author | berghofe |
Mon, 16 Dec 2002 13:43:11 +0100 | |
changeset 13755 | a9bb54a3cfb7 |
parent 13725 | 12404b452034 |
child 13918 | 2134ed516b1b |
permissions | -rw-r--r-- |
13403 | 1 |
(* Title: HOL/Extraction.thy |
2 |
ID: $Id$ |
|
3 |
Author: Stefan Berghofer, TU Muenchen |
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
5 |
*) |
|
6 |
||
7 |
header {* Program extraction for HOL *} |
|
8 |
||
9 |
theory Extraction = Datatype |
|
10 |
files |
|
11 |
"Tools/rewrite_hol_proof.ML": |
|
12 |
||
13 |
subsection {* Setup *} |
|
14 |
||
15 |
ML_setup {* |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
16 |
fun realizes_set_proc (Const ("realizes", Type ("fun", [Type ("Null", []), _])) $ r $ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
17 |
(Const ("op :", _) $ x $ S)) = (case strip_comb S of |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
18 |
(Var (ixn, U), ts) => Some (list_comb (Var (ixn, binder_types U @ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
19 |
[HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), ts @ [x])) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
20 |
| (Free (s, U), ts) => Some (list_comb (Free (s, binder_types U @ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
21 |
[HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), ts @ [x])) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
22 |
| _ => None) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
23 |
| realizes_set_proc (Const ("realizes", Type ("fun", [T, _])) $ r $ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
24 |
(Const ("op :", _) $ x $ S)) = (case strip_comb S of |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
25 |
(Var (ixn, U), ts) => Some (list_comb (Var (ixn, T :: binder_types U @ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
26 |
[HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), r :: ts @ [x])) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
27 |
| (Free (s, U), ts) => Some (list_comb (Free (s, T :: binder_types U @ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
28 |
[HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), r :: ts @ [x])) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
29 |
| _ => None) |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
30 |
| realizes_set_proc _ = None; |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
31 |
|
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
32 |
fun mk_realizes_set r rT s (setT as Type ("set", [elT])) = |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
33 |
Abs ("x", elT, Const ("realizes", rT --> HOLogic.boolT --> HOLogic.boolT) $ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
34 |
incr_boundvars 1 r $ (Const ("op :", elT --> setT --> HOLogic.boolT) $ |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
35 |
Bound 0 $ incr_boundvars 1 s)); |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
36 |
|
13403 | 37 |
Context.>> (fn thy => thy |> |
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
38 |
Extraction.add_types |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
39 |
[("bool", ([], None)), |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
40 |
("set", ([realizes_set_proc], Some mk_realizes_set))] |> |
13403 | 41 |
Extraction.set_preprocessor (fn sg => |
42 |
Proofterm.rewrite_proof_notypes |
|
43 |
([], ("HOL/elim_cong", RewriteHOLProof.elim_cong) :: |
|
44 |
ProofRewriteRules.rprocs true) o |
|
45 |
Proofterm.rewrite_proof (Sign.tsig_of sg) |
|
13599 | 46 |
(RewriteHOLProof.rews, ProofRewriteRules.rprocs true) o |
47 |
ProofRewriteRules.elim_vars (curry Const "arbitrary"))) |
|
13403 | 48 |
*} |
49 |
||
50 |
lemmas [extraction_expand] = |
|
13468
71118807d303
Removed (now unneeded) declaration of realizers for induction on natural numbers.
berghofe
parents:
13452
diff
changeset
|
51 |
atomize_eq atomize_all atomize_imp |
13403 | 52 |
allE rev_mp conjE Eq_TrueI Eq_FalseI eqTrueI eqTrueE eq_cong2 |
53 |
notE' impE' impE iffE imp_cong simp_thms |
|
54 |
induct_forall_eq induct_implies_eq induct_equal_eq |
|
55 |
induct_forall_def induct_implies_def |
|
56 |
induct_atomize induct_rulify1 induct_rulify2 |
|
57 |
||
58 |
datatype sumbool = Left | Right |
|
59 |
||
60 |
subsection {* Type of extracted program *} |
|
61 |
||
62 |
extract_type |
|
63 |
"typeof (Trueprop P) \<equiv> typeof P" |
|
64 |
||
65 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
66 |
typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE('Q))" |
|
67 |
||
68 |
"typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE(Null))" |
|
69 |
||
70 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
71 |
typeof (P \<longrightarrow> Q) \<equiv> Type (TYPE('P \<Rightarrow> 'Q))" |
|
72 |
||
73 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow> |
|
74 |
typeof (\<forall>x. P x) \<equiv> Type (TYPE(Null))" |
|
75 |
||
76 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE('P))) \<Longrightarrow> |
|
77 |
typeof (\<forall>x::'a. P x) \<equiv> Type (TYPE('a \<Rightarrow> 'P))" |
|
78 |
||
79 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow> |
|
80 |
typeof (\<exists>x::'a. P x) \<equiv> Type (TYPE('a))" |
|
81 |
||
82 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE('P))) \<Longrightarrow> |
|
83 |
typeof (\<exists>x::'a. P x) \<equiv> Type (TYPE('a \<times> 'P))" |
|
84 |
||
85 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
86 |
typeof (P \<or> Q) \<equiv> Type (TYPE(sumbool))" |
|
87 |
||
88 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
89 |
typeof (P \<or> Q) \<equiv> Type (TYPE('Q option))" |
|
90 |
||
91 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
92 |
typeof (P \<or> Q) \<equiv> Type (TYPE('P option))" |
|
93 |
||
94 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
95 |
typeof (P \<or> Q) \<equiv> Type (TYPE('P + 'Q))" |
|
96 |
||
97 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
98 |
typeof (P \<and> Q) \<equiv> Type (TYPE('Q))" |
|
99 |
||
100 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
101 |
typeof (P \<and> Q) \<equiv> Type (TYPE('P))" |
|
102 |
||
103 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> typeof Q \<equiv> Type (TYPE('Q)) \<Longrightarrow> |
|
104 |
typeof (P \<and> Q) \<equiv> Type (TYPE('P \<times> 'Q))" |
|
105 |
||
106 |
"typeof (P = Q) \<equiv> typeof ((P \<longrightarrow> Q) \<and> (Q \<longrightarrow> P))" |
|
107 |
||
108 |
"typeof (x \<in> P) \<equiv> typeof P" |
|
109 |
||
110 |
subsection {* Realizability *} |
|
111 |
||
112 |
realizability |
|
113 |
"(realizes t (Trueprop P)) \<equiv> (Trueprop (realizes t P))" |
|
114 |
||
115 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
116 |
(realizes t (P \<longrightarrow> Q)) \<equiv> (realizes Null P \<longrightarrow> realizes t Q)" |
|
117 |
||
118 |
"(typeof P) \<equiv> (Type (TYPE('P))) \<Longrightarrow> |
|
119 |
(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
120 |
(realizes t (P \<longrightarrow> Q)) \<equiv> (\<forall>x::'P. realizes x P \<longrightarrow> realizes Null Q)" |
|
121 |
||
122 |
"(realizes t (P \<longrightarrow> Q)) \<equiv> (\<forall>x. realizes x P \<longrightarrow> realizes (t x) Q)" |
|
123 |
||
124 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow> |
|
125 |
(realizes t (\<forall>x. P x)) \<equiv> (\<forall>x. realizes Null (P x))" |
|
126 |
||
127 |
"(realizes t (\<forall>x. P x)) \<equiv> (\<forall>x. realizes (t x) (P x))" |
|
128 |
||
129 |
"(\<lambda>x. typeof (P x)) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow> |
|
130 |
(realizes t (\<exists>x. P x)) \<equiv> (realizes Null (P t))" |
|
131 |
||
132 |
"(realizes t (\<exists>x. P x)) \<equiv> (realizes (snd t) (P (fst t)))" |
|
133 |
||
134 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
135 |
(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
136 |
(realizes t (P \<or> Q)) \<equiv> |
|
137 |
(case t of Left \<Rightarrow> realizes Null P | Right \<Rightarrow> realizes Null Q)" |
|
138 |
||
139 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
140 |
(realizes t (P \<or> Q)) \<equiv> |
|
141 |
(case t of None \<Rightarrow> realizes Null P | Some q \<Rightarrow> realizes q Q)" |
|
142 |
||
143 |
"(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
144 |
(realizes t (P \<or> Q)) \<equiv> |
|
145 |
(case t of None \<Rightarrow> realizes Null Q | Some p \<Rightarrow> realizes p P)" |
|
146 |
||
147 |
"(realizes t (P \<or> Q)) \<equiv> |
|
148 |
(case t of Inl p \<Rightarrow> realizes p P | Inr q \<Rightarrow> realizes q Q)" |
|
149 |
||
150 |
"(typeof P) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
151 |
(realizes t (P \<and> Q)) \<equiv> (realizes Null P \<and> realizes t Q)" |
|
152 |
||
153 |
"(typeof Q) \<equiv> (Type (TYPE(Null))) \<Longrightarrow> |
|
154 |
(realizes t (P \<and> Q)) \<equiv> (realizes t P \<and> realizes Null Q)" |
|
155 |
||
156 |
"(realizes t (P \<and> Q)) \<equiv> (realizes (fst t) P \<and> realizes (snd t) Q)" |
|
157 |
||
158 |
"typeof P \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
159 |
realizes t (\<not> P) \<equiv> \<not> realizes Null P" |
|
160 |
||
161 |
"typeof P \<equiv> Type (TYPE('P)) \<Longrightarrow> |
|
162 |
realizes t (\<not> P) \<equiv> (\<forall>x::'P. \<not> realizes x P)" |
|
163 |
||
164 |
"typeof (P::bool) \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
165 |
typeof Q \<equiv> Type (TYPE(Null)) \<Longrightarrow> |
|
166 |
realizes t (P = Q) \<equiv> realizes Null P = realizes Null Q" |
|
167 |
||
168 |
"(realizes t (P = Q)) \<equiv> (realizes t ((P \<longrightarrow> Q) \<and> (Q \<longrightarrow> P)))" |
|
169 |
||
170 |
subsection {* Computational content of basic inference rules *} |
|
171 |
||
172 |
theorem disjE_realizer: |
|
173 |
assumes r: "case x of Inl p \<Rightarrow> P p | Inr q \<Rightarrow> Q q" |
|
174 |
and r1: "\<And>p. P p \<Longrightarrow> R (f p)" and r2: "\<And>q. Q q \<Longrightarrow> R (g q)" |
|
175 |
shows "R (case x of Inl p \<Rightarrow> f p | Inr q \<Rightarrow> g q)" |
|
176 |
proof (cases x) |
|
177 |
case Inl |
|
178 |
with r show ?thesis by simp (rule r1) |
|
179 |
next |
|
180 |
case Inr |
|
181 |
with r show ?thesis by simp (rule r2) |
|
182 |
qed |
|
183 |
||
184 |
theorem disjE_realizer2: |
|
185 |
assumes r: "case x of None \<Rightarrow> P | Some q \<Rightarrow> Q q" |
|
186 |
and r1: "P \<Longrightarrow> R f" and r2: "\<And>q. Q q \<Longrightarrow> R (g q)" |
|
187 |
shows "R (case x of None \<Rightarrow> f | Some q \<Rightarrow> g q)" |
|
188 |
proof (cases x) |
|
189 |
case None |
|
190 |
with r show ?thesis by simp (rule r1) |
|
191 |
next |
|
192 |
case Some |
|
193 |
with r show ?thesis by simp (rule r2) |
|
194 |
qed |
|
195 |
||
196 |
theorem disjE_realizer3: |
|
197 |
assumes r: "case x of Left \<Rightarrow> P | Right \<Rightarrow> Q" |
|
198 |
and r1: "P \<Longrightarrow> R f" and r2: "Q \<Longrightarrow> R g" |
|
199 |
shows "R (case x of Left \<Rightarrow> f | Right \<Rightarrow> g)" |
|
200 |
proof (cases x) |
|
201 |
case Left |
|
202 |
with r show ?thesis by simp (rule r1) |
|
203 |
next |
|
204 |
case Right |
|
205 |
with r show ?thesis by simp (rule r2) |
|
206 |
qed |
|
207 |
||
208 |
theorem conjI_realizer: |
|
209 |
"P p \<Longrightarrow> Q q \<Longrightarrow> P (fst (p, q)) \<and> Q (snd (p, q))" |
|
210 |
by simp |
|
211 |
||
212 |
theorem exI_realizer: |
|
213 |
"P x y \<Longrightarrow> P (fst (x, y)) (snd (x, y))" by simp |
|
214 |
||
215 |
realizers |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
216 |
impI (P, Q): "\<lambda>pq. pq" |
13403 | 217 |
"\<Lambda>P Q pq (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))" |
218 |
||
219 |
impI (P): "Null" |
|
220 |
"\<Lambda>P Q (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))" |
|
221 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
222 |
impI (Q): "\<lambda>q. q" "\<Lambda>P Q q. impI \<cdot> _ \<cdot> _" |
13403 | 223 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
224 |
impI: "Null" "impI" |
13403 | 225 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
226 |
mp (P, Q): "\<lambda>pq. pq" |
13403 | 227 |
"\<Lambda>P Q pq (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)" |
228 |
||
229 |
mp (P): "Null" |
|
230 |
"\<Lambda>P Q (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)" |
|
231 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
232 |
mp (Q): "\<lambda>q. q" "\<Lambda>P Q q. mp \<cdot> _ \<cdot> _" |
13403 | 233 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
234 |
mp: "Null" "mp" |
13403 | 235 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
236 |
allI (P): "\<lambda>p. p" "\<Lambda>P p. allI \<cdot> _" |
13403 | 237 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
238 |
allI: "Null" "allI" |
13403 | 239 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
240 |
spec (P): "\<lambda>x p. p x" "\<Lambda>P x p. spec \<cdot> _ \<cdot> x" |
13403 | 241 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
242 |
spec: "Null" "spec" |
13403 | 243 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
244 |
exI (P): "\<lambda>x p. (x, p)" "\<Lambda>P. exI_realizer \<cdot> _" |
13403 | 245 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
246 |
exI: "\<lambda>x. x" "\<Lambda>P x (h: _). h" |
13403 | 247 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
248 |
exE (P, Q): "\<lambda>p pq. pq (fst p) (snd p)" |
13403 | 249 |
"\<Lambda>P Q p (h1: _) pq (h2: _). h2 \<cdot> (fst p) \<cdot> (snd p) \<bullet> h1" |
250 |
||
251 |
exE (P): "Null" |
|
252 |
"\<Lambda>P Q p (h1: _) (h2: _). h2 \<cdot> (fst p) \<cdot> (snd p) \<bullet> h1" |
|
253 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
254 |
exE (Q): "\<lambda>x pq. pq x" |
13403 | 255 |
"\<Lambda>P Q x (h1: _) pq (h2: _). h2 \<cdot> x \<bullet> h1" |
256 |
||
257 |
exE: "Null" |
|
258 |
"\<Lambda>P Q x (h1: _) (h2: _). h2 \<cdot> x \<bullet> h1" |
|
259 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
260 |
conjI (P, Q): "Pair" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
261 |
"\<Lambda>P Q p (h: _) q. conjI_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> q \<bullet> h" |
13403 | 262 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
263 |
conjI (P): "\<lambda>p. p" |
13403 | 264 |
"\<Lambda>P Q p. conjI \<cdot> _ \<cdot> _" |
265 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
266 |
conjI (Q): "\<lambda>q. q" |
13403 | 267 |
"\<Lambda>P Q (h: _) q. conjI \<cdot> _ \<cdot> _ \<bullet> h" |
268 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
269 |
conjI: "Null" "conjI" |
13403 | 270 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
271 |
conjunct1 (P, Q): "fst" |
13403 | 272 |
"\<Lambda>P Q pq. conjunct1 \<cdot> _ \<cdot> _" |
273 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
274 |
conjunct1 (P): "\<lambda>p. p" |
13403 | 275 |
"\<Lambda>P Q p. conjunct1 \<cdot> _ \<cdot> _" |
276 |
||
277 |
conjunct1 (Q): "Null" |
|
278 |
"\<Lambda>P Q q. conjunct1 \<cdot> _ \<cdot> _" |
|
279 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
280 |
conjunct1: "Null" "conjunct1" |
13403 | 281 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
282 |
conjunct2 (P, Q): "snd" |
13403 | 283 |
"\<Lambda>P Q pq. conjunct2 \<cdot> _ \<cdot> _" |
284 |
||
285 |
conjunct2 (P): "Null" |
|
286 |
"\<Lambda>P Q p. conjunct2 \<cdot> _ \<cdot> _" |
|
287 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
288 |
conjunct2 (Q): "\<lambda>p. p" |
13403 | 289 |
"\<Lambda>P Q p. conjunct2 \<cdot> _ \<cdot> _" |
290 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
291 |
conjunct2: "Null" "conjunct2" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
292 |
|
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
293 |
disjI1 (P, Q): "Inl" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
294 |
"\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_1 \<cdot> P \<cdot> _ \<cdot> p)" |
13403 | 295 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
296 |
disjI1 (P): "Some" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
297 |
"\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> P \<cdot> p)" |
13403 | 298 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
299 |
disjI1 (Q): "None" |
13403 | 300 |
"\<Lambda>P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)" |
301 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
302 |
disjI1: "Left" |
13403 | 303 |
"\<Lambda>P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_1 \<cdot> _ \<cdot> _)" |
304 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
305 |
disjI2 (P, Q): "Inr" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
306 |
"\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)" |
13403 | 307 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
308 |
disjI2 (P): "None" |
13403 | 309 |
"\<Lambda>Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)" |
310 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
311 |
disjI2 (Q): "Some" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
312 |
"\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)" |
13403 | 313 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
314 |
disjI2: "Right" |
13403 | 315 |
"\<Lambda>Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_2 \<cdot> _ \<cdot> _)" |
316 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
317 |
disjE (P, Q, R): "\<lambda>pq pr qr. |
13403 | 318 |
(case pq of Inl p \<Rightarrow> pr p | Inr q \<Rightarrow> qr q)" |
319 |
"\<Lambda>P Q R pq (h1: _) pr (h2: _) qr. |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
320 |
disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2" |
13403 | 321 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
322 |
disjE (Q, R): "\<lambda>pq pr qr. |
13403 | 323 |
(case pq of None \<Rightarrow> pr | Some q \<Rightarrow> qr q)" |
324 |
"\<Lambda>P Q R pq (h1: _) pr (h2: _) qr. |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
325 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2" |
13403 | 326 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
327 |
disjE (P, R): "\<lambda>pq pr qr. |
13403 | 328 |
(case pq of None \<Rightarrow> qr | Some p \<Rightarrow> pr p)" |
329 |
"\<Lambda>P Q R pq (h1: _) pr (h2: _) qr (h3: _). |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
330 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> qr \<cdot> pr \<bullet> h1 \<bullet> h3 \<bullet> h2" |
13403 | 331 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
332 |
disjE (R): "\<lambda>pq pr qr. |
13403 | 333 |
(case pq of Left \<Rightarrow> pr | Right \<Rightarrow> qr)" |
334 |
"\<Lambda>P Q R pq (h1: _) pr (h2: _) qr. |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
335 |
disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2" |
13403 | 336 |
|
337 |
disjE (P, Q): "Null" |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
338 |
"\<Lambda>P Q R pq. disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _" |
13403 | 339 |
|
340 |
disjE (Q): "Null" |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
341 |
"\<Lambda>P Q R pq. disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _" |
13403 | 342 |
|
343 |
disjE (P): "Null" |
|
344 |
"\<Lambda>P Q R pq (h1: _) (h2: _) (h3: _). |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
345 |
disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> h1 \<bullet> h3 \<bullet> h2" |
13403 | 346 |
|
347 |
disjE: "Null" |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
348 |
"\<Lambda>P Q R pq. disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _" |
13403 | 349 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
350 |
FalseE (P): "arbitrary" |
13403 | 351 |
"\<Lambda>P. FalseE \<cdot> _" |
352 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
353 |
FalseE: "Null" "FalseE" |
13403 | 354 |
|
355 |
notI (P): "Null" |
|
356 |
"\<Lambda>P (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. notI \<cdot> _ \<bullet> (h \<cdot> x))" |
|
357 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
358 |
notI: "Null" "notI" |
13403 | 359 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
360 |
notE (P, R): "\<lambda>p. arbitrary" |
13403 | 361 |
"\<Lambda>P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)" |
362 |
||
363 |
notE (P): "Null" |
|
364 |
"\<Lambda>P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)" |
|
365 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
366 |
notE (R): "arbitrary" |
13403 | 367 |
"\<Lambda>P R. notE \<cdot> _ \<cdot> _" |
368 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
369 |
notE: "Null" "notE" |
13403 | 370 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
371 |
subst (P): "\<lambda>s t ps. ps" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
372 |
"\<Lambda>s t P (h: _) ps. subst \<cdot> s \<cdot> t \<cdot> P ps \<bullet> h" |
13403 | 373 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
374 |
subst: "Null" "subst" |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
375 |
|
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
376 |
iffD1 (P, Q): "fst" |
13403 | 377 |
"\<Lambda>Q P pq (h: _) p. |
378 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))" |
|
379 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
380 |
iffD1 (P): "\<lambda>p. p" |
13403 | 381 |
"\<Lambda>Q P p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h)" |
382 |
||
383 |
iffD1 (Q): "Null" |
|
384 |
"\<Lambda>Q P q1 (h: _) q2. |
|
385 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))" |
|
386 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
387 |
iffD1: "Null" "iffD1" |
13403 | 388 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
389 |
iffD2 (P, Q): "snd" |
13403 | 390 |
"\<Lambda>P Q pq (h: _) q. |
391 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))" |
|
392 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
393 |
iffD2 (P): "\<lambda>p. p" |
13403 | 394 |
"\<Lambda>P Q p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h)" |
395 |
||
396 |
iffD2 (Q): "Null" |
|
397 |
"\<Lambda>P Q q1 (h: _) q2. |
|
398 |
mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))" |
|
399 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
400 |
iffD2: "Null" "iffD2" |
13403 | 401 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
402 |
iffI (P, Q): "Pair" |
13403 | 403 |
"\<Lambda>P Q pq (h1 : _) qp (h2 : _). conjI_realizer \<cdot> |
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
404 |
(\<lambda>pq. \<forall>x. P x \<longrightarrow> Q (pq x)) \<cdot> pq \<cdot> |
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
405 |
(\<lambda>qp. \<forall>x. Q x \<longrightarrow> P (qp x)) \<cdot> qp \<bullet> |
13403 | 406 |
(allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet> |
407 |
(allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))" |
|
408 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
409 |
iffI (P): "\<lambda>p. p" |
13403 | 410 |
"\<Lambda>P Q (h1 : _) p (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet> |
411 |
(allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet> |
|
412 |
(impI \<cdot> _ \<cdot> _ \<bullet> h2)" |
|
413 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
414 |
iffI (Q): "\<lambda>q. q" |
13403 | 415 |
"\<Lambda>P Q q (h1 : _) (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet> |
416 |
(impI \<cdot> _ \<cdot> _ \<bullet> h1) \<bullet> |
|
417 |
(allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))" |
|
418 |
||
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
419 |
iffI: "Null" "iffI" |
13403 | 420 |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
421 |
(* |
13403 | 422 |
classical: "Null" |
423 |
"\<Lambda>P. classical \<cdot> _" |
|
13725
12404b452034
Changed format of realizers / correctness proofs.
berghofe
parents:
13599
diff
changeset
|
424 |
*) |
13403 | 425 |
|
426 |
end |