TFL/examples/Subst/UTerm.thy
author wenzelm
Tue, 11 Mar 1997 13:05:11 +0100
changeset 2780 1dc77f6d83e1
parent 2113 21266526ac42
permissions -rw-r--r--
added THIS_IS_ISABELLE_BUILD discrimination;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2113
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     1
(*  Title:      Substitutions/UTerm.thy
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     2
    Author:     Martin Coen, Cambridge University Computer Laboratory
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     4
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     5
Simple term structure for unification.
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     6
Binary trees with leaves that are constants or variables.
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     7
*)
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     8
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
     9
UTerm = Finite +
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    10
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    11
datatype 'a uterm = Var ('a) 
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    12
                  | Const ('a)
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    13
                  | Comb ('a uterm) ('a uterm)
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    14
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    15
consts
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    16
  vars_of  ::  'a uterm => 'a set
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    17
  "<:"     ::  'a uterm => 'a uterm => bool   (infixl 54) 
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    18
uterm_size ::  'a uterm => nat
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    19
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    20
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    21
primrec vars_of   uterm
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    22
vars_of_Var   "vars_of (Var v) = {v}"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    23
vars_of_Const "vars_of (Const c) = {}"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    24
vars_of_Comb  "vars_of (Comb M N) = (vars_of(M) Un vars_of(N))"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    25
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    26
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    27
primrec "op <:"   uterm
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    28
occs_Var   "u <: (Var v) = False"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    29
occs_Const "u <: (Const c) = False"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    30
occs_Comb  "u <: (Comb M N) = (u=M | u=N | u <: M | u <: N)"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    31
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    32
primrec uterm_size  uterm
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    33
uterm_size_Var   "uterm_size (Var v) = 0"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    34
uterm_size_Const "uterm_size (Const c) = 0"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    35
uterm_size_Comb  "uterm_size (Comb M N) = Suc(uterm_size M + uterm_size N)"
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    36
21266526ac42 Subst as modified by Konrad Slind
paulson
parents:
diff changeset
    37
end