author | huffman |
Sun, 01 Apr 2012 09:12:03 +0200 | |
changeset 47244 | a7f85074c169 |
parent 46950 | d0181abdbdac |
permissions | -rw-r--r-- |
46801 | 1 |
(* Title: HOL/Import/Importer.thy |
2 |
Author: Sebastian Skalberg, TU Muenchen |
|
3 |
*) |
|
4 |
||
5 |
theory Importer |
|
6 |
imports Main |
|
46950
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents:
46947
diff
changeset
|
7 |
keywords |
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents:
46947
diff
changeset
|
8 |
"import_segment" "import_theory" "end_import" "setup_theory" "end_setup" |
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents:
46947
diff
changeset
|
9 |
"setup_dump" "append_dump" "flush_dump" "ignore_thms" "type_maps" |
d0181abdbdac
declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents:
46947
diff
changeset
|
10 |
"def_maps" "thm_maps" "const_renames" "const_moves" "const_maps" :: thy_decl and ">" |
46805 | 11 |
uses "shuffler.ML" "import_rews.ML" ("proof_kernel.ML") ("replay.ML") ("import.ML") |
46801 | 12 |
begin |
13 |
||
46805 | 14 |
setup {* Shuffler.setup #> importer_setup *} |
15 |
||
16 |
parse_ast_translation smarter_trueprop_parsing |
|
46801 | 17 |
|
18 |
lemma conj_norm [shuffle_rule]: "(A & B ==> PROP C) == ([| A ; B |] ==> PROP C)" |
|
19 |
proof |
|
20 |
assume "A & B ==> PROP C" A B |
|
21 |
thus "PROP C" |
|
22 |
by auto |
|
23 |
next |
|
24 |
assume "[| A; B |] ==> PROP C" "A & B" |
|
25 |
thus "PROP C" |
|
26 |
by auto |
|
27 |
qed |
|
28 |
||
29 |
lemma imp_norm [shuffle_rule]: "(Trueprop (A --> B)) == (A ==> B)" |
|
30 |
proof |
|
31 |
assume "A --> B" A |
|
32 |
thus B .. |
|
33 |
next |
|
34 |
assume "A ==> B" |
|
35 |
thus "A --> B" |
|
36 |
by auto |
|
37 |
qed |
|
38 |
||
39 |
lemma all_norm [shuffle_rule]: "(Trueprop (ALL x. P x)) == (!!x. P x)" |
|
40 |
proof |
|
41 |
fix x |
|
42 |
assume "ALL x. P x" |
|
43 |
thus "P x" .. |
|
44 |
next |
|
45 |
assume "!!x. P x" |
|
46 |
thus "ALL x. P x" |
|
47 |
.. |
|
48 |
qed |
|
49 |
||
50 |
lemma ex_norm [shuffle_rule]: "(EX x. P x ==> PROP Q) == (!!x. P x ==> PROP Q)" |
|
51 |
proof |
|
52 |
fix x |
|
53 |
assume ex: "EX x. P x ==> PROP Q" |
|
54 |
assume "P x" |
|
55 |
hence "EX x. P x" .. |
|
56 |
with ex show "PROP Q" . |
|
57 |
next |
|
58 |
assume allx: "!!x. P x ==> PROP Q" |
|
59 |
assume "EX x. P x" |
|
60 |
hence p: "P (SOME x. P x)" |
|
61 |
.. |
|
62 |
from allx |
|
63 |
have "P (SOME x. P x) ==> PROP Q" |
|
64 |
. |
|
65 |
with p |
|
66 |
show "PROP Q" |
|
67 |
by auto |
|
68 |
qed |
|
69 |
||
70 |
lemma eq_norm [shuffle_rule]: "Trueprop (t = u) == (t == u)" |
|
71 |
proof |
|
72 |
assume "t = u" |
|
73 |
thus "t == u" by simp |
|
74 |
next |
|
75 |
assume "t == u" |
|
76 |
thus "t = u" |
|
77 |
by simp |
|
78 |
qed |
|
79 |
||
80 |
section {* General Setup *} |
|
81 |
||
82 |
lemma eq_imp: "P = Q \<Longrightarrow> P \<longrightarrow> Q" |
|
83 |
by auto |
|
84 |
||
85 |
lemma HOLallI: "(!! bogus. P bogus) \<Longrightarrow> (ALL bogus. P bogus)" |
|
86 |
proof - |
|
87 |
assume "!! bogus. P bogus" |
|
88 |
thus "ALL x. P x" |
|
89 |
.. |
|
90 |
qed |
|
91 |
||
92 |
consts |
|
93 |
ONE_ONE :: "('a => 'b) => bool" |
|
94 |
||
95 |
defs |
|
96 |
ONE_ONE_DEF: "ONE_ONE f == ALL x y. f x = f y --> x = y" |
|
97 |
||
98 |
lemma ONE_ONE_rew: "ONE_ONE f = inj_on f UNIV" |
|
99 |
by (simp add: ONE_ONE_DEF inj_on_def) |
|
100 |
||
101 |
lemma INFINITY_AX: "EX (f::ind \<Rightarrow> ind). (inj f & ~(surj f))" |
|
102 |
proof (rule exI,safe) |
|
103 |
show "inj Suc_Rep" |
|
104 |
by (rule injI) (rule Suc_Rep_inject) |
|
105 |
next |
|
106 |
assume "surj Suc_Rep" |
|
107 |
hence "ALL y. EX x. y = Suc_Rep x" |
|
108 |
by (simp add: surj_def) |
|
109 |
hence "EX x. Zero_Rep = Suc_Rep x" |
|
110 |
by (rule spec) |
|
111 |
thus False |
|
112 |
proof (rule exE) |
|
113 |
fix x |
|
114 |
assume "Zero_Rep = Suc_Rep x" |
|
115 |
hence "Suc_Rep x = Zero_Rep" |
|
116 |
.. |
|
117 |
with Suc_Rep_not_Zero_Rep |
|
118 |
show False |
|
119 |
.. |
|
120 |
qed |
|
121 |
qed |
|
122 |
||
123 |
lemma EXISTS_DEF: "Ex P = P (Eps P)" |
|
124 |
proof (rule iffI) |
|
125 |
assume "Ex P" |
|
126 |
thus "P (Eps P)" |
|
127 |
.. |
|
128 |
next |
|
129 |
assume "P (Eps P)" |
|
130 |
thus "Ex P" |
|
131 |
.. |
|
132 |
qed |
|
133 |
||
134 |
consts |
|
135 |
TYPE_DEFINITION :: "('a => bool) => ('b => 'a) => bool" |
|
136 |
||
137 |
defs |
|
138 |
TYPE_DEFINITION: "TYPE_DEFINITION p rep == ((ALL x y. (rep x = rep y) --> (x = y)) & (ALL x. (p x = (EX y. x = rep y))))" |
|
139 |
||
140 |
lemma ex_imp_nonempty: "Ex P ==> EX x. x : (Collect P)" |
|
141 |
by simp |
|
142 |
||
143 |
lemma light_ex_imp_nonempty: "P t ==> EX x. x : (Collect P)" |
|
144 |
proof - |
|
145 |
assume "P t" |
|
146 |
hence "EX x. P x" |
|
147 |
.. |
|
148 |
thus ?thesis |
|
149 |
by (rule ex_imp_nonempty) |
|
150 |
qed |
|
151 |
||
152 |
lemma light_imp_as: "[| Q --> P; P --> Q |] ==> P = Q" |
|
153 |
by blast |
|
154 |
||
155 |
lemma typedef_hol2hol4: |
|
156 |
assumes a: "type_definition (Rep::'a=>'b) Abs (Collect P)" |
|
157 |
shows "EX rep. TYPE_DEFINITION P (rep::'a=>'b)" |
|
158 |
proof - |
|
159 |
from a |
|
160 |
have td: "(ALL x. P (Rep x)) & (ALL x. Abs (Rep x) = x) & (ALL y. P y \<longrightarrow> Rep (Abs y) = y)" |
|
161 |
by (simp add: type_definition_def) |
|
162 |
have ed: "TYPE_DEFINITION P Rep" |
|
163 |
proof (auto simp add: TYPE_DEFINITION) |
|
164 |
fix x y |
|
165 |
assume b: "Rep x = Rep y" |
|
166 |
from td have "x = Abs (Rep x)" |
|
167 |
by auto |
|
168 |
also have "Abs (Rep x) = Abs (Rep y)" |
|
169 |
by (simp add: b) |
|
170 |
also from td have "Abs (Rep y) = y" |
|
171 |
by auto |
|
172 |
finally show "x = y" . |
|
173 |
next |
|
174 |
fix x |
|
175 |
assume "P x" |
|
176 |
with td |
|
177 |
have "Rep (Abs x) = x" |
|
178 |
by auto |
|
179 |
hence "x = Rep (Abs x)" |
|
180 |
.. |
|
181 |
thus "EX y. x = Rep y" |
|
182 |
.. |
|
183 |
next |
|
184 |
fix y |
|
185 |
from td |
|
186 |
show "P (Rep y)" |
|
187 |
by auto |
|
188 |
qed |
|
189 |
show ?thesis |
|
190 |
apply (rule exI [of _ Rep]) |
|
191 |
apply (rule ed) |
|
192 |
. |
|
193 |
qed |
|
194 |
||
195 |
lemma typedef_hol2hollight: |
|
196 |
assumes a: "type_definition (Rep::'a=>'b) Abs (Collect P)" |
|
197 |
shows "(Abs (Rep a) = a) & (P r = (Rep (Abs r) = r))" |
|
198 |
proof |
|
199 |
from a |
|
200 |
show "Abs (Rep a) = a" |
|
201 |
by (rule type_definition.Rep_inverse) |
|
202 |
next |
|
203 |
show "P r = (Rep (Abs r) = r)" |
|
204 |
proof |
|
205 |
assume "P r" |
|
206 |
hence "r \<in> (Collect P)" |
|
207 |
by simp |
|
208 |
with a |
|
209 |
show "Rep (Abs r) = r" |
|
210 |
by (rule type_definition.Abs_inverse) |
|
211 |
next |
|
212 |
assume ra: "Rep (Abs r) = r" |
|
213 |
from a |
|
214 |
have "Rep (Abs r) \<in> (Collect P)" |
|
215 |
by (rule type_definition.Rep) |
|
216 |
thus "P r" |
|
217 |
by (simp add: ra) |
|
218 |
qed |
|
219 |
qed |
|
220 |
||
221 |
lemma termspec_help: "[| Ex P ; c == Eps P |] ==> P c" |
|
222 |
apply simp |
|
223 |
apply (rule someI_ex) |
|
224 |
. |
|
225 |
||
226 |
lemma typedef_helper: "EX x. P x \<Longrightarrow> EX x. x \<in> (Collect P)" |
|
227 |
by simp |
|
228 |
||
229 |
use "proof_kernel.ML" |
|
230 |
use "replay.ML" |
|
231 |
use "import.ML" |
|
232 |
||
233 |
setup Import.setup |
|
234 |
||
235 |
end |
|
236 |