TruthMaintenanceSystem

Struct TruthMaintenanceSystem 

Source
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

Source

pub fn new() -> Self

Create a new TMS

Source

pub fn add_explicit_justification(&mut self, fact_handle: FactHandle)

Add an explicit justification (user asserted fact)

Source

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 fact
  • source_rule - Name of the rule that derived it
  • premise_facts - Facts that were matched in the rule’s WHEN clause
Source

pub fn is_logical(&self, fact_handle: FactHandle) -> bool

Check if a fact is logically asserted (derived by rules)

Source

pub fn is_explicit(&self, fact_handle: FactHandle) -> bool

Check if a fact is explicitly asserted (by user)

Source

pub fn get_justifications(&self, fact_handle: FactHandle) -> Vec<&Justification>

Get all justifications for a fact

Source

pub fn has_valid_justification(&self, fact_handle: FactHandle) -> bool

Check if a fact still has valid justifications

Source

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

Source

pub fn remove_justifications(&mut self, fact_handle: FactHandle)

Remove all justifications for a fact

Source

pub fn stats(&self) -> TmsStats

Get statistics about the TMS

Source

pub fn clear(&mut self)

Clear all TMS data

Source

pub fn get_logical_facts(&self) -> &HashSet<FactHandle>

Get all logical facts

Source

pub fn get_explicit_facts(&self) -> &HashSet<FactHandle>

Get all explicit facts

Trait Implementations§

Source§

impl Default for TruthMaintenanceSystem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.