author | kleing |
Sat, 30 Apr 2005 14:18:36 +0200 | |
changeset 15900 | d6156cb8dc2e |
parent 14066 | fe45b97b62ea |
child 16417 | 9bc16273c2d4 |
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 |
|
9771 | 9 |
theory ListApplication = Lambda: |
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)" |
9771 | 17 |
apply (induct_tac ts rule: rev_induct) |
18 |
apply auto |
|
19 |
done |
|
20 |
||
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
21 |
lemma Var_eq_apps_conv [iff]: |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
22 |
"\<And>s. (Var m = s \<degree>\<degree> ss) = (Var m = s \<and> ss = [])" |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
23 |
apply (induct ss) |
9771 | 24 |
apply auto |
25 |
done |
|
26 |
||
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
27 |
lemma Var_apps_eq_Var_apps_conv [iff]: |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
28 |
"\<And>ss. (Var m \<degree>\<degree> rs = Var n \<degree>\<degree> ss) = (m = n \<and> rs = ss)" |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
29 |
apply (induct rs rule: rev_induct) |
9771 | 30 |
apply simp |
31 |
apply blast |
|
32 |
apply (induct_tac ss rule: rev_induct) |
|
33 |
apply auto |
|
34 |
done |
|
35 |
||
36 |
lemma App_eq_foldl_conv: |
|
12011 | 37 |
"(r \<degree> s = t \<degree>\<degree> ts) = |
38 |
(if ts = [] then r \<degree> s = t |
|
39 |
else (\<exists>ss. ts = ss @ [s] \<and> r = t \<degree>\<degree> ss))" |
|
9771 | 40 |
apply (rule_tac xs = ts in rev_exhaust) |
41 |
apply auto |
|
42 |
done |
|
43 |
||
44 |
lemma Abs_eq_apps_conv [iff]: |
|
12011 | 45 |
"(Abs r = s \<degree>\<degree> ss) = (Abs r = s \<and> ss = [])" |
9771 | 46 |
apply (induct_tac ss rule: rev_induct) |
47 |
apply auto |
|
48 |
done |
|
49 |
||
12011 | 50 |
lemma apps_eq_Abs_conv [iff]: "(s \<degree>\<degree> ss = Abs r) = (s = Abs r \<and> ss = [])" |
9771 | 51 |
apply (induct_tac ss rule: rev_induct) |
52 |
apply auto |
|
53 |
done |
|
54 |
||
55 |
lemma Abs_apps_eq_Abs_apps_conv [iff]: |
|
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
56 |
"\<And>ss. (Abs r \<degree>\<degree> rs = Abs s \<degree>\<degree> ss) = (r = s \<and> rs = ss)" |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
57 |
apply (induct rs rule: rev_induct) |
9771 | 58 |
apply simp |
59 |
apply blast |
|
60 |
apply (induct_tac ss rule: rev_induct) |
|
61 |
apply auto |
|
62 |
done |
|
63 |
||
64 |
lemma Abs_App_neq_Var_apps [iff]: |
|
12011 | 65 |
"\<forall>s t. Abs s \<degree> t ~= Var n \<degree>\<degree> ss" |
9771 | 66 |
apply (induct_tac ss rule: rev_induct) |
67 |
apply auto |
|
68 |
done |
|
69 |
||
13915
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
70 |
lemma Var_apps_neq_Abs_apps [iff]: |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
71 |
"\<And>ts. Var n \<degree>\<degree> ts ~= Abs r \<degree>\<degree> ss" |
28ccb51bd2f3
Eliminated most occurrences of rule_format attribute.
berghofe
parents:
12011
diff
changeset
|
72 |
apply (induct ss rule: rev_induct) |
9771 | 73 |
apply simp |
74 |
apply (induct_tac ts rule: rev_induct) |
|
75 |
apply auto |
|
76 |
done |
|
5261 | 77 |
|
9771 | 78 |
lemma ex_head_tail: |
12011 | 79 |
"\<exists>ts h. t = h \<degree>\<degree> ts \<and> ((\<exists>n. h = Var n) \<or> (\<exists>u. h = Abs u))" |
9771 | 80 |
apply (induct_tac t) |
81 |
apply (rule_tac x = "[]" in exI) |
|
82 |
apply simp |
|
83 |
apply clarify |
|
84 |
apply (rename_tac ts1 ts2 h1 h2) |
|
12011 | 85 |
apply (rule_tac x = "ts1 @ [h2 \<degree>\<degree> ts2]" in exI) |
9771 | 86 |
apply simp |
87 |
apply simp |
|
88 |
done |
|
89 |
||
90 |
lemma size_apps [simp]: |
|
12011 | 91 |
"size (r \<degree>\<degree> rs) = size r + foldl (op +) 0 (map size rs) + length rs" |
9771 | 92 |
apply (induct_tac rs rule: rev_induct) |
93 |
apply auto |
|
94 |
done |
|
95 |
||
96 |
lemma lem0: "[| (0::nat) < k; m <= n |] ==> m < n + k" |
|
97 |
apply simp |
|
98 |
done |
|
99 |
||
14066 | 100 |
lemma lift_map [simp]: |
101 |
"\<And>t. lift (t \<degree>\<degree> ts) i = lift t i \<degree>\<degree> map (\<lambda>t. lift t i) ts" |
|
102 |
by (induct ts) simp_all |
|
103 |
||
104 |
lemma subst_map [simp]: |
|
105 |
"\<And>t. subst (t \<degree>\<degree> ts) u i = subst t u i \<degree>\<degree> map (\<lambda>t. subst t u i) ts" |
|
106 |
by (induct ts) simp_all |
|
107 |
||
108 |
lemma app_last: "(t \<degree>\<degree> ts) \<degree> u = t \<degree>\<degree> (ts @ [u])" |
|
109 |
by simp |
|
110 |
||
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
111 |
|
12011 | 112 |
text {* \medskip A customized induction schema for @{text "\<degree>\<degree>"}. *} |
9771 | 113 |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9906
diff
changeset
|
114 |
lemma lem [rule_format (no_asm)]: |
12011 | 115 |
"[| !!n ts. \<forall>t \<in> set ts. P t ==> P (Var n \<degree>\<degree> ts); |
116 |
!!u ts. [| P u; \<forall>t \<in> set ts. P t |] ==> P (Abs u \<degree>\<degree> ts) |
|
9771 | 117 |
|] ==> \<forall>t. size t = n --> P t" |
118 |
proof - |
|
11549 | 119 |
case rule_context |
9771 | 120 |
show ?thesis |
9870 | 121 |
apply (induct_tac n rule: nat_less_induct) |
9771 | 122 |
apply (rule allI) |
123 |
apply (cut_tac t = t in ex_head_tail) |
|
124 |
apply clarify |
|
125 |
apply (erule disjE) |
|
126 |
apply clarify |
|
127 |
apply (rule prems) |
|
128 |
apply clarify |
|
129 |
apply (erule allE, erule impE) |
|
130 |
prefer 2 |
|
131 |
apply (erule allE, erule mp, rule refl) |
|
132 |
apply simp |
|
133 |
apply (rule lem0) |
|
134 |
apply force |
|
135 |
apply (rule elem_le_sum) |
|
136 |
apply force |
|
137 |
apply clarify |
|
138 |
apply (rule prems) |
|
139 |
apply (erule allE, erule impE) |
|
140 |
prefer 2 |
|
141 |
apply (erule allE, erule mp, rule refl) |
|
142 |
apply simp |
|
143 |
apply clarify |
|
144 |
apply (erule allE, erule impE) |
|
145 |
prefer 2 |
|
146 |
apply (erule allE, erule mp, rule refl) |
|
147 |
apply simp |
|
148 |
apply (rule le_imp_less_Suc) |
|
149 |
apply (rule trans_le_add1) |
|
150 |
apply (rule trans_le_add2) |
|
151 |
apply (rule elem_le_sum) |
|
152 |
apply force |
|
153 |
done |
|
154 |
qed |
|
155 |
||
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
156 |
theorem Apps_dB_induct: |
12011 | 157 |
"[| !!n ts. \<forall>t \<in> set ts. P t ==> P (Var n \<degree>\<degree> ts); |
158 |
!!u ts. [| P u; \<forall>t \<in> set ts. P t |] ==> P (Abs u \<degree>\<degree> ts) |
|
9771 | 159 |
|] ==> P t" |
160 |
proof - |
|
11549 | 161 |
case rule_context |
9771 | 162 |
show ?thesis |
163 |
apply (rule_tac t = t in lem) |
|
164 |
prefer 3 |
|
165 |
apply (rule refl) |
|
166 |
apply (assumption | rule prems)+ |
|
167 |
done |
|
168 |
qed |
|
5261 | 169 |
|
9870 | 170 |
end |