pub struct TruthMaintenanceSystem { /* private fields */ }Expand description
Justification-based Truth Maintenance System.
Nodes can be axioms (always-on unless retracted) or derived (supported only when all antecedent nodes are supported).
Implementations§
Source§impl TruthMaintenanceSystem
impl TruthMaintenanceSystem
Sourcepub fn add_axiom(&mut self, statement: impl Into<String>) -> usize
pub fn add_axiom(&mut self, statement: impl Into<String>) -> usize
Add an axiom node. Axiom nodes are always supported until retracted.
Returns the new node’s id.
Sourcepub fn add_derived(
&mut self,
statement: impl Into<String>,
from: Vec<usize>,
) -> usize
pub fn add_derived( &mut self, statement: impl Into<String>, from: Vec<usize>, ) -> usize
Add a derived node that is supported exactly when all nodes in from
are supported.
Returns the new node’s id.
Sourcepub fn retract(&mut self, node_id: usize)
pub fn retract(&mut self, node_id: usize)
Retract (un-support) a node and propagate unsupport to all dependents.
Sourcepub fn restore(&mut self, node_id: usize)
pub fn restore(&mut self, node_id: usize)
Attempt to re-support a node that was previously retracted.
For an axiom: re-supports unless still in the retraction set (but we remove it from the set here). For a derived node: re-supports only when all antecedents are supported.
Sourcepub fn is_supported(&self, node_id: usize) -> bool
pub fn is_supported(&self, node_id: usize) -> bool
Return whether node node_id is currently supported.
Sourcepub fn supported_count(&self) -> usize
pub fn supported_count(&self) -> usize
Count supported nodes.
Sourcepub fn unsupported_count(&self) -> usize
pub fn unsupported_count(&self) -> usize
Count unsupported nodes.
Sourcepub fn dependents(&self, node_id: usize) -> Vec<usize>
pub fn dependents(&self, node_id: usize) -> Vec<usize>
Return all node IDs that directly depend on node_id.
Trait Implementations§
Source§impl Debug for TruthMaintenanceSystem
impl Debug for TruthMaintenanceSystem
Auto Trait Implementations§
impl Freeze for TruthMaintenanceSystem
impl RefUnwindSafe for TruthMaintenanceSystem
impl Send for TruthMaintenanceSystem
impl Sync for TruthMaintenanceSystem
impl Unpin for TruthMaintenanceSystem
impl UnsafeUnpin for TruthMaintenanceSystem
impl UnwindSafe for TruthMaintenanceSystem
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more