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