pub struct Substitution { /* private fields */ }Expand description
Vec-based substitution with trail for efficient backtracking. Bindings are stored in a Vec indexed by VarId (O(1) lookup/bind). The trail records which VarIds were bound, enabling undo on backtracking.
Implementations§
Source§impl Substitution
impl Substitution
pub fn new() -> Self
Sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Create a substitution pre-sized for the given number of variables.
Sourcepub fn trail_mark(&self) -> usize
pub fn trail_mark(&self) -> usize
Get the current trail mark (for backtracking).
Sourcepub fn walk(&self, term: &Term) -> Term
pub fn walk(&self, term: &Term) -> Term
Dereference: follow variable chains to their ultimate value.
Sourcepub fn apply(&self, term: &Term) -> Term
pub fn apply(&self, term: &Term) -> Term
Deep walk: recursively substitute all variables in a term. Handles circular terms (from unification without occurs check) by stopping expansion when a variable cycle is detected.
Sourcepub fn unify(&mut self, t1: &Term, t2: &Term) -> bool
pub fn unify(&mut self, t1: &Term, t2: &Term) -> bool
Unify two terms. Returns true if unification succeeds. On failure, bindings made during this attempt remain (caller should undo via trail).
Sourcepub fn unify_with_occurs_check(&mut self, t1: &Term, t2: &Term) -> bool
pub fn unify_with_occurs_check(&mut self, t1: &Term, t2: &Term) -> bool
Unify with occurs check (ISO 8.2.2). Fails if binding a variable would create a circular term.
Trait Implementations§
Source§impl Clone for Substitution
impl Clone for Substitution
Source§fn clone(&self) -> Substitution
fn clone(&self) -> Substitution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more