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