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