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