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