src/HOL/Subst/UTerm.thy
author bulwahn
Fri, 11 Mar 2011 15:21:13 +0100
changeset 41919 e180c2a9873b
parent 38140 05691ad74079
permissions -rw-r--r--
correcting dependencies after renaming
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
     1
(*  Title:      HOL/Subst/UTerm.thy
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
     6
header {* Simple Term Structure for Unification *}
15635
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    12
text {* Binary trees with leaves that are constants or variables. *}
15635
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    19
primrec vars_of :: "'a uterm => 'a set"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    20
where
15635
8408a06590a6 converted HOL-Subst to tactic scripts
paulson
parents: 12406
diff changeset
    21
  vars_of_Var:   "vars_of (Var v) = {v}"
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    22
| vars_of_Const: "vars_of (Const c) = {}"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    25
primrec occs :: "'a uterm => 'a uterm => bool"   (infixl "<:" 54) 
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    26
where
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    27
  occs_Var: "u <: (Var v) = False"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    28
| occs_Const: "u <: (Const c) = False"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    29
| occs_Comb: "u <: (Comb M N) = (u = M | u = N | u <: M | u <: N)"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    30
24823
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    31
notation (xsymbols)
bfb619994060 modernized specifications;
wenzelm
parents: 15648
diff changeset
    32
  occs  (infixl "\<prec>" 54)
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    33
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    34
primrec uterm_size ::  "'a uterm => nat"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    35
where
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    36
  uterm_size_Var: "uterm_size (Var v) = 0"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    37
| uterm_size_Const: "uterm_size (Const c) = 0"
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    38
| uterm_size_Comb: "uterm_size (Comb M N) = Suc(uterm_size M + uterm_size N)"
15635
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
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 *}
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
diff changeset
    49
lemma occs_vars_subset: "M \<prec> N \<Longrightarrow> vars_of M \<subseteq> vars_of N"
24823
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
38140
05691ad74079 modernized specifications;
wenzelm
parents: 24823
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