berghofe@13403
|
1 |
(* Title: HOL/Extraction.thy
|
berghofe@13403
|
2 |
Author: Stefan Berghofer, TU Muenchen
|
berghofe@13403
|
3 |
*)
|
berghofe@13403
|
4 |
|
berghofe@13403
|
5 |
header {* Program extraction for HOL *}
|
berghofe@13403
|
6 |
|
nipkow@15131
|
7 |
theory Extraction
|
blanchet@58112
|
8 |
imports Option
|
nipkow@15131
|
9 |
begin
|
berghofe@13403
|
10 |
|
wenzelm@48891
|
11 |
ML_file "Tools/rewrite_hol_proof.ML"
|
wenzelm@48891
|
12 |
|
berghofe@13403
|
13 |
subsection {* Setup *}
|
berghofe@13403
|
14 |
|
wenzelm@16121
|
15 |
setup {*
|
wenzelm@18708
|
16 |
Extraction.add_types
|
berghofe@29930
|
17 |
[("bool", ([], NONE))] #>
|
wenzelm@18708
|
18 |
Extraction.set_preprocessor (fn thy =>
|
berghofe@13403
|
19 |
Proofterm.rewrite_proof_notypes
|
wenzelm@28797
|
20 |
([], RewriteHOLProof.elim_cong :: ProofRewriteRules.rprocs true) o
|
wenzelm@17203
|
21 |
Proofterm.rewrite_proof thy
|
berghofe@37233
|
22 |
(RewriteHOLProof.rews,
|
berghofe@37233
|
23 |
ProofRewriteRules.rprocs true @ [ProofRewriteRules.expand_of_class thy]) o
|
haftmann@27982
|
24 |
ProofRewriteRules.elim_vars (curry Const @{const_name default}))
|
berghofe@13403
|
25 |
*}
|
berghofe@13403
|
26 |
|
berghofe@13403
|
27 |
lemmas [extraction_expand] =
|
berghofe@22281
|
28 |
meta_spec atomize_eq atomize_all atomize_imp atomize_conj
|
berghofe@13403
|
29 |
allE rev_mp conjE Eq_TrueI Eq_FalseI eqTrueI eqTrueE eq_cong2
|
haftmann@20941
|
30 |
notE' impE' impE iffE imp_cong simp_thms eq_True eq_False
|
wenzelm@18456
|
31 |
induct_forall_eq induct_implies_eq induct_equal_eq induct_conj_eq
|
berghofe@34913
|
32 |
induct_atomize induct_atomize' induct_rulify induct_rulify'
|
berghofe@34913
|
33 |
induct_rulify_fallback induct_trueI
|
berghofe@25424
|
34 |
True_implies_equals TrueE
|
berghofe@13403
|
35 |
|
wenzelm@33704
|
36 |
lemmas [extraction_expand_def] =
|
wenzelm@33704
|
37 |
induct_forall_def induct_implies_def induct_equal_def induct_conj_def
|
berghofe@34913
|
38 |
induct_true_def induct_false_def
|
wenzelm@33704
|
39 |
|
blanchet@58343
|
40 |
datatype (plugins only: code) sumbool = Left | Right
|
berghofe@13403
|
41 |
|
berghofe@13403
|
42 |
subsection {* Type of extracted program *}
|
berghofe@13403
|
43 |
|
berghofe@13403
|
44 |
extract_type
|
berghofe@13403
|
45 |
"typeof (Trueprop P) \<equiv> typeof P"
|
berghofe@13403
|
46 |
|
berghofe@13403
|
47 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
48 |
typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE('Q))"
|
berghofe@13403
|
49 |
|
berghofe@13403
|
50 |
"typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE(Null))"
|
berghofe@13403
|
51 |
|
berghofe@13403
|
52 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
53 |
typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE('P \<Rightarrow> 'Q))"
|
berghofe@13403
|
54 |
|
berghofe@13403
|
55 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
56 |
typeof (\<forall>x. P x) \<equiv> Type (TYPE(Null))"
|
berghofe@13403
|
57 |
|
berghofe@13403
|
58 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE('P))) \<Longrightarrow>
|
berghofe@13403
|
59 |
typeof (\<forall>x::'a. P x) \<equiv> Type (TYPE('a \<Rightarrow> 'P))"
|
berghofe@13403
|
60 |
|
berghofe@13403
|
61 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
62 |
typeof (\<exists>x::'a. P x) \<equiv> Type (TYPE('a))"
|
berghofe@13403
|
63 |
|
berghofe@13403
|
64 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE('P))) \<Longrightarrow>
|
berghofe@13403
|
65 |
typeof (\<exists>x::'a. P x) \<equiv> Type (TYPE('a \<times> 'P))"
|
berghofe@13403
|
66 |
|
berghofe@13403
|
67 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
68 |
typeof (P \<or> Q) \<equiv> Type (TYPE(sumbool))"
|
berghofe@13403
|
69 |
|
berghofe@13403
|
70 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
71 |
typeof (P \<or> Q) \<equiv> Type (TYPE('Q option))"
|
berghofe@13403
|
72 |
|
berghofe@13403
|
73 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
74 |
typeof (P \<or> Q) \<equiv> Type (TYPE('P option))"
|
berghofe@13403
|
75 |
|
berghofe@13403
|
76 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
77 |
typeof (P \<or> Q) \<equiv> Type (TYPE('P + 'Q))"
|
berghofe@13403
|
78 |
|
berghofe@13403
|
79 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
80 |
typeof (P \<and> Q) \<equiv> Type (TYPE('Q))"
|
berghofe@13403
|
81 |
|
berghofe@13403
|
82 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
83 |
typeof (P \<and> Q) \<equiv> Type (TYPE('P))"
|
berghofe@13403
|
84 |
|
berghofe@13403
|
85 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow>
|
berghofe@13403
|
86 |
typeof (P \<and> Q) \<equiv> Type (TYPE('P \<times> 'Q))"
|
berghofe@13403
|
87 |
|
berghofe@13403
|
88 |
"typeof (P = Q) \<equiv> typeof ((P \<longrightarrow> Q) \<and> (Q \<longrightarrow> P))"
|
berghofe@13403
|
89 |
|
berghofe@13403
|
90 |
"typeof (x \<in> P) \<equiv> typeof P"
|
berghofe@13403
|
91 |
|
berghofe@13403
|
92 |
subsection {* Realizability *}
|
berghofe@13403
|
93 |
|
berghofe@13403
|
94 |
realizability
|
berghofe@13403
|
95 |
"(realizes t (Trueprop P)) \<equiv> (Trueprop (realizes t P))"
|
berghofe@13403
|
96 |
|
berghofe@13403
|
97 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
98 |
(realizes t (P \<longrightarrow> Q)) \<equiv> (realizes Null P \<longrightarrow> realizes t Q)"
|
berghofe@13403
|
99 |
|
berghofe@13403
|
100 |
"(typeof P) \<equiv> (Type (TYPE('P))) \<Longrightarrow>
|
berghofe@13403
|
101 |
(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
102 |
(realizes t (P \<longrightarrow> Q)) \<equiv> (\<forall>x::'P. realizes x P \<longrightarrow> realizes Null Q)"
|
berghofe@13403
|
103 |
|
berghofe@13403
|
104 |
"(realizes t (P \<longrightarrow> Q)) \<equiv> (\<forall>x. realizes x P \<longrightarrow> realizes (t x) Q)"
|
berghofe@13403
|
105 |
|
berghofe@13403
|
106 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
107 |
(realizes t (\<forall>x. P x)) \<equiv> (\<forall>x. realizes Null (P x))"
|
berghofe@13403
|
108 |
|
berghofe@13403
|
109 |
"(realizes t (\<forall>x. P x)) \<equiv> (\<forall>x. realizes (t x) (P x))"
|
berghofe@13403
|
110 |
|
berghofe@13403
|
111 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
112 |
(realizes t (\<exists>x. P x)) \<equiv> (realizes Null (P t))"
|
berghofe@13403
|
113 |
|
berghofe@13403
|
114 |
"(realizes t (\<exists>x. P x)) \<equiv> (realizes (snd t) (P (fst t)))"
|
berghofe@13403
|
115 |
|
berghofe@13403
|
116 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
117 |
(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
118 |
(realizes t (P \<or> Q)) \<equiv>
|
berghofe@13403
|
119 |
(case t of Left \<Rightarrow> realizes Null P | Right \<Rightarrow> realizes Null Q)"
|
berghofe@13403
|
120 |
|
berghofe@13403
|
121 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
122 |
(realizes t (P \<or> Q)) \<equiv>
|
berghofe@13403
|
123 |
(case t of None \<Rightarrow> realizes Null P | Some q \<Rightarrow> realizes q Q)"
|
berghofe@13403
|
124 |
|
berghofe@13403
|
125 |
"(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
126 |
(realizes t (P \<or> Q)) \<equiv>
|
berghofe@13403
|
127 |
(case t of None \<Rightarrow> realizes Null Q | Some p \<Rightarrow> realizes p P)"
|
berghofe@13403
|
128 |
|
berghofe@13403
|
129 |
"(realizes t (P \<or> Q)) \<equiv>
|
berghofe@13403
|
130 |
(case t of Inl p \<Rightarrow> realizes p P | Inr q \<Rightarrow> realizes q Q)"
|
berghofe@13403
|
131 |
|
berghofe@13403
|
132 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
133 |
(realizes t (P \<and> Q)) \<equiv> (realizes Null P \<and> realizes t Q)"
|
berghofe@13403
|
134 |
|
berghofe@13403
|
135 |
"(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>
|
berghofe@13403
|
136 |
(realizes t (P \<and> Q)) \<equiv> (realizes t P \<and> realizes Null Q)"
|
berghofe@13403
|
137 |
|
berghofe@13403
|
138 |
"(realizes t (P \<and> Q)) \<equiv> (realizes (fst t) P \<and> realizes (snd t) Q)"
|
berghofe@13403
|
139 |
|
berghofe@13403
|
140 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
141 |
realizes t (\<not> P) \<equiv> \<not> realizes Null P"
|
berghofe@13403
|
142 |
|
berghofe@13403
|
143 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow>
|
berghofe@13403
|
144 |
realizes t (\<not> P) \<equiv> (\<forall>x::'P. \<not> realizes x P)"
|
berghofe@13403
|
145 |
|
berghofe@13403
|
146 |
"typeof (P::bool) \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
147 |
typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow>
|
berghofe@13403
|
148 |
realizes t (P = Q) \<equiv> realizes Null P = realizes Null Q"
|
berghofe@13403
|
149 |
|
berghofe@13403
|
150 |
"(realizes t (P = Q)) \<equiv> (realizes t ((P \<longrightarrow> Q) \<and> (Q \<longrightarrow> P)))"
|
berghofe@13403
|
151 |
|
berghofe@13403
|
152 |
subsection {* Computational content of basic inference rules *}
|
berghofe@13403
|
153 |
|
berghofe@13403
|
154 |
theorem disjE_realizer:
|
berghofe@13403
|
155 |
assumes r: "case x of Inl p \<Rightarrow> P p | Inr q \<Rightarrow> Q q"
|
berghofe@13403
|
156 |
and r1: "\<And>p. P p \<Longrightarrow> R (f p)" and r2: "\<And>q. Q q \<Longrightarrow> R (g q)"
|
berghofe@13403
|
157 |
shows "R (case x of Inl p \<Rightarrow> f p | Inr q \<Rightarrow> g q)"
|
berghofe@13403
|
158 |
proof (cases x)
|
berghofe@13403
|
159 |
case Inl
|
berghofe@13403
|
160 |
with r show ?thesis by simp (rule r1)
|
berghofe@13403
|
161 |
next
|
berghofe@13403
|
162 |
case Inr
|
berghofe@13403
|
163 |
with r show ?thesis by simp (rule r2)
|
berghofe@13403
|
164 |
qed
|
berghofe@13403
|
165 |
|
berghofe@13403
|
166 |
theorem disjE_realizer2:
|
berghofe@13403
|
167 |
assumes r: "case x of None \<Rightarrow> P | Some q \<Rightarrow> Q q"
|
berghofe@13403
|
168 |
and r1: "P \<Longrightarrow> R f" and r2: "\<And>q. Q q \<Longrightarrow> R (g q)"
|
berghofe@13403
|
169 |
shows "R (case x of None \<Rightarrow> f | Some q \<Rightarrow> g q)"
|
berghofe@13403
|
170 |
proof (cases x)
|
berghofe@13403
|
171 |
case None
|
berghofe@13403
|
172 |
with r show ?thesis by simp (rule r1)
|
berghofe@13403
|
173 |
next
|
berghofe@13403
|
174 |
case Some
|
berghofe@13403
|
175 |
with r show ?thesis by simp (rule r2)
|
berghofe@13403
|
176 |
qed
|
berghofe@13403
|
177 |
|
berghofe@13403
|
178 |
theorem disjE_realizer3:
|
berghofe@13403
|
179 |
assumes r: "case x of Left \<Rightarrow> P | Right \<Rightarrow> Q"
|
berghofe@13403
|
180 |
and r1: "P \<Longrightarrow> R f" and r2: "Q \<Longrightarrow> R g"
|
berghofe@13403
|
181 |
shows "R (case x of Left \<Rightarrow> f | Right \<Rightarrow> g)"
|
berghofe@13403
|
182 |
proof (cases x)
|
berghofe@13403
|
183 |
case Left
|
berghofe@13403
|
184 |
with r show ?thesis by simp (rule r1)
|
berghofe@13403
|
185 |
next
|
berghofe@13403
|
186 |
case Right
|
berghofe@13403
|
187 |
with r show ?thesis by simp (rule r2)
|
berghofe@13403
|
188 |
qed
|
berghofe@13403
|
189 |
|
berghofe@13403
|
190 |
theorem conjI_realizer:
|
berghofe@13403
|
191 |
"P p \<Longrightarrow> Q q \<Longrightarrow> P (fst (p, q)) \<and> Q (snd (p, q))"
|
berghofe@13403
|
192 |
by simp
|
berghofe@13403
|
193 |
|
berghofe@13403
|
194 |
theorem exI_realizer:
|
berghofe@13918
|
195 |
"P y x \<Longrightarrow> P (snd (x, y)) (fst (x, y))" by simp
|
berghofe@13918
|
196 |
|
berghofe@13918
|
197 |
theorem exE_realizer: "P (snd p) (fst p) \<Longrightarrow>
|
berghofe@15393
|
198 |
(\<And>x y. P y x \<Longrightarrow> Q (f x y)) \<Longrightarrow> Q (let (x, y) = p in f x y)"
|
berghofe@15393
|
199 |
by (cases p) (simp add: Let_def)
|
berghofe@13918
|
200 |
|
berghofe@13918
|
201 |
theorem exE_realizer': "P (snd p) (fst p) \<Longrightarrow>
|
berghofe@13918
|
202 |
(\<And>x y. P y x \<Longrightarrow> Q) \<Longrightarrow> Q" by (cases p) simp
|
berghofe@13403
|
203 |
|
berghofe@13403
|
204 |
realizers
|
berghofe@13725
|
205 |
impI (P, Q): "\<lambda>pq. pq"
|
wenzelm@52486
|
206 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq (h: _). allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
|
berghofe@13403
|
207 |
|
berghofe@13403
|
208 |
impI (P): "Null"
|
wenzelm@52486
|
209 |
"\<^bold>\<lambda>(c: _) P Q (h: _). allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
|
berghofe@13403
|
210 |
|
wenzelm@52486
|
211 |
impI (Q): "\<lambda>q. q" "\<^bold>\<lambda>(c: _) P Q q. impI \<cdot> _ \<cdot> _"
|
berghofe@13403
|
212 |
|
berghofe@13725
|
213 |
impI: "Null" "impI"
|
berghofe@13403
|
214 |
|
berghofe@13725
|
215 |
mp (P, Q): "\<lambda>pq. pq"
|
wenzelm@52486
|
216 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> c \<bullet> h)"
|
berghofe@13403
|
217 |
|
berghofe@13403
|
218 |
mp (P): "Null"
|
wenzelm@52486
|
219 |
"\<^bold>\<lambda>(c: _) P Q (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> c \<bullet> h)"
|
berghofe@13403
|
220 |
|
wenzelm@52486
|
221 |
mp (Q): "\<lambda>q. q" "\<^bold>\<lambda>(c: _) P Q q. mp \<cdot> _ \<cdot> _"
|
berghofe@13403
|
222 |
|
berghofe@13725
|
223 |
mp: "Null" "mp"
|
berghofe@13403
|
224 |
|
wenzelm@52486
|
225 |
allI (P): "\<lambda>p. p" "\<^bold>\<lambda>(c: _) P (d: _) p. allI \<cdot> _ \<bullet> d"
|
berghofe@13403
|
226 |
|
berghofe@13725
|
227 |
allI: "Null" "allI"
|
berghofe@13403
|
228 |
|
wenzelm@52486
|
229 |
spec (P): "\<lambda>x p. p x" "\<^bold>\<lambda>(c: _) P x (d: _) p. spec \<cdot> _ \<cdot> x \<bullet> d"
|
berghofe@13403
|
230 |
|
berghofe@13725
|
231 |
spec: "Null" "spec"
|
berghofe@13403
|
232 |
|
wenzelm@52486
|
233 |
exI (P): "\<lambda>x p. (x, p)" "\<^bold>\<lambda>(c: _) P x (d: _) p. exI_realizer \<cdot> P \<cdot> p \<cdot> x \<bullet> c \<bullet> d"
|
berghofe@13403
|
234 |
|
wenzelm@52486
|
235 |
exI: "\<lambda>x. x" "\<^bold>\<lambda>P x (c: _) (h: _). h"
|
berghofe@13403
|
236 |
|
berghofe@15393
|
237 |
exE (P, Q): "\<lambda>p pq. let (x, y) = p in pq x y"
|
wenzelm@52486
|
238 |
"\<^bold>\<lambda>(c: _) (d: _) P Q (e: _) p (h: _) pq. exE_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> pq \<bullet> c \<bullet> e \<bullet> d \<bullet> h"
|
berghofe@13403
|
239 |
|
berghofe@13403
|
240 |
exE (P): "Null"
|
wenzelm@52486
|
241 |
"\<^bold>\<lambda>(c: _) P Q (d: _) p. exE_realizer' \<cdot> _ \<cdot> _ \<cdot> _ \<bullet> c \<bullet> d"
|
berghofe@13403
|
242 |
|
berghofe@13725
|
243 |
exE (Q): "\<lambda>x pq. pq x"
|
wenzelm@52486
|
244 |
"\<^bold>\<lambda>(c: _) P Q (d: _) x (h1: _) pq (h2: _). h2 \<cdot> x \<bullet> h1"
|
berghofe@13403
|
245 |
|
berghofe@13403
|
246 |
exE: "Null"
|
wenzelm@52486
|
247 |
"\<^bold>\<lambda>P Q (c: _) x (h1: _) (h2: _). h2 \<cdot> x \<bullet> h1"
|
berghofe@13403
|
248 |
|
berghofe@13725
|
249 |
conjI (P, Q): "Pair"
|
wenzelm@52486
|
250 |
"\<^bold>\<lambda>(c: _) (d: _) P Q p (h: _) q. conjI_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> q \<bullet> c \<bullet> d \<bullet> h"
|
berghofe@13403
|
251 |
|
berghofe@13725
|
252 |
conjI (P): "\<lambda>p. p"
|
wenzelm@52486
|
253 |
"\<^bold>\<lambda>(c: _) P Q p. conjI \<cdot> _ \<cdot> _"
|
berghofe@13403
|
254 |
|
berghofe@13725
|
255 |
conjI (Q): "\<lambda>q. q"
|
wenzelm@52486
|
256 |
"\<^bold>\<lambda>(c: _) P Q (h: _) q. conjI \<cdot> _ \<cdot> _ \<bullet> h"
|
berghofe@13403
|
257 |
|
berghofe@13725
|
258 |
conjI: "Null" "conjI"
|
berghofe@13403
|
259 |
|
berghofe@13725
|
260 |
conjunct1 (P, Q): "fst"
|
wenzelm@52486
|
261 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq. conjunct1 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
262 |
|
berghofe@13725
|
263 |
conjunct1 (P): "\<lambda>p. p"
|
wenzelm@52486
|
264 |
"\<^bold>\<lambda>(c: _) P Q p. conjunct1 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
265 |
|
berghofe@13403
|
266 |
conjunct1 (Q): "Null"
|
wenzelm@52486
|
267 |
"\<^bold>\<lambda>(c: _) P Q q. conjunct1 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
268 |
|
berghofe@13725
|
269 |
conjunct1: "Null" "conjunct1"
|
berghofe@13403
|
270 |
|
berghofe@13725
|
271 |
conjunct2 (P, Q): "snd"
|
wenzelm@52486
|
272 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq. conjunct2 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
273 |
|
berghofe@13403
|
274 |
conjunct2 (P): "Null"
|
wenzelm@52486
|
275 |
"\<^bold>\<lambda>(c: _) P Q p. conjunct2 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
276 |
|
berghofe@13725
|
277 |
conjunct2 (Q): "\<lambda>p. p"
|
wenzelm@52486
|
278 |
"\<^bold>\<lambda>(c: _) P Q p. conjunct2 \<cdot> _ \<cdot> _"
|
berghofe@13403
|
279 |
|
berghofe@13725
|
280 |
conjunct2: "Null" "conjunct2"
|
berghofe@13725
|
281 |
|
berghofe@13725
|
282 |
disjI1 (P, Q): "Inl"
|
blanchet@55642
|
283 |
"\<^bold>\<lambda>(c: _) (d: _) P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.case_1 \<cdot> P \<cdot> _ \<cdot> p \<bullet> arity_type_bool \<bullet> c \<bullet> d)"
|
berghofe@13403
|
284 |
|
berghofe@13725
|
285 |
disjI1 (P): "Some"
|
blanchet@55642
|
286 |
"\<^bold>\<lambda>(c: _) P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.case_2 \<cdot> _ \<cdot> P \<cdot> p \<bullet> arity_type_bool \<bullet> c)"
|
berghofe@13403
|
287 |
|
berghofe@13725
|
288 |
disjI1 (Q): "None"
|
blanchet@55642
|
289 |
"\<^bold>\<lambda>(c: _) P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.case_1 \<cdot> _ \<cdot> _ \<bullet> arity_type_bool \<bullet> c)"
|
berghofe@13403
|
290 |
|
berghofe@13725
|
291 |
disjI1: "Left"
|
blanchet@55642
|
292 |
"\<^bold>\<lambda>P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.case_1 \<cdot> _ \<cdot> _ \<bullet> arity_type_bool)"
|
berghofe@13403
|
293 |
|
berghofe@13725
|
294 |
disjI2 (P, Q): "Inr"
|
blanchet@55642
|
295 |
"\<^bold>\<lambda>(d: _) (c: _) Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.case_2 \<cdot> _ \<cdot> Q \<cdot> q \<bullet> arity_type_bool \<bullet> c \<bullet> d)"
|
berghofe@13403
|
296 |
|
berghofe@13725
|
297 |
disjI2 (P): "None"
|
blanchet@55642
|
298 |
"\<^bold>\<lambda>(c: _) Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.case_1 \<cdot> _ \<cdot> _ \<bullet> arity_type_bool \<bullet> c)"
|
berghofe@13403
|
299 |
|
berghofe@13725
|
300 |
disjI2 (Q): "Some"
|
blanchet@55642
|
301 |
"\<^bold>\<lambda>(c: _) Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.case_2 \<cdot> _ \<cdot> Q \<cdot> q \<bullet> arity_type_bool \<bullet> c)"
|
berghofe@13403
|
302 |
|
berghofe@13725
|
303 |
disjI2: "Right"
|
blanchet@55642
|
304 |
"\<^bold>\<lambda>Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.case_2 \<cdot> _ \<cdot> _ \<bullet> arity_type_bool)"
|
berghofe@13403
|
305 |
|
berghofe@13725
|
306 |
disjE (P, Q, R): "\<lambda>pq pr qr.
|
berghofe@13403
|
307 |
(case pq of Inl p \<Rightarrow> pr p | Inr q \<Rightarrow> qr q)"
|
wenzelm@52486
|
308 |
"\<^bold>\<lambda>(c: _) (d: _) (e: _) P Q R pq (h1: _) pr (h2: _) qr.
|
berghofe@37233
|
309 |
disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> c \<bullet> d \<bullet> e \<bullet> h1 \<bullet> h2"
|
berghofe@13403
|
310 |
|
berghofe@13725
|
311 |
disjE (Q, R): "\<lambda>pq pr qr.
|
berghofe@13403
|
312 |
(case pq of None \<Rightarrow> pr | Some q \<Rightarrow> qr q)"
|
wenzelm@52486
|
313 |
"\<^bold>\<lambda>(c: _) (d: _) P Q R pq (h1: _) pr (h2: _) qr.
|
berghofe@37233
|
314 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> c \<bullet> d \<bullet> h1 \<bullet> h2"
|
berghofe@13403
|
315 |
|
berghofe@13725
|
316 |
disjE (P, R): "\<lambda>pq pr qr.
|
berghofe@13403
|
317 |
(case pq of None \<Rightarrow> qr | Some p \<Rightarrow> pr p)"
|
wenzelm@52486
|
318 |
"\<^bold>\<lambda>(c: _) (d: _) P Q R pq (h1: _) pr (h2: _) qr (h3: _).
|
berghofe@37233
|
319 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> qr \<cdot> pr \<bullet> c \<bullet> d \<bullet> h1 \<bullet> h3 \<bullet> h2"
|
berghofe@13403
|
320 |
|
berghofe@13725
|
321 |
disjE (R): "\<lambda>pq pr qr.
|
berghofe@13403
|
322 |
(case pq of Left \<Rightarrow> pr | Right \<Rightarrow> qr)"
|
wenzelm@52486
|
323 |
"\<^bold>\<lambda>(c: _) P Q R pq (h1: _) pr (h2: _) qr.
|
berghofe@37233
|
324 |
disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> c \<bullet> h1 \<bullet> h2"
|
berghofe@13403
|
325 |
|
berghofe@13403
|
326 |
disjE (P, Q): "Null"
|
wenzelm@52486
|
327 |
"\<^bold>\<lambda>(c: _) (d: _) P Q R pq. disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> c \<bullet> d \<bullet> arity_type_bool"
|
berghofe@13403
|
328 |
|
berghofe@13403
|
329 |
disjE (Q): "Null"
|
wenzelm@52486
|
330 |
"\<^bold>\<lambda>(c: _) P Q R pq. disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> c \<bullet> arity_type_bool"
|
berghofe@13403
|
331 |
|
berghofe@13403
|
332 |
disjE (P): "Null"
|
wenzelm@52486
|
333 |
"\<^bold>\<lambda>(c: _) P Q R pq (h1: _) (h2: _) (h3: _).
|
berghofe@37233
|
334 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> c \<bullet> arity_type_bool \<bullet> h1 \<bullet> h3 \<bullet> h2"
|
berghofe@13403
|
335 |
|
berghofe@13403
|
336 |
disjE: "Null"
|
wenzelm@52486
|
337 |
"\<^bold>\<lambda>P Q R pq. disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> arity_type_bool"
|
berghofe@13403
|
338 |
|
haftmann@27982
|
339 |
FalseE (P): "default"
|
wenzelm@52486
|
340 |
"\<^bold>\<lambda>(c: _) P. FalseE \<cdot> _"
|
berghofe@13403
|
341 |
|
berghofe@13725
|
342 |
FalseE: "Null" "FalseE"
|
berghofe@13403
|
343 |
|
berghofe@13403
|
344 |
notI (P): "Null"
|
wenzelm@52486
|
345 |
"\<^bold>\<lambda>(c: _) P (h: _). allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. notI \<cdot> _ \<bullet> (h \<cdot> x))"
|
berghofe@13403
|
346 |
|
berghofe@13725
|
347 |
notI: "Null" "notI"
|
berghofe@13403
|
348 |
|
haftmann@27982
|
349 |
notE (P, R): "\<lambda>p. default"
|
wenzelm@52486
|
350 |
"\<^bold>\<lambda>(c: _) (d: _) P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> c \<bullet> h)"
|
berghofe@13403
|
351 |
|
berghofe@13403
|
352 |
notE (P): "Null"
|
wenzelm@52486
|
353 |
"\<^bold>\<lambda>(c: _) P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> c \<bullet> h)"
|
berghofe@13403
|
354 |
|
haftmann@27982
|
355 |
notE (R): "default"
|
wenzelm@52486
|
356 |
"\<^bold>\<lambda>(c: _) P R. notE \<cdot> _ \<cdot> _"
|
berghofe@13403
|
357 |
|
berghofe@13725
|
358 |
notE: "Null" "notE"
|
berghofe@13403
|
359 |
|
berghofe@13725
|
360 |
subst (P): "\<lambda>s t ps. ps"
|
wenzelm@52486
|
361 |
"\<^bold>\<lambda>(c: _) s t P (d: _) (h: _) ps. subst \<cdot> s \<cdot> t \<cdot> P ps \<bullet> d \<bullet> h"
|
berghofe@13403
|
362 |
|
berghofe@13725
|
363 |
subst: "Null" "subst"
|
berghofe@13725
|
364 |
|
berghofe@13725
|
365 |
iffD1 (P, Q): "fst"
|
wenzelm@52486
|
366 |
"\<^bold>\<lambda>(d: _) (c: _) Q P pq (h: _) p.
|
berghofe@37233
|
367 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> d \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
|
berghofe@13403
|
368 |
|
berghofe@13725
|
369 |
iffD1 (P): "\<lambda>p. p"
|
wenzelm@52486
|
370 |
"\<^bold>\<lambda>(c: _) Q P p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h)"
|
berghofe@13403
|
371 |
|
berghofe@13403
|
372 |
iffD1 (Q): "Null"
|
wenzelm@52486
|
373 |
"\<^bold>\<lambda>(c: _) Q P q1 (h: _) q2.
|
berghofe@37233
|
374 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> c \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
|
berghofe@13403
|
375 |
|
berghofe@13725
|
376 |
iffD1: "Null" "iffD1"
|
berghofe@13403
|
377 |
|
berghofe@13725
|
378 |
iffD2 (P, Q): "snd"
|
wenzelm@52486
|
379 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq (h: _) q.
|
berghofe@37233
|
380 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q \<bullet> d \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
|
berghofe@13403
|
381 |
|
berghofe@13725
|
382 |
iffD2 (P): "\<lambda>p. p"
|
wenzelm@52486
|
383 |
"\<^bold>\<lambda>(c: _) P Q p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h)"
|
berghofe@13403
|
384 |
|
berghofe@13403
|
385 |
iffD2 (Q): "Null"
|
wenzelm@52486
|
386 |
"\<^bold>\<lambda>(c: _) P Q q1 (h: _) q2.
|
berghofe@37233
|
387 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> c \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
|
berghofe@13403
|
388 |
|
berghofe@13725
|
389 |
iffD2: "Null" "iffD2"
|
berghofe@13403
|
390 |
|
berghofe@13725
|
391 |
iffI (P, Q): "Pair"
|
wenzelm@52486
|
392 |
"\<^bold>\<lambda>(c: _) (d: _) P Q pq (h1 : _) qp (h2 : _). conjI_realizer \<cdot>
|
berghofe@13725
|
393 |
(\<lambda>pq. \<forall>x. P x \<longrightarrow> Q (pq x)) \<cdot> pq \<cdot>
|
berghofe@13725
|
394 |
(\<lambda>qp. \<forall>x. Q x \<longrightarrow> P (qp x)) \<cdot> qp \<bullet>
|
berghofe@37233
|
395 |
(arity_type_fun \<bullet> c \<bullet> d) \<bullet>
|
berghofe@37233
|
396 |
(arity_type_fun \<bullet> d \<bullet> c) \<bullet>
|
wenzelm@52486
|
397 |
(allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
|
wenzelm@52486
|
398 |
(allI \<cdot> _ \<bullet> d \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
|
berghofe@13403
|
399 |
|
berghofe@13725
|
400 |
iffI (P): "\<lambda>p. p"
|
wenzelm@52486
|
401 |
"\<^bold>\<lambda>(c: _) P Q (h1 : _) p (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
|
wenzelm@52486
|
402 |
(allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
|
berghofe@13403
|
403 |
(impI \<cdot> _ \<cdot> _ \<bullet> h2)"
|
berghofe@13403
|
404 |
|
berghofe@13725
|
405 |
iffI (Q): "\<lambda>q. q"
|
wenzelm@52486
|
406 |
"\<^bold>\<lambda>(c: _) P Q q (h1 : _) (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
|
berghofe@13403
|
407 |
(impI \<cdot> _ \<cdot> _ \<bullet> h1) \<bullet>
|
wenzelm@52486
|
408 |
(allI \<cdot> _ \<bullet> c \<bullet> (\<^bold>\<lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
|
berghofe@13403
|
409 |
|
berghofe@13725
|
410 |
iffI: "Null" "iffI"
|
berghofe@13403
|
411 |
|
berghofe@13403
|
412 |
end
|