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