protocol
stn_protocol
Portable, functional Simple Temporal Networks over closed difference constraints.
logtalk_load(simple_temporal_networks(loader))static
Constraints: A constraint from
XtoYwith weightDeltameanstime(Y) - time(X) =< Delta.Inputs: States must be opaque ground terms returned by this API. Malformed public arguments and unknown time-points fail without instantiating inputs; hand-built internal states are unsupported.
Numbers: Weights are finite integers or floats. Arithmetic errors propagate; floating-point results are approximate, with no implicit tolerance.
Bounds: Unbounded query results use the atoms positive_infinity and negative_infinity, never native numeric infinities.
Public predicates
new/2
Creates an unconstrained network over distinct ground time-points and a reserved reference time-point zero fixed at time zero. Fails for duplicate labels or an explicitly supplied zero.
staticnew(TimePoints,STN)new(+list,-stn) - zero_or_oneadd_time_points/3
Appends distinct fresh ground time-points, rebuilding once and preserving source identifiers. Fails for existing labels or zero. An empty list returns the original state.
staticadd_time_points(STN0,TimePoints,STN)add_time_points(+stn,+list,-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)remove_time_points/3
Removes time-points and all incident source constraints, rebuilding once and preserving surviving node order and source identifiers. Missing labels and duplicate requests are ignored. Fails for a request containing zero or a malformed or nonground list.
staticremove_time_points(STN0,TimePoints,STN)remove_time_points(+stn,+list,-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)
Bounds: Deletion retracts incident sources, not just variables. Bounds supported through removed points may weaken or become unbounded; implied bounds are not preserved as new constraints.
Identity: Labels are compared by term identity. The original state and next source identifier are preserved. A request removing no existing point returns the original state.
time_points/2
Returns the declared time-points in insertion order, with zero first.
statictime_points(STN,TimePoints)time_points(+stn,-list) - zero_or_oneconstraints/2
Returns all source constraints in insertion order as constraint(Id, X, Y, Delta) terms, including redundant and parallel constraints.
staticconstraints(STN,Constraints)constraints(+stn,-list(compound)) - zero_or_oneconsistent/1
True if the argument is a library-owned consistent state. All successfully returned states are consistent; this predicate is not an importer for hand-built internal terms.
staticconsistent(STN)consistent(+stn) - zero_or_oneschedule/2
Returns one finite feasible assignment as time(Point, Value) terms in declaration order, with time(zero, 0) first. Fails for invalid states without instantiating inputs.
staticschedule(STN,Schedule)schedule(+stn,-list(compound)) - zero_or_one_or_errorevaluation_error(A)representation_error(A)
Choice: The assignment is deterministic, not necessarily unique, earliest, non-negative, or optimal. Disconnected and absolutely unbounded points are assigned finite values.
Numbers: Every retained source inequality is checked after normalization using backend arithmetic. Floating-point results remain approximate, with no implicit tolerance.
earliest_schedule/2
Returns the componentwise earliest feasible assignment as time(Point, Value) terms in declaration order, with time(zero, 0) first. Requires every declared point to have a finite absolute lower bound. Fails for invalid states or any unbounded lower bound without instantiating inputs.
staticearliest_schedule(STN,Schedule)earliest_schedule(+stn,-list(compound)) - zero_or_one_or_errorevaluation_error(A)representation_error(A)
Bounds: Finite upper bounds are not required. No artificial lower bounds are introduced and the original state and source identifiers are unchanged.
Numbers: Componentwise minimality holds in exact arithmetic. Every retained source inequality is checked using backend arithmetic; floating-point feasibility and optimality are not exact-real guarantees and no tolerance is applied.
add_constraint/5
Adds Y - X =< Delta, retaining the source even when redundant. Fails if the result is inconsistent or the inputs are invalid.
staticadd_constraint(STN0,X,Y,Delta,STN)add_constraint(+stn,@term,@term,+number,-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)add_constraint/6
Adds Y - X =< Delta and returns its source identifier. Fails for an inconsistent result or invalid inputs. Identifiers are local to a state lineage, not globally unique across forks.
staticadd_constraint(STN0,X,Y,Delta,Id,STN)add_constraint(+stn,@term,@term,+number,-integer,-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)add_constraints/3
Atomically adds a batch of constraint(X, Y, Delta) terms, rebuilding once. Fails if any input is invalid or the combined network is inconsistent. An empty batch returns the original state.
staticadd_constraints(STN0,Constraints,STN)add_constraints(+stn,+list(compound),-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)add_constraints/4
Atomically adds constraint(X, Y, Delta) terms and returns their source identifiers in batch order. Fails for invalid inputs or an inconsistent result.
staticadd_constraints(STN0,Constraints,Ids,STN)add_constraints(+stn,+list(compound),-list(integer),-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)try_add_constraints/4
Attempts a batch update and returns consistent(STN) or inconsistent(cycle(Sources, Weight)). The cycle is an ordered closed path of identified source constraints with negative total weight, not necessarily a minimal conflict. Invalid inputs fail.
statictry_add_constraints(STN0,Constraints,Ids,Outcome)try_add_constraints(+stn,+list(compound),-list(integer),-compound) - zero_or_one_or_errorevaluation_error(A)representation_error(A)
Identifiers: Ids identifies candidate constraints in batch order even when rejected. No state is changed; rejected identifiers may coincide with later accepted allocations from the original state.
Arithmetic: Backend arithmetic errors propagate. Non-finite computed sums raise evaluation_error(float_overflow); inconsistent numerical diagnostics raise evaluation_error(stn_numerical_inconsistency).
remove_constraints/3
Removes source constraints by positive integer identifier, rebuilding once if necessary. Missing identifiers and duplicate requests are ignored. Surviving identifiers are preserved and removed identifiers are never reused in descendant states.
staticremove_constraints(STN0,Ids,STN)remove_constraints(+stn,+list(integer),-stn) - zero_or_one_or_errorevaluation_error(A)representation_error(A)distance/4
Returns the tightest upper bound on Y - X, or positive_infinity if no directed path exists.
staticdistance(STN,X,Y,Upper)distance(+stn,@term,@term,-bound) - zero_or_onedistance/5
Returns a finite tight upper bound on Y - X and one ordered supporting source-constraint path. Fails for an unreachable pair. An identity query returns zero and an empty path. Ties select one deterministic witness, not every support.
staticdistance(STN,X,Y,Upper,Path)distance(+stn,@term,@term,-number,-list(compound)) - zero_or_one_or_errorevaluation_error(stn_numerical_inconsistency)entails/4
True if the network entails Y - X =< Delta for a finite integer or float Delta.
staticentails(STN,X,Y,Delta)entails(+stn,@term,@term,+number) - zero_or_oneentails/5
True if the network entails Y - X =< Delta and returns one supporting source-constraint path.
staticentails(STN,X,Y,Delta,Path)entails(+stn,@term,@term,+number,-list(compound)) - zero_or_oneevaluation_error(stn_numerical_inconsistency)earliest/3
Returns the earliest feasible time relative to zero, or negative_infinity when unbounded.
staticearliest(STN,TimePoint,Earliest)earliest(+stn,@term,-bound) - zero_or_onelatest/3
Returns the latest feasible time relative to zero, or positive_infinity when unbounded.
staticlatest(STN,TimePoint,Latest)latest(+stn,@term,-bound) - zero_or_onebounds/4
Returns the tightest absolute time window, including symbolic unbounded endpoints. The reference point zero has bounds [0, 0].
staticbounds(STN,TimePoint,Earliest,Latest)bounds(+stn,@term,-bound,-bound) - zero_or_onedifference_bounds/5
Returns tight bounds Lower =< Y - X =< Upper. Lower is the negated reverse distance, Upper the forward distance. Either endpoint may be symbolically unbounded.
staticdifference_bounds(STN,X,Y,Lower,Upper)difference_bounds(+stn,@term,@term,-bound,-bound) - zero_or_onecan_precede/3
True if some feasible schedule has X strictly earlier than Y. Tests whether the upper bound on Y - X is positive or unbounded.
staticcan_precede(STN,X,Y)can_precede(+stn,@term,@term) - zero_or_onemust_precede/3
True if every feasible schedule has X strictly earlier than Y. Tests whether the lower bound on Y - X is positive.
staticmust_precede(STN,X,Y)must_precede(+stn,@term,@term) - zero_or_onecan_precede_or_equal/3
True if some feasible schedule has X no later than Y. Tests whether the upper bound on Y - X is non-negative or unbounded.
staticcan_precede_or_equal(STN,X,Y)can_precede_or_equal(+stn,@term,@term) - zero_or_onemust_precede_or_equal/3
True if every feasible schedule has X no later than Y. Tests whether the lower bound on Y - X is non-negative.
staticmust_precede_or_equal(STN,X,Y)must_precede_or_equal(+stn,@term,@term) - zero_or_onewindow_interval/3
Returns a finite non-degenerate marginal time-point window as i(Start, End), preserving endpoint numeric representations. Fails for unknown points, invalid states, and unbounded or singleton windows.
staticwindow_interval(STN,TimePoint,Interval)window_interval(+stn,@term,-compound) - zero_or_one
Numeric ordering: The descriptor uses arithmetic endpoint ordering, not term ordering. It is numeric data, not a portable replacement for the ranked interval bridge.
Envelope: Describes marginal absolute bounds, not an event duration or joint endpoint correlations.
event_interval/4
Returns a concrete event interval as i(Start, End), preserving endpoint numeric representations. Both points must have finite singleton absolute bounds and the duration must be strictly positive. Fails for invalid states and unknown, uncertain, unbounded, reversed, or zero-duration endpoints.
staticevent_interval(STN,StartPoint,EndPoint,Interval)event_interval(+stn,@term,@term,-compound) - zero_or_one
Numeric ordering: The descriptor uses arithmetic endpoint ordering, not term ordering. Use event_relation/6 for the portable ranked Allen-relation bridge.
window_relation/4
Classifies two finite, non-degenerate marginal time-point windows using Allen relations. Fails for unbounded or singleton windows. This is an envelope diagnostic, not an entailed relation between uncertain events.
staticwindow_relation(STN,TimePoint1,TimePoint2,Relation)window_relation(+stn,@term,@term,-atom) - zero_or_one
Numeric ordering: Delegates to interval after jointly ranking endpoints by arithmetic value, preserving numeric equality across integers and floats.
event_relation/6
Classifies two concrete event intervals using Allen relations. All four endpoint time-points must have finite singleton absolute bounds and each event must have strictly positive duration. Fails for uncertain, unbounded, reversed, or zero-duration events.
staticevent_relation(STN,Start1,End1,Start2,End2,Relation)event_relation(+stn,@term,@term,@term,@term,-atom) - zero_or_one
Numeric ordering: Delegates to interval after jointly ranking endpoints by arithmetic value, without converting integer endpoints to floats.
Protected predicates
(none)
Private predicates
(none)
Operators
(none)