src/HOL/Subst/UTerm.thy
author paulson
Tue, 29 Mar 2005 12:30:48 +0200
changeset 15635 8408a06590a6
parent 12406 c9775847ed66
child 15648 f6da795ee27a
permissions -rw-r--r--
converted HOL-Subst to tactic scripts
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) 
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    22
uterm_size ::  "'a uterm => nat"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    23
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    24
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    25
primrec
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    26
  vars_of_Var:   "vars_of (Var v) = {v}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    27
  vars_of_Const: "vars_of (Const c) = {}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    28
  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
    29
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    30
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    31
primrec
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    32
  occs_Var:   "u <: (Var v) = False"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    33
  occs_Const: "u <: (Const c) = False"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    34
  occs_Comb:  "u <: (Comb M N) = (u=M | u=N | u <: M | u <: N)"
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    35
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    36
primrec
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    37
  uterm_size_Var:   "uterm_size (Var v) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    38
  uterm_size_Const: "uterm_size (Const c) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    39
  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
    40
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    41
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    42
lemma vars_var_iff: "(v : vars_of(Var(w))) = (w=v)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    43
by auto
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    44
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    45
lemma vars_iff_occseq: "(x : vars_of(t)) = (Var(x) <: t | Var(x) = t)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    46
by (induct_tac "t", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    47
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    48
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    49
(* Not used, but perhaps useful in other proofs *)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    50
lemma occs_vars_subset: "M<:N --> vars_of(M) <= vars_of(N)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    51
by (induct_tac "N", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    52
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    53
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    54
lemma monotone_vars_of: "vars_of M Un vars_of N <= (vars_of M Un A) Un (vars_of N Un B)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    55
by blast
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    56
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    57
lemma finite_vars_of: "finite(vars_of M)"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    58
by (induct_tac "M", auto)
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    59
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    60
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    61
end