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