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