pub struct LogicEnv { /* private fields */ }Expand description
A unification substitution: bindings from logic variables to terms.
Carries a resolution depth so renamed clause variables stay distinct
across recursive calls.
Implementations§
Source§impl LogicEnv
impl LogicEnv
Sourcepub fn with_depth(depth: usize) -> Self
pub fn with_depth(depth: usize) -> Self
Creates an empty environment recorded at the given resolution depth.
Sourcepub fn apply(&self, expr: &Expr) -> Expr
pub fn apply(&self, expr: &Expr) -> Expr
Applies the substitution to expr, recursively replacing bound
variables with their values.
Sourcepub fn get(&self, var: &Symbol) -> Option<&Expr>
pub fn get(&self, var: &Symbol) -> Option<&Expr>
Returns the term directly bound to var, if any.
Sourcepub fn bind(
&mut self,
var: Symbol,
value: Expr,
occurs_check: OccursCheck,
) -> Result<()>
pub fn bind( &mut self, var: Symbol, value: Expr, occurs_check: OccursCheck, ) -> Result<()>
Binds var to value, honoring the OccursCheck policy.
Returns an error when an enabled occurs check detects that var occurs
in value (which would build a cyclic term).
Sourcepub fn unify(
&mut self,
left: &Expr,
right: &Expr,
occurs_check: OccursCheck,
) -> Result<bool>
pub fn unify( &mut self, left: &Expr, right: &Expr, occurs_check: OccursCheck, ) -> Result<bool>
Unifies two terms, extending the substitution in place.
Returns true when the terms unify and false on a structural
mismatch; errors propagate only from a failed occurs check.
Sourcepub fn free_vars(&self, expr: &Expr) -> Vec<Symbol>
pub fn free_vars(&self, expr: &Expr) -> Vec<Symbol>
Collects the distinct logic variables appearing in expr.
Sourcepub fn to_shape_bindings(&self, _cx: &mut Cx) -> Result<ShapeBindings>
pub fn to_shape_bindings(&self, _cx: &mut Cx) -> Result<ShapeBindings>
Projects the current bindings into kernel ShapeBindings.
Sourcepub fn as_shape_match(&self, cx: &mut Cx) -> Result<ShapeMatch>
pub fn as_shape_match(&self, cx: &mut Cx) -> Result<ShapeMatch>
Builds an accepting kernel ShapeMatch whose captures are this
environment’s bindings.
Trait Implementations§
impl Eq for LogicEnv
impl StructuralPartialEq for LogicEnv
Auto Trait Implementations§
impl Freeze for LogicEnv
impl RefUnwindSafe for LogicEnv
impl Send for LogicEnv
impl Sync for LogicEnv
impl Unpin for LogicEnv
impl UnsafeUnpin for LogicEnv
impl UnwindSafe for LogicEnv
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.