Background for Unification
- Terms made from constructors and variables (for the simple first order case)
- Constructors may be applied to arguments (other terms) to make new terms
- Variables and constructors with no arguments are base cases
-
Constructors applied to different number of arguments (
) considered different - Substitution of terms for variables
type term = Variable of string
| Const of (string * term list)
let x = Variable "a";;
let tm = Const ("2", []);;
let rec subst var_name residue term =
match term with Variable name ->
if var_name = name then residue else term
| Const (c, tys) ->
Const (c, List.map (subst var_name residue) tys);;Given a set of pairs of terms (“equations”)
- Type Inference and type checking
- Pattern matching as in OCaml
- Can use a simplified version of algorithm
- Logic Programming - Prolog
- Simple parsing
-
: If (they are the same term) then -
: and -
: