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