Changed format of realizers / correctness proofs.
authorberghofe
Wed Nov 27 17:06:47 2002 +0100 (2002-11-27)
changeset 1372512404b452034
parent 13724 06ded8d18d02
child 13726 9550a6f4ed4a
Changed format of realizers / correctness proofs.
src/HOL/Extraction.thy
src/HOL/Tools/datatype_realizer.ML
src/HOL/Tools/inductive_realizer.ML
     1.1 --- a/src/HOL/Extraction.thy	Mon Nov 25 20:32:29 2002 +0100
     1.2 +++ b/src/HOL/Extraction.thy	Wed Nov 27 17:06:47 2002 +0100
     1.3 @@ -13,7 +13,31 @@
     1.4  subsection {* Setup *}
     1.5  
     1.6  ML_setup {*
     1.7 +fun realizes_set_proc (Const ("realizes", Type ("fun", [Type ("Null", []), _])) $ r $
     1.8 +      (Const ("op :", _) $ x $ S)) = (case strip_comb S of
     1.9 +        (Var (ixn, U), ts) => Some (list_comb (Var (ixn, binder_types U @
    1.10 +           [HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), ts @ [x]))
    1.11 +      | (Free (s, U), ts) => Some (list_comb (Free (s, binder_types U @
    1.12 +           [HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), ts @ [x]))
    1.13 +      | _ => None)
    1.14 +  | realizes_set_proc (Const ("realizes", Type ("fun", [T, _])) $ r $
    1.15 +      (Const ("op :", _) $ x $ S)) = (case strip_comb S of
    1.16 +        (Var (ixn, U), ts) => Some (list_comb (Var (ixn, T :: binder_types U @
    1.17 +           [HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), r :: ts @ [x]))
    1.18 +      | (Free (s, U), ts) => Some (list_comb (Free (s, T :: binder_types U @
    1.19 +           [HOLogic.dest_setT (body_type U)] ---> HOLogic.boolT), r :: ts @ [x]))
    1.20 +      | _ => None)
    1.21 +  | realizes_set_proc _ = None;
    1.22 +
    1.23 +fun mk_realizes_set r rT s (setT as Type ("set", [elT])) =
    1.24 +  Abs ("x", elT, Const ("realizes", rT --> HOLogic.boolT --> HOLogic.boolT) $
    1.25 +    incr_boundvars 1 r $ (Const ("op :", elT --> setT --> HOLogic.boolT) $
    1.26 +      Bound 0 $ incr_boundvars 1 s));
    1.27 +
    1.28    Context.>> (fn thy => thy |>
    1.29 +    Extraction.add_types
    1.30 +      [("bool", ([], None)),
    1.31 +       ("set", ([realizes_set_proc], Some mk_realizes_set))] |>
    1.32      Extraction.set_preprocessor (fn sg =>
    1.33        Proofterm.rewrite_proof_notypes
    1.34          ([], ("HOL/elim_cong", RewriteHOLProof.elim_cong) ::
    1.35 @@ -189,223 +213,214 @@
    1.36    "P x y \<Longrightarrow> P (fst (x, y)) (snd (x, y))" by simp
    1.37  
    1.38  realizers
    1.39 -  impI (P, Q): "\<lambda>P Q pq. pq"
    1.40 +  impI (P, Q): "\<lambda>pq. pq"
    1.41      "\<Lambda>P Q pq (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
    1.42  
    1.43    impI (P): "Null"
    1.44      "\<Lambda>P Q (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h \<cdot> x))"
    1.45  
    1.46 -  impI (Q): "\<lambda>P Q q. q" "\<Lambda>P Q q. impI \<cdot> _ \<cdot> _"
    1.47 +  impI (Q): "\<lambda>q. q" "\<Lambda>P Q q. impI \<cdot> _ \<cdot> _"
    1.48  
    1.49 -  impI: "Null" "\<Lambda>P Q. impI \<cdot> _ \<cdot> _"
    1.50 +  impI: "Null" "impI"
    1.51  
    1.52 -  mp (P, Q): "\<lambda>P Q pq. pq"
    1.53 +  mp (P, Q): "\<lambda>pq. pq"
    1.54      "\<Lambda>P Q pq (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
    1.55  
    1.56    mp (P): "Null"
    1.57      "\<Lambda>P Q (h: _) p. mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
    1.58  
    1.59 -  mp (Q): "\<lambda>P Q q. q" "\<Lambda>P Q q. mp \<cdot> _ \<cdot> _"
    1.60 +  mp (Q): "\<lambda>q. q" "\<Lambda>P Q q. mp \<cdot> _ \<cdot> _"
    1.61  
    1.62 -  mp: "Null" "\<Lambda>P Q. mp \<cdot> _ \<cdot> _"
    1.63 +  mp: "Null" "mp"
    1.64  
    1.65 -  allI (P): "\<lambda>P p. p" "\<Lambda>P p. allI \<cdot> _"
    1.66 +  allI (P): "\<lambda>p. p" "\<Lambda>P p. allI \<cdot> _"
    1.67  
    1.68 -  allI: "Null" "\<Lambda>P. allI \<cdot> _"
    1.69 +  allI: "Null" "allI"
    1.70  
    1.71 -  spec (P): "\<lambda>P x p. p x" "\<Lambda>P x p. spec \<cdot> _ \<cdot> x"
    1.72 +  spec (P): "\<lambda>x p. p x" "\<Lambda>P x p. spec \<cdot> _ \<cdot> x"
    1.73  
    1.74 -  spec: "Null" "\<Lambda>P x. spec \<cdot> _ \<cdot> x"
    1.75 +  spec: "Null" "spec"
    1.76  
    1.77 -  exI (P): "\<lambda>P x p. (x, p)" "\<Lambda>P. exI_realizer \<cdot> _"
    1.78 +  exI (P): "\<lambda>x p. (x, p)" "\<Lambda>P. exI_realizer \<cdot> _"
    1.79  
    1.80 -  exI: "\<lambda>P x. x" "\<Lambda>P x (h: _). h"
    1.81 +  exI: "\<lambda>x. x" "\<Lambda>P x (h: _). h"
    1.82  
    1.83 -  exE (P, Q): "\<lambda>P Q p pq. pq (fst p) (snd p)"
    1.84 +  exE (P, Q): "\<lambda>p pq. pq (fst p) (snd p)"
    1.85      "\<Lambda>P Q p (h1: _) pq (h2: _). h2 \<cdot> (fst p) \<cdot> (snd p) \<bullet> h1"
    1.86  
    1.87    exE (P): "Null"
    1.88      "\<Lambda>P Q p (h1: _) (h2: _). h2 \<cdot> (fst p) \<cdot> (snd p) \<bullet> h1"
    1.89  
    1.90 -  exE (Q): "\<lambda>P Q x pq. pq x"
    1.91 +  exE (Q): "\<lambda>x pq. pq x"
    1.92      "\<Lambda>P Q x (h1: _) pq (h2: _). h2 \<cdot> x \<bullet> h1"
    1.93  
    1.94    exE: "Null"
    1.95      "\<Lambda>P Q x (h1: _) (h2: _). h2 \<cdot> x \<bullet> h1"
    1.96  
    1.97 -  conjI (P, Q): "\<lambda>P Q p q. (p, q)"
    1.98 -    "\<Lambda>P Q p (h: _) q. conjI_realizer \<cdot>
    1.99 -       (\<lambda>p. realizes p P) \<cdot> p \<cdot> (\<lambda>q. realizes q Q) \<cdot> q \<bullet> h"
   1.100 +  conjI (P, Q): "Pair"
   1.101 +    "\<Lambda>P Q p (h: _) q. conjI_realizer \<cdot> P \<cdot> p \<cdot> Q \<cdot> q \<bullet> h"
   1.102  
   1.103 -  conjI (P): "\<lambda>P Q p. p"
   1.104 +  conjI (P): "\<lambda>p. p"
   1.105      "\<Lambda>P Q p. conjI \<cdot> _ \<cdot> _"
   1.106  
   1.107 -  conjI (Q): "\<lambda>P Q q. q"
   1.108 +  conjI (Q): "\<lambda>q. q"
   1.109      "\<Lambda>P Q (h: _) q. conjI \<cdot> _ \<cdot> _ \<bullet> h"
   1.110  
   1.111 -  conjI: "Null"
   1.112 -    "\<Lambda>P Q. conjI \<cdot> _ \<cdot> _"
   1.113 +  conjI: "Null" "conjI"
   1.114  
   1.115 -  conjunct1 (P, Q): "\<lambda>P Q. fst"
   1.116 +  conjunct1 (P, Q): "fst"
   1.117      "\<Lambda>P Q pq. conjunct1 \<cdot> _ \<cdot> _"
   1.118  
   1.119 -  conjunct1 (P): "\<lambda>P Q p. p"
   1.120 +  conjunct1 (P): "\<lambda>p. p"
   1.121      "\<Lambda>P Q p. conjunct1 \<cdot> _ \<cdot> _"
   1.122  
   1.123    conjunct1 (Q): "Null"
   1.124      "\<Lambda>P Q q. conjunct1 \<cdot> _ \<cdot> _"
   1.125  
   1.126 -  conjunct1: "Null"
   1.127 -    "\<Lambda>P Q. conjunct1 \<cdot> _ \<cdot> _"
   1.128 +  conjunct1: "Null" "conjunct1"
   1.129  
   1.130 -  conjunct2 (P, Q): "\<lambda>P Q. snd"
   1.131 +  conjunct2 (P, Q): "snd"
   1.132      "\<Lambda>P Q pq. conjunct2 \<cdot> _ \<cdot> _"
   1.133  
   1.134    conjunct2 (P): "Null"
   1.135      "\<Lambda>P Q p. conjunct2 \<cdot> _ \<cdot> _"
   1.136  
   1.137 -  conjunct2 (Q): "\<lambda>P Q p. p"
   1.138 +  conjunct2 (Q): "\<lambda>p. p"
   1.139      "\<Lambda>P Q p. conjunct2 \<cdot> _ \<cdot> _"
   1.140  
   1.141 -  conjunct2: "Null"
   1.142 -    "\<Lambda>P Q. conjunct2 \<cdot> _ \<cdot> _"
   1.143 +  conjunct2: "Null" "conjunct2"
   1.144 +
   1.145 +  disjI1 (P, Q): "Inl"
   1.146 +    "\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_1 \<cdot> P \<cdot> _ \<cdot> p)"
   1.147  
   1.148 -  disjI1 (P, Q): "\<lambda>P Q. Inl"
   1.149 -    "\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_1 \<cdot> (\<lambda>p. realizes p P) \<cdot> _ \<cdot> p)"
   1.150 +  disjI1 (P): "Some"
   1.151 +    "\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> P \<cdot> p)"
   1.152  
   1.153 -  disjI1 (P): "\<lambda>P Q. Some"
   1.154 -    "\<Lambda>P Q p. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> (\<lambda>p. realizes p P) \<cdot> p)"
   1.155 -
   1.156 -  disjI1 (Q): "\<lambda>P Q. None"
   1.157 +  disjI1 (Q): "None"
   1.158      "\<Lambda>P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)"
   1.159  
   1.160 -  disjI1: "\<lambda>P Q. Left"
   1.161 +  disjI1: "Left"
   1.162      "\<Lambda>P Q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_1 \<cdot> _ \<cdot> _)"
   1.163  
   1.164 -  disjI2 (P, Q): "\<lambda>Q P. Inr"
   1.165 -    "\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_2 \<cdot> _ \<cdot> (\<lambda>q. realizes q Q) \<cdot> q)"
   1.166 +  disjI2 (P, Q): "Inr"
   1.167 +    "\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sum.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)"
   1.168  
   1.169 -  disjI2 (P): "\<lambda>Q P. None"
   1.170 +  disjI2 (P): "None"
   1.171      "\<Lambda>Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_1 \<cdot> _ \<cdot> _)"
   1.172  
   1.173 -  disjI2 (Q): "\<lambda>Q P. Some"
   1.174 -    "\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> (\<lambda>q. realizes q Q) \<cdot> q)"
   1.175 +  disjI2 (Q): "Some"
   1.176 +    "\<Lambda>Q P q. iffD2 \<cdot> _ \<cdot> _ \<bullet> (option.cases_2 \<cdot> _ \<cdot> Q \<cdot> q)"
   1.177  
   1.178 -  disjI2: "\<lambda>Q P. Right"
   1.179 +  disjI2: "Right"
   1.180      "\<Lambda>Q P. iffD2 \<cdot> _ \<cdot> _ \<bullet> (sumbool.cases_2 \<cdot> _ \<cdot> _)"
   1.181  
   1.182 -  disjE (P, Q, R): "\<lambda>P Q R pq pr qr.
   1.183 +  disjE (P, Q, R): "\<lambda>pq pr qr.
   1.184       (case pq of Inl p \<Rightarrow> pr p | Inr q \<Rightarrow> qr q)"
   1.185      "\<Lambda>P Q R pq (h1: _) pr (h2: _) qr.
   1.186 -       disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes r R) \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.187 +       disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.188  
   1.189 -  disjE (Q, R): "\<lambda>P Q R pq pr qr.
   1.190 +  disjE (Q, R): "\<lambda>pq pr qr.
   1.191       (case pq of None \<Rightarrow> pr | Some q \<Rightarrow> qr q)"
   1.192      "\<Lambda>P Q R pq (h1: _) pr (h2: _) qr.
   1.193 -       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes r R) \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.194 +       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.195  
   1.196 -  disjE (P, R): "\<lambda>P Q R pq pr qr.
   1.197 +  disjE (P, R): "\<lambda>pq pr qr.
   1.198       (case pq of None \<Rightarrow> qr | Some p \<Rightarrow> pr p)"
   1.199      "\<Lambda>P Q R pq (h1: _) pr (h2: _) qr (h3: _).
   1.200 -       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes r R) \<cdot> qr \<cdot> pr \<bullet> h1 \<bullet> h3 \<bullet> h2"
   1.201 +       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> qr \<cdot> pr \<bullet> h1 \<bullet> h3 \<bullet> h2"
   1.202  
   1.203 -  disjE (R): "\<lambda>P Q R pq pr qr.
   1.204 +  disjE (R): "\<lambda>pq pr qr.
   1.205       (case pq of Left \<Rightarrow> pr | Right \<Rightarrow> qr)"
   1.206      "\<Lambda>P Q R pq (h1: _) pr (h2: _) qr.
   1.207 -       disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes r R) \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.208 +       disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> R \<cdot> pr \<cdot> qr \<bullet> h1 \<bullet> h2"
   1.209  
   1.210    disjE (P, Q): "Null"
   1.211 -    "\<Lambda>P Q R pq. disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes Null R) \<cdot> _ \<cdot> _"
   1.212 +    "\<Lambda>P Q R pq. disjE_realizer \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   1.213  
   1.214    disjE (Q): "Null"
   1.215 -    "\<Lambda>P Q R pq. disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes Null R) \<cdot> _ \<cdot> _"
   1.216 +    "\<Lambda>P Q R pq. disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   1.217  
   1.218    disjE (P): "Null"
   1.219      "\<Lambda>P Q R pq (h1: _) (h2: _) (h3: _).
   1.220 -       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes Null R) \<cdot> _ \<cdot> _ \<bullet> h1 \<bullet> h3 \<bullet> h2"
   1.221 +       disjE_realizer2 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _ \<bullet> h1 \<bullet> h3 \<bullet> h2"
   1.222  
   1.223    disjE: "Null"
   1.224 -    "\<Lambda>P Q R pq. disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>r. realizes Null R) \<cdot> _ \<cdot> _"
   1.225 +    "\<Lambda>P Q R pq. disjE_realizer3 \<cdot> _ \<cdot> _ \<cdot> pq \<cdot> (\<lambda>x. R) \<cdot> _ \<cdot> _"
   1.226  
   1.227 -  FalseE (P): "\<lambda>P. arbitrary"
   1.228 +  FalseE (P): "arbitrary"
   1.229      "\<Lambda>P. FalseE \<cdot> _"
   1.230  
   1.231 -  FalseE: "Null"
   1.232 -    "\<Lambda>P. FalseE \<cdot> _"
   1.233 +  FalseE: "Null" "FalseE"
   1.234  
   1.235    notI (P): "Null"
   1.236      "\<Lambda>P (h: _). allI \<cdot> _ \<bullet> (\<Lambda>x. notI \<cdot> _ \<bullet> (h \<cdot> x))"
   1.237  
   1.238 -  notI: "Null"
   1.239 -    "\<Lambda>P. notI \<cdot> _"
   1.240 +  notI: "Null" "notI"
   1.241  
   1.242 -  notE (P, R): "\<lambda>P R p. arbitrary"
   1.243 +  notE (P, R): "\<lambda>p. arbitrary"
   1.244      "\<Lambda>P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   1.245  
   1.246    notE (P): "Null"
   1.247      "\<Lambda>P R (h: _) p. notE \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> h)"
   1.248  
   1.249 -  notE (R): "\<lambda>P R. arbitrary"
   1.250 -    "\<Lambda>P R. notE \<cdot> _ \<cdot> _"
   1.251 -
   1.252 -  notE: "Null"
   1.253 +  notE (R): "arbitrary"
   1.254      "\<Lambda>P R. notE \<cdot> _ \<cdot> _"
   1.255  
   1.256 -  subst (P): "\<lambda>s t P ps. ps"
   1.257 -    "\<Lambda>s t P (h: _) ps. subst \<cdot> s \<cdot> t \<cdot> (\<lambda>x. realizes ps (P x)) \<bullet> h"
   1.258 +  notE: "Null" "notE"
   1.259  
   1.260 -  subst: "Null"
   1.261 -    "\<Lambda>s t P. subst \<cdot> s \<cdot> t \<cdot> (\<lambda>x. realizes Null (P x))"
   1.262 +  subst (P): "\<lambda>s t ps. ps"
   1.263 +    "\<Lambda>s t P (h: _) ps. subst \<cdot> s \<cdot> t \<cdot> P ps \<bullet> h"
   1.264  
   1.265 -  iffD1 (P, Q): "\<lambda>Q P. fst"
   1.266 +  subst: "Null" "subst"
   1.267 +
   1.268 +  iffD1 (P, Q): "fst"
   1.269      "\<Lambda>Q P pq (h: _) p.
   1.270         mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> p \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
   1.271  
   1.272 -  iffD1 (P): "\<lambda>Q P p. p"
   1.273 +  iffD1 (P): "\<lambda>p. p"
   1.274      "\<Lambda>Q P p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h)"
   1.275  
   1.276    iffD1 (Q): "Null"
   1.277      "\<Lambda>Q P q1 (h: _) q2.
   1.278         mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct1 \<cdot> _ \<cdot> _ \<bullet> h))"
   1.279  
   1.280 -  iffD1: "Null"
   1.281 -    "\<Lambda>Q P. iffD1 \<cdot> _ \<cdot> _"
   1.282 +  iffD1: "Null" "iffD1"
   1.283  
   1.284 -  iffD2 (P, Q): "\<lambda>P Q. snd"
   1.285 +  iffD2 (P, Q): "snd"
   1.286      "\<Lambda>P Q pq (h: _) q.
   1.287         mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
   1.288  
   1.289 -  iffD2 (P): "\<lambda>P Q p. p"
   1.290 +  iffD2 (P): "\<lambda>p. p"
   1.291      "\<Lambda>P Q p (h: _). mp \<cdot> _ \<cdot> _ \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h)"
   1.292  
   1.293    iffD2 (Q): "Null"
   1.294      "\<Lambda>P Q q1 (h: _) q2.
   1.295         mp \<cdot> _ \<cdot> _ \<bullet> (spec \<cdot> _ \<cdot> q2 \<bullet> (conjunct2 \<cdot> _ \<cdot> _ \<bullet> h))"
   1.296  
   1.297 -  iffD2: "Null"
   1.298 -    "\<Lambda>P Q. iffD2 \<cdot> _ \<cdot> _"
   1.299 +  iffD2: "Null" "iffD2"
   1.300  
   1.301 -  iffI (P, Q): "\<lambda>P Q pq qp. (pq, qp)"
   1.302 +  iffI (P, Q): "Pair"
   1.303      "\<Lambda>P Q pq (h1 : _) qp (h2 : _). conjI_realizer \<cdot>
   1.304 -       (\<lambda>pq. \<forall>x. realizes x P \<longrightarrow> realizes (pq x) Q) \<cdot> pq \<cdot>
   1.305 -       (\<lambda>qp. \<forall>x. realizes x Q \<longrightarrow> realizes (qp x) P) \<cdot> qp \<bullet>
   1.306 +       (\<lambda>pq. \<forall>x. P x \<longrightarrow> Q (pq x)) \<cdot> pq \<cdot>
   1.307 +       (\<lambda>qp. \<forall>x. Q x \<longrightarrow> P (qp x)) \<cdot> qp \<bullet>
   1.308         (allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
   1.309         (allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
   1.310  
   1.311 -  iffI (P): "\<lambda>P Q p. p"
   1.312 +  iffI (P): "\<lambda>p. p"
   1.313      "\<Lambda>P Q (h1 : _) p (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
   1.314         (allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h1 \<cdot> x))) \<bullet>
   1.315         (impI \<cdot> _ \<cdot> _ \<bullet> h2)"
   1.316  
   1.317 -  iffI (Q): "\<lambda>P Q q. q"
   1.318 +  iffI (Q): "\<lambda>q. q"
   1.319      "\<Lambda>P Q q (h1 : _) (h2 : _). conjI \<cdot> _ \<cdot> _ \<bullet>
   1.320         (impI \<cdot> _ \<cdot> _ \<bullet> h1) \<bullet>
   1.321         (allI \<cdot> _ \<bullet> (\<Lambda>x. impI \<cdot> _ \<cdot> _ \<bullet> (h2 \<cdot> x)))"
   1.322  
   1.323 -  iffI: "Null"
   1.324 -    "\<Lambda>P Q. iffI \<cdot> _ \<cdot> _"
   1.325 +  iffI: "Null" "iffI"
   1.326  
   1.327 +(*
   1.328    classical: "Null"
   1.329      "\<Lambda>P. classical \<cdot> _"
   1.330 +*)
   1.331  
   1.332  end
     2.1 --- a/src/HOL/Tools/datatype_realizer.ML	Mon Nov 25 20:32:29 2002 +0100
     2.2 +++ b/src/HOL/Tools/datatype_realizer.ML	Wed Nov 27 17:06:47 2002 +0100
     2.3 @@ -36,6 +36,9 @@
     2.4  
     2.5  fun is_unit t = snd (strip_type (fastype_of t)) = HOLogic.unitT;
     2.6  
     2.7 +fun tname_of (Type (s, _)) = s
     2.8 +  | tname_of _ = "";
     2.9 +
    2.10  fun mk_realizes T = Const ("realizes", T --> HOLogic.boolT --> HOLogic.boolT);
    2.11  
    2.12  fun make_ind sorts ({descr, rec_names, rec_rewrites, induction, ...} : datatype_info) (is, thy) =
    2.13 @@ -135,19 +138,15 @@
    2.14          ((space_implode "_" (ind_name :: vs @ ["correctness"]), thm), [])
    2.15        |>> Theory.add_path (NameSpace.pack (if_none path []));
    2.16  
    2.17 -    val inst = map (fn ((((i, _), s), T), U) => ((s, 0), if i mem is then
    2.18 -        Abs ("r", U, Abs ("x", T, mk_realizes U $ Bound 1 $
    2.19 -          (Var ((s, 0), T --> HOLogic.boolT) $ Bound 0)))
    2.20 -      else Abs ("x", T, mk_realizes Extraction.nullT $ Extraction.nullt $
    2.21 -        (Var ((s, 0), T --> HOLogic.boolT) $
    2.22 -          Bound 0)))) (descr ~~ pnames ~~ map Type.varifyT recTs ~~
    2.23 -            map Type.varifyT rec_result_Ts);
    2.24 +    val ivs = Drule.vars_of_terms
    2.25 +      [Logic.varify (DatatypeProp.make_ind [descr] sorts)];
    2.26 +    val rvs = Drule.vars_of_terms [prop_of thm'];
    2.27 +    val ivs1 = map Var (filter_out (fn (_, T) =>
    2.28 +      tname_of (body_type T) mem ["set", "bool"]) ivs);
    2.29 +    val ivs2 = map (fn (ixn, _) => Var (ixn, the (assoc (rvs, ixn)))) ivs;
    2.30  
    2.31 -    val ivs = map Var (Drule.vars_of_terms
    2.32 -      [Logic.varify (DatatypeProp.make_ind [descr] sorts)]);
    2.33 -
    2.34 -    val prf = foldr forall_intr_prf (ivs,
    2.35 -      prf_subst_vars inst (foldr (fn ((f, p), prf) =>
    2.36 +    val prf = foldr forall_intr_prf (ivs2,
    2.37 +      foldr (fn ((f, p), prf) =>
    2.38          (case head_of (strip_abs_body f) of
    2.39             Free (s, T) =>
    2.40               let val T' = Type.varifyT T
    2.41 @@ -156,10 +155,10 @@
    2.42               end
    2.43           | _ => AbsP ("H", Some p, prf)))
    2.44             (rec_fns ~~ prems_of thm, Proofterm.proof_combP
    2.45 -             (prf_of thm', map PBound (length prems - 1 downto 0)))));
    2.46 +             (prf_of thm', map PBound (length prems - 1 downto 0))));
    2.47  
    2.48      val r' = if null is then r else Logic.varify (foldr (uncurry lambda)
    2.49 -      (map Logic.unvarify ivs @ filter_out is_unit
    2.50 +      (map Logic.unvarify ivs1 @ filter_out is_unit
    2.51          (map (head_of o strip_abs_body) rec_fns), r));
    2.52  
    2.53    in Extraction.add_realizers_i [(ind_name, (vs, r', prf))] thy' end;
    2.54 @@ -211,24 +210,19 @@
    2.55        |> PureThy.store_thm ((exh_name ^ "_P_correctness", thm), [])
    2.56        |>> Theory.add_path (NameSpace.pack (if_none path []));
    2.57  
    2.58 -    val P = Var (("P", 0), HOLogic.boolT);
    2.59 +    val P = Var (("P", 0), rT' --> HOLogic.boolT);
    2.60      val prf = forall_intr_prf (y, forall_intr_prf (P,
    2.61 -      prf_subst_vars [(("P", 0), Abs ("r", rT',
    2.62 -        mk_realizes rT' $ Bound 0 $ P))] (foldr (fn ((p, r), prf) =>
    2.63 -          forall_intr_prf (Logic.varify r, AbsP ("H", Some (Logic.varify p),
    2.64 -            prf))) (prems ~~ rs, Proofterm.proof_combP (prf_of thm',
    2.65 -              map PBound (length prems - 1 downto 0))))));
    2.66 +      foldr (fn ((p, r), prf) =>
    2.67 +        forall_intr_prf (Logic.varify r, AbsP ("H", Some (Logic.varify p),
    2.68 +          prf))) (prems ~~ rs, Proofterm.proof_combP (prf_of thm',
    2.69 +            map PBound (length prems - 1 downto 0)))));
    2.70      val r' = Logic.varify (Abs ("y", Type.varifyT T,
    2.71 -      Abs ("P", HOLogic.boolT, list_abs (map dest_Free rs, list_comb (r,
    2.72 -        map Bound ((length rs - 1 downto 0) @ [length rs + 1]))))));
    2.73 -
    2.74 -    val prf' = forall_intr_prf (y, forall_intr_prf (P, prf_subst_vars
    2.75 -      [(("P", 0), mk_realizes Extraction.nullT $ Extraction.nullt $ P)]
    2.76 -        (prf_of exhaustion)));
    2.77 +      list_abs (map dest_Free rs, list_comb (r,
    2.78 +        map Bound ((length rs - 1 downto 0) @ [length rs])))));
    2.79  
    2.80    in Extraction.add_realizers_i
    2.81      [(exh_name, (["P"], r', prf)),
    2.82 -     (exh_name, ([], Extraction.nullt, prf'))] thy'
    2.83 +     (exh_name, ([], Extraction.nullt, prf_of exhaustion))] thy'
    2.84    end;
    2.85  
    2.86  
     3.1 --- a/src/HOL/Tools/inductive_realizer.ML	Mon Nov 25 20:32:29 2002 +0100
     3.2 +++ b/src/HOL/Tools/inductive_realizer.ML	Wed Nov 27 17:06:47 2002 +0100
     3.3 @@ -69,22 +69,7 @@
     3.4      map constr_of_intr intrs)
     3.5    end;
     3.6  
     3.7 -fun gen_realizes (Const ("realizes", Type ("fun", [T, _])) $ t $
     3.8 -      (Const ("op :", Type ("fun", [U, _])) $ x $ Var (ixn, _))) =
     3.9 -        Var (ixn, [T, U] ---> HOLogic.boolT) $ t $ x
    3.10 -  | gen_realizes (Const ("op :", Type ("fun", [U, _])) $ x $ Var (ixn, _)) =
    3.11 -      Var (ixn, U --> HOLogic.boolT) $ x
    3.12 -  | gen_realizes (bla as Const ("realizes", Type ("fun", [T, _])) $ t $ P) =
    3.13 -      if T = Extraction.nullT then P
    3.14 -      else (case strip_comb P of
    3.15 -          (Var (ixn, U), ts) => list_comb (Var (ixn, T --> U), t :: ts)
    3.16 -        | _ => error "gen_realizes: variable expected")
    3.17 -  | gen_realizes (t $ u) = gen_realizes t $ gen_realizes u
    3.18 -  | gen_realizes (Abs (s, T, t)) = Abs (s, T, gen_realizes t)
    3.19 -  | gen_realizes t = t;
    3.20 -
    3.21  fun mk_rlz T = Const ("realizes", [T, HOLogic.boolT] ---> HOLogic.boolT);
    3.22 -fun mk_rlz' T = Const ("realizes", [T, propT] ---> propT);
    3.23  
    3.24  (** turn "P" into "%r x. realizes r (P x)" or "%r x. realizes r (x : P)" **)
    3.25  
    3.26 @@ -268,30 +253,26 @@
    3.27  
    3.28  fun mk_realizer thy vs params ((rule, rrule), rt) =
    3.29    let
    3.30 -    val prems = prems_of rule;
    3.31 +    val prems = prems_of rule ~~ prems_of rrule;
    3.32 +    val rvs = map fst (relevant_vars (prop_of rule));
    3.33      val xs = rev (Term.add_vars ([], prop_of rule));
    3.34 -    val rs = gen_rems (op = o pairself fst)
    3.35 -      (rev (Term.add_vars ([], prop_of rrule)), xs);
    3.36 +    val vs1 = map Var (filter_out (fn ((a, _), _) => a mem rvs) xs);
    3.37 +    val rlzvs = rev (Term.add_vars ([], prop_of rrule));
    3.38 +    val vs2 = map (fn (ixn, _) => Var (ixn, the (assoc (rlzvs, ixn)))) xs;
    3.39 +    val rs = gen_rems (op = o pairself fst) (rlzvs, xs);
    3.40  
    3.41      fun mk_prf _ [] prf = prf
    3.42 -      | mk_prf rs (prem :: prems) prf =
    3.43 -          let val T = Extraction.etype_of thy vs [] prem
    3.44 -          in if T = Extraction.nullT
    3.45 -            then AbsP ("H", Some (mk_rlz' T $ Extraction.nullt $ prem),
    3.46 -              mk_prf rs prems prf)
    3.47 -            else forall_intr_prf (Var (hd rs), AbsP ("H", Some (mk_rlz' T $
    3.48 -              Var (hd rs) $ prem), mk_prf (tl rs) prems prf))
    3.49 -          end;
    3.50 -
    3.51 -    val subst = map (fn v as (ixn, _) => (ixn, gen_rvar vs (Var v))) xs;
    3.52 -    val prf = Proofterm.map_proof_terms
    3.53 -      (subst_vars ([], subst)) I (prf_of rrule);
    3.54 +      | mk_prf rs ((prem, rprem) :: prems) prf =
    3.55 +          if Extraction.etype_of thy vs [] prem = Extraction.nullT
    3.56 +          then AbsP ("H", Some rprem, mk_prf rs prems prf)
    3.57 +          else forall_intr_prf (Var (hd rs), AbsP ("H", Some rprem,
    3.58 +            mk_prf (tl rs) prems prf));
    3.59  
    3.60    in (Thm.name_of_thm rule, (vs,
    3.61      if rt = Extraction.nullt then rt else
    3.62 -      foldr (uncurry lambda) (map Var xs, rt),
    3.63 -    foldr forall_intr_prf (map Var xs, mk_prf rs prems (Proofterm.proof_combP
    3.64 -      (prf, map PBound (length prems - 1 downto 0))))))
    3.65 +      foldr (uncurry lambda) (vs1, rt),
    3.66 +    foldr forall_intr_prf (vs2, mk_prf rs prems (Proofterm.proof_combP
    3.67 +      (prf_of rrule, map PBound (length prems - 1 downto 0))))))
    3.68    end;
    3.69  
    3.70  fun add_rule (rss, r) =
    3.71 @@ -348,10 +329,10 @@
    3.72          end
    3.73        else ((recs, dummies), replicate (length rs) Extraction.nullt))
    3.74          ((get #rec_thms dt_info, dummies), rss);
    3.75 -    val rintrs = map (fn (intr, c) => Pattern.eta_contract (gen_realizes
    3.76 +    val rintrs = map (fn (intr, c) => Pattern.eta_contract
    3.77        (Extraction.realizes_of thy2 vs
    3.78          c (prop_of (forall_intr_list (map (cterm_of (sign_of thy2) o Var)
    3.79 -          (rev (Term.add_vars ([], prop_of intr)) \\ params')) intr)))))
    3.80 +          (rev (Term.add_vars ([], prop_of intr)) \\ params')) intr))))
    3.81              (intrs ~~ flat constrss);
    3.82      val rlzsets = distinct (map (fn rintr => snd (HOLogic.dest_mem
    3.83        (HOLogic.dest_Trueprop (Logic.strip_assums_concl rintr)))) rintrs);
    3.84 @@ -377,8 +358,8 @@
    3.85        let
    3.86          val r = indrule_realizer thy induct raw_induct rsets params'
    3.87            (vs @ Ps) rec_names rss intrs dummies;
    3.88 -        val rlz = strip_all (Logic.unvarify (gen_realizes
    3.89 -          (Extraction.realizes_of thy (vs @ Ps) r (prop_of induct))));
    3.90 +        val rlz = strip_all (Logic.unvarify
    3.91 +          (Extraction.realizes_of thy (vs @ Ps) r (prop_of induct)));
    3.92          val rews = map mk_meta_eq
    3.93            (fst_conv :: snd_conv :: get #rec_thms dt_info);
    3.94          val thm = simple_prove_goal_cterm (cterm_of (sign_of thy) rlz) (fn prems =>
    3.95 @@ -416,8 +397,8 @@
    3.96                 [Abs ("x", HOLogic.unitT, Const ("arbitrary", body_type T))]
    3.97               else []) @
    3.98              map Bound ((length prems - 1 downto 0) @ [length prems])));
    3.99 -        val rlz = strip_all (Logic.unvarify (gen_realizes
   3.100 -          (Extraction.realizes_of thy (vs @ Ps) r (prop_of elim))));
   3.101 +        val rlz = strip_all (Logic.unvarify
   3.102 +          (Extraction.realizes_of thy (vs @ Ps) r (prop_of elim)));
   3.103          val rews = map mk_meta_eq case_thms;
   3.104          val thm = simple_prove_goal_cterm (cterm_of (sign_of thy) rlz) (fn prems =>
   3.105            [cut_facts_tac [hd prems] 1,