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