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