pub struct Substitution { /* private fields */ }Expand description
A substitution maps variables to terms.
A substitution θ = {x₁/t₁, x₂/t₂, …} represents the simultaneous replacement of each variable xᵢ with term tᵢ.
Implementations§
Source§impl Substitution
impl Substitution
Sourcepub fn from_map(bindings: HashMap<String, Term>) -> Self
pub fn from_map(bindings: HashMap<String, Term>) -> Self
Create a substitution from a map of bindings.
Sourcepub fn apply(&self, term: &Term) -> Term
pub fn apply(&self, term: &Term) -> Term
Apply this substitution to a term.
This recursively replaces all occurrences of bound variables with their substituted values.
Sourcepub fn compose(&self, other: &Substitution) -> Substitution
pub fn compose(&self, other: &Substitution) -> Substitution
Compose two substitutions: (σ ∘ θ)(x) = σ(θ(x))
The composition applies θ first, then σ.
Sourcepub fn extend(&mut self, var: String, term: Term) -> Result<(), IrError>
pub fn extend(&mut self, var: String, term: Term) -> Result<(), IrError>
Extend this substitution with a new binding.
Returns an error if the binding conflicts with existing bindings.
Sourcepub fn try_extend(&mut self, other: &Substitution) -> Result<(), IrError>
pub fn try_extend(&mut self, other: &Substitution) -> Result<(), IrError>
Try to extend this substitution with all bindings from another substitution.
This is used for subsumption checking where we need to merge substitutions. Returns an error if any binding conflicts with existing bindings.
Trait Implementations§
Source§impl Clone for Substitution
impl Clone for Substitution
Source§fn clone(&self) -> Substitution
fn clone(&self) -> Substitution
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Substitution
impl Debug for Substitution
Source§impl Default for Substitution
impl Default for Substitution
Source§fn default() -> Substitution
fn default() -> Substitution
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Substitution
impl<'de> Deserialize<'de> for Substitution
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Substitution
impl PartialEq for Substitution
Source§impl Serialize for Substitution
impl Serialize for Substitution
impl StructuralPartialEq for Substitution
Auto Trait Implementations§
impl Freeze for Substitution
impl RefUnwindSafe for Substitution
impl Send for Substitution
impl Sync for Substitution
impl Unpin for Substitution
impl UnwindSafe for Substitution
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