src/HOL/Subst/UTerm.thy
author wenzelm
Mon, 16 Mar 2009 18:24:30 +0100
changeset 30549 d2d7874648bd
parent 24823 bfb619994060
child 38140 05691ad74079
permissions -rw-r--r--
simplified method setup;
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
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    10
begin
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    11
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    12
text{*Binary trees with leaves that are constants or variables.*}
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    13
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    14
datatype 'a uterm =
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    15
    Var 'a
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    16
  | Const 'a
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    17
  | Comb "'a uterm" "'a uterm"
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    18
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    19
consts vars_of :: "'a uterm => 'a set"
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    20
primrec
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    21
  vars_of_Var:   "vars_of (Var v) = {v}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    22
  vars_of_Const: "vars_of (Const c) = {}"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    23
  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
    24
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    25
consts occs :: "'a uterm => 'a uterm => bool"   (infixl "<:" 54) 
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    26
notation (xsymbols)
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    27
  occs  (infixl "\<prec>" 54)
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    28
primrec
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    29
  occs_Var:   "u \<prec> (Var v) = False"
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    30
  occs_Const: "u \<prec> (Const c) = False"
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    31
  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
    32
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    33
consts
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    34
  uterm_size ::  "'a uterm => nat"
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 3268
diff changeset
    35
primrec
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    36
  uterm_size_Var:   "uterm_size (Var v) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    37
  uterm_size_Const: "uterm_size (Const c) = 0"
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    38
  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
    39
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    40
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    41
lemma vars_var_iff: "(v \<in> vars_of(Var(w))) = (w=v)"
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    42
  by auto
15635
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_iff_occseq: "(x \<in> vars_of(t)) = (Var(x) \<prec> t | Var(x) = t)"
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    45
  by (induct t) auto
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    46
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    47
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    48
text{* Not used, but perhaps useful in other proofs *}
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    49
lemma occs_vars_subset: "M\<prec>N \<Longrightarrow> vars_of(M) \<subseteq> vars_of(N)"
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    50
  by (induct N) auto
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    51
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    52
15648
f6da795ee27a x-symbols and other tidying
paulson
parents: 15635
diff changeset
    53
lemma monotone_vars_of:
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    54
    "vars_of M Un vars_of N \<subseteq> (vars_of M Un A) Un (vars_of N Un B)"
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    55
  by blast
15635
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)"
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    58
  by (induct M) auto
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    59
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    60
end