src/HOL/Extraction.thy
author wenzelm
Tue Nov 17 14:48:21 2009 +0100 (2009-11-17)
changeset 33723 14d0dadd9517
parent 33704 6aeb8454efc1
child 34913 d8cb720c9c53
permissions -rw-r--r--
eliminated dead code;
     1 (*  Title:      HOL/Extraction.thy
     2     ID:         $Id$
     3     Author:     Stefan Berghofer, TU Muenchen
     4 *)
     5 
     6 header {* Program extraction for HOL *}
     7 
     8 theory Extraction
     9 imports Option
    10 uses "Tools/rewrite_hol_proof.ML"
    11 begin
    12 
    13 subsection {* Setup *}
    14 
    15 setup {*
    16   Extraction.add_types
    17       [("bool", ([], NONE))] #>
    18   Extraction.set_preprocessor (fn thy =>
    19       Proofterm.rewrite_proof_notypes
    20         ([], RewriteHOLProof.elim_cong :: ProofRewriteRules.rprocs true) o
    21       Proofterm.rewrite_proof thy
    22         (RewriteHOLProof.rews, ProofRewriteRules.rprocs true) o
    23       ProofRewriteRules.elim_vars (curry Const @{const_name default}))
    24 *}
    25 
    26 lemmas [extraction_expand] =
    27   meta_spec atomize_eq atomize_all atomize_imp atomize_conj
    28   allE rev_mp conjE Eq_TrueI Eq_FalseI eqTrueI eqTrueE eq_cong2
    29   notE' impE' impE iffE imp_cong simp_thms eq_True eq_False
    30   induct_forall_eq induct_implies_eq induct_equal_eq induct_conj_eq
    31   induct_atomize induct_rulify induct_rulify_fallback
    32   True_implies_equals TrueE
    33 
    34 lemmas [extraction_expand_def] =
    35   induct_forall_def induct_implies_def induct_equal_def induct_conj_def
    36 
    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:
   192   "P y x \<Longrightarrow> P (snd (x, y)) (fst (x, y))" by simp
   193 
   194 theorem exE_realizer: "P (snd p) (fst p) \<Longrightarrow>
   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)
   197 
   198 theorem exE_realizer': "P (snd p) (fst p) \<Longrightarrow>
   199   (\<And>x y. P y x \<Longrightarrow> Q) \<Longrightarrow> Q" by (cases p) simp
   200 
   201 setup {*
   202   Sign.add_const_constraint (@{const_name "default"}, SOME @{typ "'a::type"})
   203 *}
   204 
   205 realizers
   206   impI (P, Q): "\<lambda>pq. pq"
   207     "\<Lambda> P Q pq (h: _). allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
   208 
   209   impI (P): "Null"
   210     "\<Lambda> P Q (h: _). allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
   211 
   212   impI (Q): "\<lambda>q. q" "\<Lambda> P Q q. impI \<cdot> _ \<cdot> _"
   213 
   214   impI: "Null" "impI"
   215 
   216   mp (P, Q): "\<lambda>pq. pq"
   217     "\<Lambda> P Q pq (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   218 
   219   mp (P): "Null"
   220     "\<Lambda> P Q (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   221 
   222   mp (Q): "\<lambda>q. q" "\<Lambda> P Q q. mp \<cdot> _ \<cdot> _"
   223 
   224   mp: "Null" "mp"
   225 
   226   allI (P): "\<lambda>p. p" "\<Lambda> P p. allI \<cdot> _"
   227 
   228   allI: "Null" "allI"
   229 
   230   spec (P): "\<lambda>x p. p x" "\<Lambda> P x p. spec \<cdot> _ \<cdot> x"
   231 
   232   spec: "Null" "spec"
   233 
   234   exI (P): "\<lambda>x p. (x, p)" "\<Lambda> P x p. exI_realizer \<cdot> P \<cdot> p \<cdot> x"
   235 
   236   exI: "\<lambda>x. x" "\<Lambda> P x (h: _). h"
   237 
   238   exE (P, Q): "\<lambda>p pq. let (x, y) = p in pq x y"
   239     "\<Lambda> P Q p (h: _) pq. exE_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> pq \<bullet> h"
   240 
   241   exE (P): "Null"
   242     "\<Lambda> P Q p. exE_realizer' \<cdot> _ \<cdot> _ \<cdot> _"
   243 
   244   exE (Q): "\<lambda>x pq. pq x"
   245     "\<Lambda> P Q x (h1: _) pq (h2: _). h2 \<cdot> x \<bullet> h1"
   246 
   247   exE: "Null"
   248     "\<Lambda> P Q x (h1: _) (h2: _). h2 \<cdot> x \<bullet> h1"
   249 
   250   conjI (P, Q): "Pair"
   251     "\<Lambda> P Q p (h: _) q. conjI_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> q \<bullet> h"
   252 
   253   conjI (P): "\<lambda>p. p"
   254     "\<Lambda> P Q p. conjI \<cdot> _ \<cdot> _"
   255 
   256   conjI (Q): "\<lambda>q. q"
   257     "\<Lambda> P Q (h: _) q. conjI \<cdot> _ \<cdot> _ \<bullet> h"
   258 
   259   conjI: "Null" "conjI"
   260 
   261   conjunct1 (P, Q): "fst"
   262     "\<Lambda> P Q pq. conjunct1 \<cdot> _ \<cdot> _"
   263 
   264   conjunct1 (P): "\<lambda>p. p"
   265     "\<Lambda> P Q p. conjunct1 \<cdot> _ \<cdot> _"
   266 
   267   conjunct1 (Q): "Null"
   268     "\<Lambda> P Q q. conjunct1 \<cdot> _ \<cdot> _"
   269 
   270   conjunct1: "Null" "conjunct1"
   271 
   272   conjunct2 (P, Q): "snd"
   273     "\<Lambda> P Q pq. conjunct2 \<cdot> _ \<cdot> _"
   274 
   275   conjunct2 (P): "Null"
   276     "\<Lambda> P Q p. conjunct2 \<cdot> _ \<cdot> _"
   277 
   278   conjunct2 (Q): "\<lambda>p. p"
   279     "\<Lambda> P Q p. conjunct2 \<cdot> _ \<cdot> _"
   280 
   281   conjunct2: "Null" "conjunct2"
   282 
   283   disjI1 (P, Q): "Inl"
   284     "\<Lambda> P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_1 \<cdot> P \<cdot> _ \<cdot> p)"
   285 
   286   disjI1 (P): "Some"
   287     "\<Lambda> P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> P \<cdot> p)"
   288 
   289   disjI1 (Q): "None"
   290     "\<Lambda> P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)"
   291 
   292   disjI1: "Left"
   293     "\<Lambda> P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_1 \<cdot> _ \<cdot> _)"
   294 
   295   disjI2 (P, Q): "Inr"
   296     "\<Lambda> Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)"
   297 
   298   disjI2 (P): "None"
   299     "\<Lambda> Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)"
   300 
   301   disjI2 (Q): "Some"
   302     "\<Lambda> Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)"
   303 
   304   disjI2: "Right"
   305     "\<Lambda> Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_2 \<cdot> _ \<cdot> _)"
   306 
   307   disjE (P, Q, R): "\<lambda>pq pr qr.
   308      (case pq of Inl p \<Rightarrow> pr p | Inr q \<Rightarrow> qr q)"
   309     "\<Lambda> P Q R pq (h1: _) pr (h2: _) qr.
   310        disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   311 
   312   disjE (Q, R): "\<lambda>pq pr qr.
   313      (case pq of None \<Rightarrow> pr | Some q \<Rightarrow> qr q)"
   314     "\<Lambda> P Q R pq (h1: _) pr (h2: _) qr.
   315        disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   316 
   317   disjE (P, R): "\<lambda>pq pr qr.
   318      (case pq of None \<Rightarrow> qr | Some p \<Rightarrow> pr p)"
   319     "\<Lambda> P Q R pq (h1: _) pr (h2: _) qr (h3: _).
   320        disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> qr \<cdot> pr \<bullet> h1 \<bullet> h3 \<bullet> h2"
   321 
   322   disjE (R): "\<lambda>pq pr qr.
   323      (case pq of Left \<Rightarrow> pr | Right \<Rightarrow> qr)"
   324     "\<Lambda> P Q R pq (h1: _) pr (h2: _) qr.
   325        disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   326 
   327   disjE (P, Q): "Null"
   328     "\<Lambda> P Q R pq. disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   329 
   330   disjE (Q): "Null"
   331     "\<Lambda> P Q R pq. disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   332 
   333   disjE (P): "Null"
   334     "\<Lambda> P Q R pq (h1: _) (h2: _) (h3: _).
   335        disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> h1 \<bullet> h3 \<bullet> h2"
   336 
   337   disjE: "Null"
   338     "\<Lambda> P Q R pq. disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   339 
   340   FalseE (P): "default"
   341     "\<Lambda> P. FalseE \<cdot> _"
   342 
   343   FalseE: "Null" "FalseE"
   344 
   345   notI (P): "Null"
   346     "\<Lambda> P (h: _). allI \<cdot> _ \<bullet> (\<Lambda> x. notI \<cdot> _ \<bullet> (h \<cdot> x))"
   347 
   348   notI: "Null" "notI"
   349 
   350   notE (P, R): "\<lambda>p. default"
   351     "\<Lambda> P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   352 
   353   notE (P): "Null"
   354     "\<Lambda> P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   355 
   356   notE (R): "default"
   357     "\<Lambda> P R. notE \<cdot> _ \<cdot> _"
   358 
   359   notE: "Null" "notE"
   360 
   361   subst (P): "\<lambda>s t ps. ps"
   362     "\<Lambda> s t P (h: _) ps. subst \<cdot> s \<cdot> t \<cdot> P ps \<bullet> h"
   363 
   364   subst: "Null" "subst"
   365 
   366   iffD1 (P, Q): "fst"
   367     "\<Lambda> Q P pq (h: _) p.
   368        mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
   369 
   370   iffD1 (P): "\<lambda>p. p"
   371     "\<Lambda> Q P p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h)"
   372 
   373   iffD1 (Q): "Null"
   374     "\<Lambda> Q P q1 (h: _) q2.
   375        mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
   376 
   377   iffD1: "Null" "iffD1"
   378 
   379   iffD2 (P, Q): "snd"
   380     "\<Lambda> P Q pq (h: _) q.
   381        mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
   382 
   383   iffD2 (P): "\<lambda>p. p"
   384     "\<Lambda> P Q p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h)"
   385 
   386   iffD2 (Q): "Null"
   387     "\<Lambda> P Q q1 (h: _) q2.
   388        mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
   389 
   390   iffD2: "Null" "iffD2"
   391 
   392   iffI (P, Q): "Pair"
   393     "\<Lambda> P Q pq (h1 : _) qp (h2 : _). conjI_realizer \<cdot>
   394        (\<lambda>pq. \<forall>x. P x \<longrightarrow> Q (pq x)) \<cdot> pq \<cdot>
   395        (\<lambda>qp. \<forall>x. Q x \<longrightarrow> P (qp x)) \<cdot> qp \<bullet>
   396        (allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
   397        (allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
   398 
   399   iffI (P): "\<lambda>p. p"
   400     "\<Lambda> P Q (h1 : _) p (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
   401        (allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
   402        (impI \<cdot> _ \<cdot> _ \<bullet> h2)"
   403 
   404   iffI (Q): "\<lambda>q. q"
   405     "\<Lambda> P Q q (h1 : _) (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
   406        (impI \<cdot> _ \<cdot> _ \<bullet> h1) \<bullet>
   407        (allI \<cdot> _ \<bullet> (\<Lambda> x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
   408 
   409   iffI: "Null" "iffI"
   410 
   411 (*
   412   classical: "Null"
   413     "\<Lambda> P. classical \<cdot> _"
   414 *)
   415 
   416 setup {*
   417   Sign.add_const_constraint (@{const_name "default"}, SOME @{typ "'a::default"})
   418 *}
   419 
   420 end