pub struct TruthMaintenanceSystem { /* private fields */ }Expand description
Truth Maintenance System
Tracks justifications for facts and automatically maintains consistency by retracting derived facts when their premises become invalid.
Implementations§
Source§impl TruthMaintenanceSystem
impl TruthMaintenanceSystem
Sourcepub fn add_explicit_justification(&mut self, fact_handle: FactHandle)
pub fn add_explicit_justification(&mut self, fact_handle: FactHandle)
Add an explicit justification (user asserted fact)
Sourcepub fn add_logical_justification(
&mut self,
fact_handle: FactHandle,
source_rule: String,
premise_facts: Vec<FactHandle>,
)
pub fn add_logical_justification( &mut self, fact_handle: FactHandle, source_rule: String, premise_facts: Vec<FactHandle>, )
Add a logical justification (rule derived fact)
§Arguments
fact_handle- The derived factsource_rule- Name of the rule that derived itpremise_facts- Facts that were matched in the rule’s WHEN clause
Sourcepub fn is_logical(&self, fact_handle: FactHandle) -> bool
pub fn is_logical(&self, fact_handle: FactHandle) -> bool
Check if a fact is logically asserted (derived by rules)
Sourcepub fn is_explicit(&self, fact_handle: FactHandle) -> bool
pub fn is_explicit(&self, fact_handle: FactHandle) -> bool
Check if a fact is explicitly asserted (by user)
Sourcepub fn get_justifications(&self, fact_handle: FactHandle) -> Vec<&Justification>
pub fn get_justifications(&self, fact_handle: FactHandle) -> Vec<&Justification>
Get all justifications for a fact
Sourcepub fn has_valid_justification(&self, fact_handle: FactHandle) -> bool
pub fn has_valid_justification(&self, fact_handle: FactHandle) -> bool
Check if a fact still has valid justifications
Sourcepub fn retract_with_cascade(
&mut self,
fact_handle: FactHandle,
) -> Vec<FactHandle>
pub fn retract_with_cascade( &mut self, fact_handle: FactHandle, ) -> Vec<FactHandle>
Retract a fact and cascade to dependent facts
Returns a list of facts that should be retracted due to cascade
Sourcepub fn remove_justifications(&mut self, fact_handle: FactHandle)
pub fn remove_justifications(&mut self, fact_handle: FactHandle)
Remove all justifications for a fact
Sourcepub fn get_logical_facts(&self) -> &HashSet<FactHandle>
pub fn get_logical_facts(&self) -> &HashSet<FactHandle>
Get all logical facts
Sourcepub fn get_explicit_facts(&self) -> &HashSet<FactHandle>
pub fn get_explicit_facts(&self) -> &HashSet<FactHandle>
Get all explicit facts
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TruthMaintenanceSystem
impl RefUnwindSafe for TruthMaintenanceSystem
impl Send for TruthMaintenanceSystem
impl Sync for TruthMaintenanceSystem
impl Unpin for TruthMaintenanceSystem
impl UnwindSafe for TruthMaintenanceSystem
Blanket Implementations§
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
Mutably borrows from an owned value. Read more