First-order unification and matching algorithms.
This crate provides algorithms for finding substitutions that make terms equal:
- [
unify] - Most general unifier (MGU) of two terms - [
match_term] - One-way matching: find a substitution making a pattern equal to a target
Multiple algorithm implementations are available for educational comparison:
- [
robinson] - Classic recursive algorithm (simple, easy to understand)
Examples
use ;
use unify;
let mut syms = new;
let f = syms.intern;
let a = syms.intern;
// Unify f(X, a) with f(b, Y)
let b = syms.intern;
let t1 = app;
let t2 = app;
let mgu = unify.unwrap;
// X -> b, Y -> a
assert_eq!;
assert_eq!;