9 |
10 |
10 datatype 'a subst = Fail | Subst ('a list) |
11 datatype 'a subst = Fail | Subst ('a list) |
11 |
12 |
12 consts |
13 consts |
13 |
14 |
14 uterm_less :: "(('a uterm * 'a uterm) * ('a uterm * 'a uterm)) set" |
15 unifyRel :: "(('a uterm * 'a uterm) * ('a uterm * 'a uterm)) set" |
15 unifyRel :: "(('a uterm * 'a uterm) * ('a uterm * 'a uterm)) set" |
16 unify :: "'a uterm * 'a uterm => ('a * 'a uterm) subst" |
16 unify :: "'a uterm * 'a uterm => ('a * 'a uterm) subst" |
|
17 |
17 |
18 defs |
18 defs |
19 |
19 |
20 uterm_less_def "uterm_less == rprod (measure uterm_size) |
20 (*Termination relation for the Unify function: |
21 (measure uterm_size)" |
21 --either the set of variables decreases |
22 |
22 --or the first argument does (in fact, both do) |
23 (* Termination relation for the Unify function *) |
23 *) |
24 unifyRel_def "unifyRel == inv_image (finite_psubset ** uterm_less) |
24 unifyRel_def "unifyRel == inv_image (finite_psubset ** measure uterm_size) |
25 (%(x,y). (vars_of x Un vars_of y, (x,y)))" |
25 (%(M,N). (vars_of M Un vars_of N, M))" |
26 |
26 |
27 recdef unify "unifyRel" |
27 recdef unify "unifyRel" |
28 "unify(Const m, Const n) = (if (m=n) then Subst[] else Fail)" |
28 "unify(Const m, Const n) = (if (m=n) then Subst[] else Fail)" |
29 "unify(Const m, Comb M N) = Fail" |
29 "unify(Const m, Comb M N) = Fail" |
30 "unify(Const m, Var v) = Subst[(v,Const m)]" |
30 "unify(Const m, Var v) = Subst[(v,Const m)]" |