protocol
atms_protocol
Portable, functional Assumption-based Truth Maintenance System API.
logtalk_load(atms(loader))static
State: All update predicates take an input ATMS state and return a new state. This permits several ATMS instances without relying on backend-specific mutable databases.
Retraction: Node and batch justification removal is idempotent. Single justification removal deletes one matching occurrence. Earlier states and surviving identifiers are preserved.
Environments: The public API uses ordered lists of node identifiers. The representation selected when creating a state is internal.
Public predicates
new/1
Creates a new empty ATMS using the default ordered-list environment representation.
staticnew(State)new(-atms_state) - onenew/2
Creates a new empty ATMS using the specified environment representation object. Fails if the object does not conform to the environment protocol.
staticnew(Representation,State)new(+object,-atms_state) - zero_or_oneclear/2
Returns a new empty ATMS using the same environment representation as the given state.
staticclear(State,ClearedState)clear(+atms_state,-atms_state) - onerepresentation/2
Returns the environment representation object used by the given state.
staticrepresentation(State,Representation)representation(+atms_state,?object) - onecreate_node/4
Creates an ordinary node for the given datum and returns the updated state.
staticcreate_node(Datum,State,Node,NewState)create_node(+term,+atms_state,-atms_node,-atms_state) - onecreate_assumption/4
Creates an assumption node for the given datum and returns the updated state.
staticcreate_assumption(Datum,State,Assumption,NewState)create_assumption(+term,+atms_state,-atms_node,-atms_state) - onecreate_contradiction/4
Creates a contradiction node for the given datum and returns the updated state.
staticcreate_contradiction(Datum,State,Contradiction,NewState)create_contradiction(+term,+atms_state,-atms_node,-atms_state) - onejustify/5
Adds a Horn justification from the antecedent nodes to the consequent node, incrementally propagating label changes. Fails if any referenced node is unknown.
staticjustify(Consequent,Antecedents,Info,State,NewState)justify(+atms_node,+list(atms_node),+term,+atms_state,-atms_state) - zero_or_oneretract_justification/5
Removes one occurrence of the specified Horn justification, rebuilding labels and nogoods when needed. Returns the input state unchanged if the justification is absent.
staticretract_justification(Consequent,Antecedents,Info,State,NewState)retract_justification(+atms_node,+list(atms_node),+term,+atms_state,-atms_state) - one
Identity: Antecedents are sorted and deduplicated as in
justify/5. The complete justification, including Info, is matched using term identity rather than unification.Occurrences: If variable aliasing has made distinct stored rules identical, removes the most recently added matching occurrence. Use
retract_justifications/3to remove all matches.Redundant rules: If another rule with the same consequent and canonical antecedents remains, preserves labels and nogoods and removes only the stored rule and its reverse dependency entries. Info is ignored only for this redundancy check.
retract_justifications/3
Removes all occurrences matching the requested justification terms, rebuilding derived state at most once. Returns the input state unchanged if none match.
staticretract_justifications(Justifications,State,NewState)retract_justifications(+list(term),+atms_state,-atms_state) - one
Targets: Each target is a
justification(Consequent, Antecedents, Info)term. Antecedents are sorted and deduplicated; the full term is matched using term identity.Idempotence: Missing targets and duplicate requests have no additional effect. All matching stored occurrences are removed, including those made identical by variable aliasing.
Redundant rules: Preserves labels and nogoods if every removed consequent and canonical antecedent signature still has a surviving rule, regardless of Info. Reverse dependencies retain the surviving occurrence counts.
retract_node/3
Removes an ordinary, assumption, or contradiction node and all justifications mentioning it, rebuilding derived state when needed. Returns the input state unchanged if the node is absent.
staticretract_node(Node,State,NewState)retract_node(+atms_node,+atms_state,-atms_state) - one
Dependents: Other nodes are retained even when they lose all support.
Isolated nodes: Removing a non-assumption node that appears in no justification deletes its label entry without rebuilding other labels, nogoods, or dependency indexes.
Identifiers: Surviving node identifiers are preserved and removed identifiers are not reused in descendant states.
retract_nodes/3
Removes the requested nodes and every justification mentioning any of them, rebuilding derived state at most once. Returns the input state unchanged if no nodes are removed.
staticretract_nodes(Nodes,State,NewState)retract_nodes(+list(atms_node),+atms_state,-atms_state) - one
Targets: Missing nodes and duplicate requests are ignored. All other nodes are retained, even when they lose all support.
Isolated nodes: If no assumption or incident justification is removed, only node, role, and label entries are deleted; other derived indexes are preserved.
Identifiers: Surviving identifiers and the next node identifier are preserved.
retract_batch/4
Removes requested nodes, their incident justifications, and all exact matches for requested justification terms in one batch, rebuilding derived state at most once.
staticretract_batch(Nodes,Justifications,State,NewState)retract_batch(+list(atms_node),+list(term),+atms_state,-atms_state) - one
Targets: Uses the same canonical antecedents and complete term identity as
retract_justifications/3. Missing targets and duplicate or overlapping requests are ignored.Occurrences: Every matching stored occurrence is removed, including occurrences made identical by variable aliasing.
Identifiers: Surviving nodes, identifiers, and rule insertion order are preserved. Other nodes remain even when they lose support.
No changes: Returns the input state unchanged if no targets match. Isolated non-assumption node removal preserves the other derived indexes.
Redundant rules: If no nodes are removed, uses the same redundant-rule fast path as
retract_justifications/3. Effective node removal affecting assumptions or rules rebuilds once.
node/2
Enumerates or tests the nodes in the given state.
staticnode(Node,State)node(?atms_node,+atms_state) - zero_or_moreassumption/2
Enumerates or tests the assumption nodes in the given state.
staticassumption(Assumption,State)assumption(?atms_node,+atms_state) - zero_or_morecontradiction/2
Enumerates or tests the contradiction nodes in the given state.
staticcontradiction(Contradiction,State)contradiction(?atms_node,+atms_state) - zero_or_morenodes/2
Returns the node-datum pairs in node identifier order.
staticnodes(State,Nodes)nodes(+atms_state,-list(pair)) - oneassumptions/2
Returns the assumption nodes in node identifier order.
staticassumptions(State,Assumptions)assumptions(+atms_state,-list(atms_node)) - onejustifications/2
Returns all justifications in insertion order.
staticjustifications(State,Justifications)justifications(+atms_state,-list(term)) - onelabel/3
Returns the minimal consistent environments supporting the given node. Fails if the node is unknown.
staticlabel(Node,State,Environments)label(+atms_node,+atms_state,-list(list(atms_node))) - zero_or_onein_label/3
True iff the given environment is a member of the node label.
staticin_label(Node,Environment,State)in_label(+atms_node,+list(atms_node),+atms_state) - zero_or_oneconsistent/2
True iff the given environment contains no recorded nogood.
staticconsistent(Environment,State)consistent(+list(atms_node),+atms_state) - zero_or_onenogood/2
Enumerates or tests the minimal nogood environments in the given state.
staticnogood(Environment,State)nogood(?list(atms_node),+atms_state) - zero_or_moreinterpretations/2
Returns the maximal consistent environments over all assumptions.
staticinterpretations(State,Interpretations)interpretations(+atms_state,-list(list(atms_node))) - onewhy/3
Returns the direct justifications for the given node in insertion order.
staticwhy(Node,State,Justifications)why(+atms_node,+atms_state,-list(term)) - oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)