src/HOL/Subst/UTerm.thy
author haftmann
Tue, 10 Jul 2007 17:30:50 +0200
changeset 23709 fd31da8f752a
parent 15648 f6da795ee27a
child 24823 bfb619994060
permissions -rw-r--r--
moved lfp_induct2 here
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
     1
(*  ID:         $Id$
1476
608483c2122a expanded tabs; incorporated Konrad's changes
clasohm
parents: 1381
diff changeset
     2
    Author:     Martin Coen, Cambridge University Computer Laboratory
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     4
*)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     5
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
     6
header{*Simple Term Structure for Unification*}
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
     7
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
     8
theory UTerm
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
     9
imports Main
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    10
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    11
begin
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    12
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    13
text{*Binary trees with leaves that are constants or variables.*}
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    14
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    15
datatype 'a uterm = Var 'a
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    16
                  | Const 'a
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    17
                  | Comb "'a uterm" "'a uterm"
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    18
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    19
consts
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    20
  vars_of  ::  "'a uterm => 'a set"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    21
  "<:"     ::  "'a uterm => 'a uterm => bool"   (infixl 54) 
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    22
  uterm_size ::  "'a uterm => nat"
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    23
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    24
syntax (xsymbols)
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    25
  "op <:"     ::  "'a uterm => 'a uterm => bool"   (infixl "\<prec>" 54) 
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    26
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    27
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    28
primrec
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    29
  vars_of_Var:   "vars_of (Var v) = {v}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    30
  vars_of_Const: "vars_of (Const c) = {}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    31
  vars_of_Comb:  "vars_of (Comb M N) = (vars_of(M) Un vars_of(N))"
3192
a75558a4ed37 New version, modified by Konrad Slind and LCP for TFL
paulson
parents: 2903
diff changeset
    32
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    33
primrec
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    34
  occs_Var:   "u \<prec> (Var v) = False"
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    35
  occs_Const: "u \<prec> (Const c) = False"
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    36
  occs_Comb:  "u \<prec> (Comb M N) = (u=M | u=N | u \<prec> M | u \<prec> N)"
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    37
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    38
primrec
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    39
  uterm_size_Var:   "uterm_size (Var v) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    40
  uterm_size_Const: "uterm_size (Const c) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    41
  uterm_size_Comb:  "uterm_size (Comb M N) = Suc(uterm_size M + uterm_size N)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    42
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    43
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    44
lemma vars_var_iff: "(v \<in> vars_of(Var(w))) = (w=v)"
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    45
by auto
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    46
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    47
lemma vars_iff_occseq: "(x \<in> vars_of(t)) = (Var(x) \<prec> t | Var(x) = t)"
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    48
by (induct_tac "t", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    49
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    50
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    51
text{* Not used, but perhaps useful in other proofs *}
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    52
lemma occs_vars_subset [rule_format]: "M\<prec>N --> vars_of(M) \<subseteq> vars_of(N)"
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    53
by (induct_tac "N", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    54
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    55
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    56
lemma monotone_vars_of:
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    57
     "vars_of M Un vars_of N \<subseteq> (vars_of M Un A) Un (vars_of N Un B)"
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    58
by blast
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    59
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    60
lemma finite_vars_of: "finite(vars_of M)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    61
by (induct_tac "M", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    62
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    63
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    64
end