src/HOL/Subst/Unify.thy
changeset 3267 7203f4dbc0c5
parent 3192 a75558a4ed37
child 3298 5f0ed3caa991
equal deleted inserted replaced
3266:89e5f4163663 3267:7203f4dbc0c5
     1 (*  Title:      Subst/Unify
     1 (*  Title:      Subst/Unify
       
     2     ID:         $Id$
     2     Author:     Konrad Slind, Cambridge University Computer Laboratory
     3     Author:     Konrad Slind, Cambridge University Computer Laboratory
     3     Copyright   1997  University of Cambridge
     4     Copyright   1997  University of Cambridge
     4 
     5 
     5 Unification algorithm
     6 Unification algorithm
     6 *)
     7 *)
     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)]"