pub struct LogicSolver { /* private fields */ }Expand description
Logic solver with semantic integration
Implementations§
Source§impl LogicSolver
impl LogicSolver
Sourcepub fn new(config: SolverConfig) -> Result<Self>
pub fn new(config: SolverConfig) -> Result<Self>
Create a new logic solver
Sourcepub fn with_defaults() -> Result<Self>
pub fn with_defaults() -> Result<Self>
Create with default configuration
Sourcepub fn add_fact(&mut self, fact: Predicate, cid: Cid) -> Result<()>
pub fn add_fact(&mut self, fact: Predicate, cid: Cid) -> Result<()>
Add a fact to the knowledge base and index it
Sourcepub fn add_rule(&mut self, head: Predicate, body: Vec<Predicate>) -> Result<()>
pub fn add_rule(&mut self, head: Predicate, body: Vec<Predicate>) -> Result<()>
Add a rule to the knowledge base
Sourcepub fn find_similar_predicates(
&self,
query: &Predicate,
k: usize,
) -> Result<Vec<(Cid, Predicate, f32)>>
pub fn find_similar_predicates( &self, query: &Predicate, k: usize, ) -> Result<Vec<(Cid, Predicate, f32)>>
Find similar predicates using semantic search
Sourcepub fn query(&self, goal: &Predicate) -> Result<Vec<Substitution>>
pub fn query(&self, goal: &Predicate) -> Result<Vec<Substitution>>
Query using backward chaining with semantic relevance
Sourcepub fn query_with_depth(
&self,
goal: &Predicate,
max_depth: usize,
) -> Result<Vec<Substitution>>
pub fn query_with_depth( &self, goal: &Predicate, max_depth: usize, ) -> Result<Vec<Substitution>>
Query with depth limit and semantic guidance
Sourcepub fn backward_chain(
&self,
goal: &Predicate,
) -> Result<Vec<(Substitution, f32)>>
pub fn backward_chain( &self, goal: &Predicate, ) -> Result<Vec<(Substitution, f32)>>
Perform backward chaining with semantic search fallback
This combines traditional backward chaining with semantic search:
- Try exact unification first
- If that fails, search for similar predicates
- Use similarity scores to rank results
Sourcepub fn would_cycle(&self, goal: &Predicate, _depth: usize) -> bool
pub fn would_cycle(&self, goal: &Predicate, _depth: usize) -> bool
Check if a query would create a cycle
Sourcepub fn stats(&self) -> SolverStats
pub fn stats(&self) -> SolverStats
Get knowledge base statistics
Auto Trait Implementations§
impl Freeze for LogicSolver
impl !RefUnwindSafe for LogicSolver
impl Send for LogicSolver
impl Sync for LogicSolver
impl Unpin for LogicSolver
impl !UnwindSafe for LogicSolver
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.