author | urbanc |
Tue, 13 Dec 2005 18:11:21 +0100 | |
changeset 18396 | b3e7da94b51f |
parent 18257 | 2124b24454dd |
child 19086 | 1b3780be6cc2 |
permissions | -rw-r--r-- |
5261 | 1 |
(* Title: HOL/Lambda/ListApplication.thy |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 1998 TU Muenchen |
|
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
5 |
*) |
5261 | 6 |
|
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
7 |
header {* Application of a term to a list of terms *} |
5261 | 8 |
|
16417 | 9 |
theory ListApplication imports Lambda begin |
9771 | 10 |
|
11 |
syntax |
|
12011 | 12 |
"_list_application" :: "dB => dB list => dB" (infixl "\<degree>\<degree>" 150) |
13 |
translations |
|
14 |
"t \<degree>\<degree> ts" == "foldl (op \<degree>) t ts" |
|
11943 | 15 |
|
12011 | 16 |
lemma apps_eq_tail_conv [iff]: "(r \<degree>\<degree> ts = s \<degree>\<degree> ts) = (r = s)" |
18241 | 17 |
by (induct ts rule: rev_induct) auto |
9771 | 18 |
|
18241 | 19 |
lemma Var_eq_apps_conv [iff]: "(Var m = s \<degree>\<degree> ss) = (Var m = s \<and> ss = [])" |
20 |
by (induct ss fixing: s) auto |
|
9771 | 21 |
|
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
22 |
lemma Var_apps_eq_Var_apps_conv [iff]: |
18241 | 23 |
"(Var m \<degree>\<degree> rs = Var n \<degree>\<degree> ss) = (m = n \<and> rs = ss)" |
24 |
apply (induct rs fixing: ss rule: rev_induct) |
|
9771 | 25 |
apply simp |
26 |
apply blast |
|
27 |
apply (induct_tac ss rule: rev_induct) |
|
28 |
apply auto |
|
29 |
done |
|
30 |
||
31 |
lemma App_eq_foldl_conv: |
|
12011 | 32 |
"(r \<degree> s = t \<degree>\<degree> ts) = |
33 |
(if ts = [] then r \<degree> s = t |
|
34 |
else (\<exists>ss. ts = ss @ [s] \<and> r = t \<degree>\<degree> ss))" |
|
9771 | 35 |
apply (rule_tac xs = ts in rev_exhaust) |
36 |
apply auto |
|
37 |
done |
|
38 |
||
39 |
lemma Abs_eq_apps_conv [iff]: |
|
12011 | 40 |
"(Abs r = s \<degree>\<degree> ss) = (Abs r = s \<and> ss = [])" |
18241 | 41 |
by (induct ss rule: rev_induct) auto |
9771 | 42 |
|
12011 | 43 |
lemma apps_eq_Abs_conv [iff]: "(s \<degree>\<degree> ss = Abs r) = (s = Abs r \<and> ss = [])" |
18241 | 44 |
by (induct ss rule: rev_induct) auto |
9771 | 45 |
|
46 |
lemma Abs_apps_eq_Abs_apps_conv [iff]: |
|
18241 | 47 |
"(Abs r \<degree>\<degree> rs = Abs s \<degree>\<degree> ss) = (r = s \<and> rs = ss)" |
48 |
apply (induct rs fixing: ss rule: rev_induct) |
|
9771 | 49 |
apply simp |
50 |
apply blast |
|
51 |
apply (induct_tac ss rule: rev_induct) |
|
52 |
apply auto |
|
53 |
done |
|
54 |
||
55 |
lemma Abs_App_neq_Var_apps [iff]: |
|
18257 | 56 |
"Abs s \<degree> t \<noteq> Var n \<degree>\<degree> ss" |
18241 | 57 |
by (induct ss fixing: s t rule: rev_induct) auto |
9771 | 58 |
|
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
59 |
lemma Var_apps_neq_Abs_apps [iff]: |
18257 | 60 |
"Var n \<degree>\<degree> ts \<noteq> Abs r \<degree>\<degree> ss" |
18241 | 61 |
apply (induct ss fixing: ts rule: rev_induct) |
9771 | 62 |
apply simp |
63 |
apply (induct_tac ts rule: rev_induct) |
|
64 |
apply auto |
|
65 |
done |
|
5261 | 66 |
|
9771 | 67 |
lemma ex_head_tail: |
12011 | 68 |
"\<exists>ts h. t = h \<degree>\<degree> ts \<and> ((\<exists>n. h = Var n) \<or> (\<exists>u. h = Abs u))" |
18241 | 69 |
apply (induct t) |
9771 | 70 |
apply (rule_tac x = "[]" in exI) |
71 |
apply simp |
|
72 |
apply clarify |
|
73 |
apply (rename_tac ts1 ts2 h1 h2) |
|
12011 | 74 |
apply (rule_tac x = "ts1 @ [h2 \<degree>\<degree> ts2]" in exI) |
9771 | 75 |
apply simp |
76 |
apply simp |
|
77 |
done |
|
78 |
||
79 |
lemma size_apps [simp]: |
|
12011 | 80 |
"size (r \<degree>\<degree> rs) = size r + foldl (op +) 0 (map size rs) + length rs" |
18241 | 81 |
by (induct rs rule: rev_induct) auto |
9771 | 82 |
|
83 |
lemma lem0: "[| (0::nat) < k; m <= n |] ==> m < n + k" |
|
18241 | 84 |
by simp |
9771 | 85 |
|
14066 | 86 |
lemma lift_map [simp]: |
18241 | 87 |
"lift (t \<degree>\<degree> ts) i = lift t i \<degree>\<degree> map (\<lambda>t. lift t i) ts" |
88 |
by (induct ts fixing: t) simp_all |
|
14066 | 89 |
|
90 |
lemma subst_map [simp]: |
|
18241 | 91 |
"subst (t \<degree>\<degree> ts) u i = subst t u i \<degree>\<degree> map (\<lambda>t. subst t u i) ts" |
92 |
by (induct ts fixing: t) simp_all |
|
14066 | 93 |
|
94 |
lemma app_last: "(t \<degree>\<degree> ts) \<degree> u = t \<degree>\<degree> (ts @ [u])" |
|
95 |
by simp |
|
96 |
||
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
97 |
|
12011 | 98 |
text {* \medskip A customized induction schema for @{text "\<degree>\<degree>"}. *} |
9771 | 99 |
|
18241 | 100 |
lemma lem: |
101 |
assumes "!!n ts. \<forall>t \<in> set ts. P t ==> P (Var n \<degree>\<degree> ts)" |
|
102 |
and "!!u ts. [| P u; \<forall>t \<in> set ts. P t |] ==> P (Abs u \<degree>\<degree> ts)" |
|
103 |
shows "size t = n \<Longrightarrow> P t" |
|
104 |
apply (induct n fixing: t rule: nat_less_induct) |
|
105 |
apply (cut_tac t = t in ex_head_tail) |
|
106 |
apply clarify |
|
107 |
apply (erule disjE) |
|
108 |
apply clarify |
|
109 |
apply (rule prems) |
|
9771 | 110 |
apply clarify |
18241 | 111 |
apply (erule allE, erule impE) |
112 |
prefer 2 |
|
113 |
apply (erule allE, erule mp, rule refl) |
|
114 |
apply simp |
|
115 |
apply (rule lem0) |
|
9771 | 116 |
apply force |
18241 | 117 |
apply (rule elem_le_sum) |
118 |
apply force |
|
119 |
apply clarify |
|
120 |
apply (rule prems) |
|
121 |
apply (erule allE, erule impE) |
|
122 |
prefer 2 |
|
123 |
apply (erule allE, erule mp, rule refl) |
|
124 |
apply simp |
|
125 |
apply clarify |
|
126 |
apply (erule allE, erule impE) |
|
127 |
prefer 2 |
|
128 |
apply (erule allE, erule mp, rule refl) |
|
129 |
apply simp |
|
130 |
apply (rule le_imp_less_Suc) |
|
131 |
apply (rule trans_le_add1) |
|
132 |
apply (rule trans_le_add2) |
|
133 |
apply (rule elem_le_sum) |
|
134 |
apply force |
|
135 |
done |
|
9771 | 136 |
|
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
137 |
theorem Apps_dB_induct: |
18241 | 138 |
assumes "!!n ts. \<forall>t \<in> set ts. P t ==> P (Var n \<degree>\<degree> ts)" |
139 |
and "!!u ts. [| P u; \<forall>t \<in> set ts. P t |] ==> P (Abs u \<degree>\<degree> ts)" |
|
140 |
shows "P t" |
|
141 |
apply (rule_tac t = t in lem) |
|
142 |
prefer 3 |
|
143 |
apply (rule refl) |
|
144 |
apply (assumption | rule prems)+ |
|
145 |
done |
|
5261 | 146 |
|
9870 | 147 |
end |