author | haftmann |
Thu, 29 Oct 2009 11:41:36 +0100 | |
changeset 33318 | ddd97d9dfbfb |
parent 24823 | bfb619994060 |
child 38140 | 05691ad74079 |
permissions | -rw-r--r-- |
15635 | 1 |
(* ID: $Id$ |
1476 | 2 |
Author: Martin Coen, Cambridge University Computer Laboratory |
968 | 3 |
Copyright 1993 University of Cambridge |
4 |
*) |
|
5 |
||
15635 | 6 |
header{*Simple Term Structure for Unification*} |
7 |
||
8 |
theory UTerm |
|
9 |
imports Main |
|
10 |
begin |
|
11 |
||
12 |
text{*Binary trees with leaves that are constants or variables.*} |
|
13 |
||
24823 | 14 |
datatype 'a uterm = |
15 |
Var 'a |
|
16 |
| Const 'a |
|
17 |
| Comb "'a uterm" "'a uterm" |
|
968 | 18 |
|
24823 | 19 |
consts vars_of :: "'a uterm => 'a set" |
15635 | 20 |
primrec |
21 |
vars_of_Var: "vars_of (Var v) = {v}" |
|
22 |
vars_of_Const: "vars_of (Const c) = {}" |
|
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 | 25 |
consts occs :: "'a uterm => 'a uterm => bool" (infixl "<:" 54) |
26 |
notation (xsymbols) |
|
27 |
occs (infixl "\<prec>" 54) |
|
5184 | 28 |
primrec |
15648 | 29 |
occs_Var: "u \<prec> (Var v) = False" |
30 |
occs_Const: "u \<prec> (Const c) = False" |
|
31 |
occs_Comb: "u \<prec> (Comb M N) = (u=M | u=N | u \<prec> M | u \<prec> N)" |
|
968 | 32 |
|
24823 | 33 |
consts |
34 |
uterm_size :: "'a uterm => nat" |
|
5184 | 35 |
primrec |
15635 | 36 |
uterm_size_Var: "uterm_size (Var v) = 0" |
37 |
uterm_size_Const: "uterm_size (Const c) = 0" |
|
38 |
uterm_size_Comb: "uterm_size (Comb M N) = Suc(uterm_size M + uterm_size N)" |
|
39 |
||
40 |
||
15648 | 41 |
lemma vars_var_iff: "(v \<in> vars_of(Var(w))) = (w=v)" |
24823 | 42 |
by auto |
15635 | 43 |
|
15648 | 44 |
lemma vars_iff_occseq: "(x \<in> vars_of(t)) = (Var(x) \<prec> t | Var(x) = t)" |
24823 | 45 |
by (induct t) auto |
15635 | 46 |
|
968 | 47 |
|
15648 | 48 |
text{* Not used, but perhaps useful in other proofs *} |
24823 | 49 |
lemma occs_vars_subset: "M\<prec>N \<Longrightarrow> vars_of(M) \<subseteq> vars_of(N)" |
50 |
by (induct N) auto |
|
15635 | 51 |
|
52 |
||
15648 | 53 |
lemma monotone_vars_of: |
24823 | 54 |
"vars_of M Un vars_of N \<subseteq> (vars_of M Un A) Un (vars_of N Un B)" |
55 |
by blast |
|
15635 | 56 |
|
57 |
lemma finite_vars_of: "finite(vars_of M)" |
|
24823 | 58 |
by (induct M) auto |
968 | 59 |
|
60 |
end |