mrs-unify 0.1.0

First-order unification and matching algorithms
Documentation
  • Coverage
  • 70.59%
    12 out of 17 items documented3 out of 6 items with examples
  • Size
  • Source code size: 17.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 564.87 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • newca12/mrs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • newca12

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 mrs_core::{Term, SymbolTable};
use mrs_unify::unify;

let mut syms = SymbolTable::new();
let f = syms.intern("f");
let a = syms.intern("a");

// Unify f(X, a) with f(b, Y)
let b = syms.intern("b");
let t1 = Term::app(f, vec![Term::var(0), Term::constant(a)]);
let t2 = Term::app(f, vec![Term::constant(b), Term::var(1)]);

let mgu = unify(&t1, &t2).unwrap();
// X -> b, Y -> a
assert_eq!(mgu.apply_term(&Term::var(0)), Term::constant(b));
assert_eq!(mgu.apply_term(&Term::var(1)), Term::constant(a));