src/HOL/Library/reflection.ML
author haftmann
Tue Feb 19 19:44:10 2013 +0100 (2013-02-19)
changeset 51188 9b5bf1a9a710
parent 46763 aa9f5c3bcd4c
child 51717 9e7d1c139569
permissions -rw-r--r--
dropped spurious left-over from 0a2371e7ced3
haftmann@29650
     1
(*  Title:      HOL/Library/reflection.ML
haftmann@29650
     2
    Author:     Amine Chaieb, TU Muenchen
wenzelm@20319
     3
wenzelm@20319
     4
A trial for automatical reification.
wenzelm@20319
     5
*)
wenzelm@20319
     6
wenzelm@29269
     7
signature REFLECTION =
wenzelm@29269
     8
sig
wenzelm@20319
     9
  val genreify_tac: Proof.context -> thm list -> term option -> int -> tactic
chaieb@23648
    10
  val reflection_tac: Proof.context -> thm list -> thm list -> term option -> int -> tactic
haftmann@21878
    11
  val gen_reflection_tac: Proof.context -> (cterm -> thm)
chaieb@23648
    12
    -> thm list -> thm list -> term option -> int -> tactic
hoelzl@31810
    13
  val genreif : Proof.context -> thm list -> term -> thm
wenzelm@20319
    14
end;
wenzelm@20319
    15
wenzelm@29269
    16
structure Reflection : REFLECTION =
wenzelm@29269
    17
struct
wenzelm@20319
    18
chaieb@20374
    19
  (* Make a congruence rule out of a defining equation for the interpretation *)
chaieb@20374
    20
  (* th is one defining equation of f, i.e.
chaieb@20374
    21
     th is "f (Cp ?t1 ... ?tn) = P(f ?t1, .., f ?tn)" *)
chaieb@20374
    22
  (* Cp is a constructor pattern and P is a pattern *)
chaieb@20374
    23
chaieb@20374
    24
  (* The result is:
chaieb@20374
    25
      [|?A1 = f ?t1 ; .. ; ?An= f ?tn |] ==> P (?A1, .., ?An) = f (Cp ?t1 .. ?tn) *)
chaieb@20374
    26
  (*  + the a list of names of the A1 .. An, Those are fresh in the ctxt*)
chaieb@20374
    27
hoelzl@31386
    28
fun mk_congeq ctxt fs th =
hoelzl@31386
    29
  let
haftmann@46763
    30
   val Const (fN, _) = th |> prop_of |> HOLogic.dest_Trueprop |> HOLogic.dest_eq
haftmann@29650
    31
     |> fst |> strip_comb |> fst
wenzelm@42361
    32
   val thy = Proof_Context.theory_of ctxt
chaieb@20374
    33
   val cert = Thm.cterm_of thy
wenzelm@31794
    34
   val (((_,_),[th']), ctxt') = Variable.import true [th] ctxt
chaieb@20374
    35
   val (lhs, rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop (Thm.prop_of th'))
hoelzl@31386
    36
   fun add_fterms (t as t1 $ t2) =
wenzelm@29269
    37
       if exists (fn f => Term.could_unify (t |> strip_comb |> fst, f)) fs then insert (op aconv) t
chaieb@20564
    38
       else add_fterms t1 #> add_fterms t2
haftmann@46763
    39
     | add_fterms (t as Abs _) =
wenzelm@29273
    40
       if exists_Const (fn (c, _) => c = fN) t then (fn _ => [t]) else (fn _ => [])
chaieb@20374
    41
     | add_fterms _ = I
chaieb@20374
    42
   val fterms = add_fterms rhs []
wenzelm@20797
    43
   val (xs, ctxt'') = Variable.variant_fixes (replicate (length fterms) "x") ctxt'
chaieb@20374
    44
   val tys = map fastype_of fterms
chaieb@20374
    45
   val vs = map Free (xs ~~ tys)
chaieb@20374
    46
   val env = fterms ~~ vs
wenzelm@32960
    47
                    (* FIXME!!!!*)
chaieb@20564
    48
   fun replace_fterms (t as t1 $ t2) =
chaieb@20374
    49
       (case AList.lookup (op aconv) env t of
wenzelm@32960
    50
            SOME v => v
wenzelm@32960
    51
          | NONE => replace_fterms t1 $ replace_fterms t2)
chaieb@20374
    52
     | replace_fterms t = (case AList.lookup (op aconv) env t of
wenzelm@32960
    53
                               SOME v => v
wenzelm@32960
    54
                             | NONE => t)
hoelzl@31386
    55
chaieb@20374
    56
   fun mk_def (Abs(x,xT,t),v) = HOLogic.mk_Trueprop ((HOLogic.all_const xT)$ Abs(x,xT,HOLogic.mk_eq(v$(Bound 0), t)))
chaieb@20374
    57
     | mk_def (t, v) = HOLogic.mk_Trueprop (HOLogic.mk_eq (v, t))
wenzelm@46510
    58
   fun tryext x = (x RS @{lemma "(\<forall>x. f x = g x) \<Longrightarrow> f = g" by blast} handle THM _ =>  x)
wenzelm@45403
    59
   val cong =
wenzelm@45403
    60
    (Goal.prove ctxt'' [] (map mk_def env)
wenzelm@45403
    61
      (HOLogic.mk_Trueprop (HOLogic.mk_eq (lhs, replace_fterms rhs)))
wenzelm@45403
    62
      (fn {context, prems, ...} =>
wenzelm@45403
    63
        Local_Defs.unfold_tac context (map tryext prems) THEN rtac th' 1)) RS sym
hoelzl@31386
    64
hoelzl@31386
    65
   val (cong' :: vars') =
chaieb@20374
    66
       Variable.export ctxt'' ctxt (cong :: map (Drule.mk_term o cert) vs)
chaieb@20374
    67
   val vs' = map (fst o fst o Term.dest_Var o Thm.term_of o Drule.dest_term) vars'
hoelzl@31386
    68
hoelzl@31386
    69
  in  (vs', cong') end;
wenzelm@20319
    70
 (* congs is a list of pairs (P,th) where th is a theorem for *)
wenzelm@20319
    71
        (* [| f p1 = A1; ...; f pn = An|] ==> f (C p1 .. pn) = P *)
wenzelm@20319
    72
val FWD = curry (op OF);
wenzelm@20319
    73
wenzelm@20319
    74
chaieb@20374
    75
exception REIF of string;
chaieb@20374
    76
hoelzl@31412
    77
fun dest_listT (Type (@{type_name "list"}, [T])) = T;
hoelzl@29834
    78
hoelzl@31386
    79
fun rearrange congs =
hoelzl@31386
    80
  let
hoelzl@31386
    81
    fun P (_, th) =
haftmann@38864
    82
      let val @{term "Trueprop"}$(Const (@{const_name HOL.eq},_) $l$_) = concl_of th
hoelzl@31386
    83
      in can dest_Var l end
hoelzl@31386
    84
    val (yes,no) = List.partition P congs
hoelzl@31386
    85
  in no @ yes end
hoelzl@29834
    86
hoelzl@29834
    87
fun genreif ctxt raw_eqs t =
hoelzl@31386
    88
  let
hoelzl@31412
    89
    fun index_of t bds =
hoelzl@31386
    90
      let
hoelzl@31386
    91
        val tt = HOLogic.listT (fastype_of t)
hoelzl@31386
    92
      in
hoelzl@31387
    93
       (case AList.lookup Type.could_unify bds tt of
hoelzl@31386
    94
          NONE => error "index_of : type not found in environements!"
hoelzl@31386
    95
        | SOME (tbs,tats) =>
hoelzl@31386
    96
          let
haftmann@31986
    97
            val i = find_index (fn t' => t' = t) tats
haftmann@31986
    98
            val j = find_index (fn t' => t' = t) tbs
hoelzl@31387
    99
          in (if j = ~1 then
hoelzl@31387
   100
              if i = ~1
hoelzl@31412
   101
              then (length tbs + length tats,
hoelzl@31412
   102
                    AList.update Type.could_unify (tt,(tbs,tats@[t])) bds)
hoelzl@31412
   103
              else (i, bds) else (j, bds))
hoelzl@31386
   104
          end)
hoelzl@31386
   105
      end;
hoelzl@31386
   106
hoelzl@31386
   107
    (* Generic decomp for reification : matches the actual term with the
hoelzl@31386
   108
       rhs of one cong rule. The result of the matching guides the
hoelzl@31386
   109
       proof synthesis: The matches of the introduced Variables A1 .. An are
hoelzl@31386
   110
       processed recursively
hoelzl@31386
   111
       The rest is instantiated in the cong rule,i.e. no reification is needed *)
chaieb@20564
   112
hoelzl@31386
   113
    (* da is the decomposition for atoms, ie. it returns ([],g) where g
hoelzl@31386
   114
       returns the right instance f (AtC n) = t , where AtC is the Atoms
hoelzl@31386
   115
       constructor and n is the number of the atom corresponding to t *)
hoelzl@31412
   116
    fun decomp_genreif da cgns (t,ctxt) bds =
hoelzl@31386
   117
      let
wenzelm@42361
   118
        val thy = Proof_Context.theory_of ctxt
chaieb@20374
   119
        val cert = cterm_of thy
hoelzl@31412
   120
        fun tryabsdecomp (s,ctxt) bds =
hoelzl@31386
   121
          (case s of
haftmann@46763
   122
             Abs(_, xT, ta) => (
hoelzl@31386
   123
               let
hoelzl@31386
   124
                 val ([xn],ctxt') = Variable.variant_fixes ["x"] ctxt
wenzelm@42284
   125
                 val (xn,ta) = Syntax_Trans.variant_abs (xn,xT,ta)  (* FIXME !? *)
hoelzl@31386
   126
                 val x = Free(xn,xT)
hoelzl@31387
   127
                 val bds = (case AList.lookup Type.could_unify bds (HOLogic.listT xT)
wenzelm@32960
   128
                          of NONE => error "tryabsdecomp: Type not found in the Environement"
hoelzl@31386
   129
                           | SOME (bsT,atsT) =>
hoelzl@31387
   130
                             (AList.update Type.could_unify (HOLogic.listT xT, ((x::bsT), atsT)) bds))
hoelzl@31412
   131
               in (([(ta, ctxt')],
hoelzl@31412
   132
                    fn ([th], bds) =>
wenzelm@36945
   133
                      (hd (Variable.export ctxt' ctxt [(Thm.forall_intr (cert x) th) COMP allI]),
hoelzl@31412
   134
                       let val (bsT,asT) = the(AList.lookup Type.could_unify bds (HOLogic.listT xT))
wenzelm@32960
   135
                       in AList.update Type.could_unify (HOLogic.listT xT,(tl bsT,asT)) bds
wenzelm@32960
   136
                       end)),
hoelzl@31412
   137
                   bds)
hoelzl@31386
   138
               end)
hoelzl@31412
   139
           | _ => da (s,ctxt) bds)
wenzelm@37117
   140
      in
wenzelm@37117
   141
        (case cgns of
hoelzl@31412
   142
          [] => tryabsdecomp (t,ctxt) bds
wenzelm@37117
   143
        | ((vns,cong)::congs) =>
wenzelm@37117
   144
            (let
wenzelm@37117
   145
              val cert = cterm_of thy
wenzelm@37117
   146
              val certy = ctyp_of thy
wenzelm@37117
   147
              val (tyenv, tmenv) =
wenzelm@37117
   148
                Pattern.match thy
wenzelm@37117
   149
                  ((fst o HOLogic.dest_eq o HOLogic.dest_Trueprop) (concl_of cong), t)
wenzelm@37117
   150
                  (Vartab.empty, Vartab.empty)
wenzelm@37117
   151
              val (fnvs,invs) = List.partition (fn ((vn,_),_) => member (op =) vns vn) (Vartab.dest tmenv)
wenzelm@37117
   152
              val (fts,its) =
wenzelm@37117
   153
                (map (snd o snd) fnvs,
wenzelm@37117
   154
                 map (fn ((vn,vi),(tT,t)) => (cert(Var ((vn,vi),tT)), cert t)) invs)
wenzelm@37117
   155
              val ctyenv = map (fn ((vn,vi),(s,ty)) => (certy (TVar((vn,vi),s)), certy ty)) (Vartab.dest tyenv)
wenzelm@37117
   156
            in ((fts ~~ (replicate (length fts) ctxt),
wenzelm@43333
   157
                 Library.apfst (FWD (Drule.instantiate_normalize (ctyenv, its) cong))), bds)
wenzelm@37117
   158
            end handle Pattern.MATCH => decomp_genreif da congs (t,ctxt) bds))
hoelzl@31386
   159
      end;
chaieb@23648
   160
chaieb@23648
   161
 (* looks for the atoms equation and instantiates it with the right number *)
hoelzl@31412
   162
    fun mk_decompatom eqs (t,ctxt) bds = (([], fn (_, bds) =>
hoelzl@31386
   163
      let
hoelzl@31386
   164
        val tT = fastype_of t
hoelzl@31386
   165
        fun isat eq =
hoelzl@31386
   166
          let
hoelzl@31386
   167
            val rhs = eq |> prop_of |> HOLogic.dest_Trueprop |> HOLogic.dest_eq |> snd
hoelzl@31386
   168
          in exists_Const
wenzelm@32960
   169
            (fn (n,ty) => n = @{const_name "List.nth"}
hoelzl@31386
   170
                          andalso
wenzelm@32960
   171
                          AList.defined Type.could_unify bds (domain_type ty)) rhs
hoelzl@31386
   172
            andalso Type.could_unify (fastype_of rhs, tT)
hoelzl@31386
   173
          end
hoelzl@31386
   174
hoelzl@31386
   175
        fun get_nths t acc =
hoelzl@31386
   176
          case t of
hoelzl@31412
   177
            Const(@{const_name "List.nth"},_)$vs$n => insert (fn ((a,_),(b,_)) => a aconv b) (t,(vs,n)) acc
hoelzl@31386
   178
          | t1$t2 => get_nths t1 (get_nths t2 acc)
hoelzl@31386
   179
          | Abs(_,_,t') => get_nths t'  acc
hoelzl@31386
   180
          | _ => acc
chaieb@23548
   181
hoelzl@31386
   182
        fun
hoelzl@31412
   183
           tryeqs [] bds = error "Can not find the atoms equation"
hoelzl@31412
   184
         | tryeqs (eq::eqs) bds = ((
hoelzl@31386
   185
          let
hoelzl@31386
   186
            val rhs = eq |> prop_of |> HOLogic.dest_Trueprop  |> HOLogic.dest_eq |> snd
hoelzl@31386
   187
            val nths = get_nths rhs []
haftmann@46763
   188
            val (vss,_ ) = fold_rev (fn (_, (vs, n)) => fn (vss, ns) =>
haftmann@46763
   189
              (insert (op aconv) vs vss, insert (op aconv) n ns)) nths ([], [])
hoelzl@31386
   190
            val (vsns, ctxt') = Variable.variant_fixes (replicate (length vss) "vs") ctxt
hoelzl@31386
   191
            val (xns, ctxt'') = Variable.variant_fixes (replicate (length nths) "x") ctxt'
wenzelm@42361
   192
            val thy = Proof_Context.theory_of ctxt''
hoelzl@31386
   193
            val cert = cterm_of thy
hoelzl@31386
   194
            val certT = ctyp_of thy
hoelzl@31386
   195
            val vsns_map = vss ~~ vsns
hoelzl@31386
   196
            val xns_map = (fst (split_list nths)) ~~ xns
hoelzl@31386
   197
            val subst = map (fn (nt, xn) => (nt, Var ((xn,0), fastype_of nt))) xns_map
hoelzl@31386
   198
            val rhs_P = subst_free subst rhs
wenzelm@32032
   199
            val (tyenv, tmenv) = Pattern.match thy (rhs_P, t) (Vartab.empty, Vartab.empty)
wenzelm@32035
   200
            val sbst = Envir.subst_term (tyenv, tmenv)
wenzelm@32035
   201
            val sbsT = Envir.subst_type tyenv
hoelzl@31386
   202
            val subst_ty = map (fn (n,(s,t)) => (certT (TVar (n, s)), certT t))
hoelzl@31386
   203
                               (Vartab.dest tyenv)
hoelzl@31386
   204
            val tml = Vartab.dest tmenv
hoelzl@31412
   205
            val (subst_ns, bds) = fold_map
haftmann@46763
   206
                (fn (Const _ $ _ $ n, Var (xn0, _)) => fn bds =>
hoelzl@31387
   207
                  let
hoelzl@31412
   208
                    val name = snd (the (AList.lookup (op =) tml xn0))
hoelzl@31412
   209
                    val (idx, bds) = index_of name bds
hoelzl@31412
   210
                  in ((cert n, idx |> (HOLogic.mk_nat #> cert)), bds) end) subst bds
hoelzl@31386
   211
            val subst_vs =
hoelzl@31386
   212
              let
haftmann@46763
   213
                fun h (Const _ $ (vs as Var (_, lT)) $ _, Var (_, T)) =
hoelzl@31386
   214
                  let
hoelzl@31412
   215
                    val cns = sbst (Const(@{const_name "List.Cons"}, T --> lT --> lT))
hoelzl@31386
   216
                    val lT' = sbsT lT
haftmann@46763
   217
                    val (bsT, _) = the (AList.lookup Type.could_unify bds lT)
hoelzl@31412
   218
                    val vsn = the (AList.lookup (op =) vsns_map vs)
hoelzl@31386
   219
                    val cvs = cert (fold_rev (fn x => fn xs => cns$x$xs) bsT (Free (vsn, lT')))
hoelzl@31386
   220
                  in (cert vs, cvs) end
hoelzl@31386
   221
              in map h subst end
hoelzl@31386
   222
            val cts = map (fn ((vn,vi),(tT,t)) => (cert(Var ((vn,vi),tT)), cert t))
hoelzl@31386
   223
                          (fold (AList.delete (fn (((a: string),_),(b,_)) => a = b))
hoelzl@31386
   224
                                (map (fn n => (n,0)) xns) tml)
hoelzl@31386
   225
            val substt =
hoelzl@31386
   226
              let val ih = Drule.cterm_rule (Thm.instantiate (subst_ty,[]))
hoelzl@31386
   227
              in map (fn (v,t) => (ih v, ih t)) (subst_ns@subst_vs@cts)  end
wenzelm@43333
   228
            val th = (Drule.instantiate_normalize (subst_ty, substt)  eq) RS sym
hoelzl@31412
   229
          in (hd (Variable.export ctxt'' ctxt [th]), bds) end)
wenzelm@37117
   230
          handle Pattern.MATCH => tryeqs eqs bds)
hoelzl@31412
   231
      in tryeqs (filter isat eqs) bds end), bds);
chaieb@20374
   232
wenzelm@20319
   233
  (* Generic reification procedure: *)
wenzelm@20319
   234
  (* creates all needed cong rules and then just uses the theorem synthesis *)
chaieb@20564
   235
hoelzl@31386
   236
    fun mk_congs ctxt raw_eqs =
hoelzl@31386
   237
      let
hoelzl@31386
   238
        val fs = fold_rev (fn eq =>
hoelzl@31386
   239
                           insert (op =) (eq |> prop_of |> HOLogic.dest_Trueprop
hoelzl@31386
   240
                           |> HOLogic.dest_eq |> fst |> strip_comb
hoelzl@31386
   241
                           |> fst)) raw_eqs []
hoelzl@31386
   242
        val tys = fold_rev (fn f => fold (insert (op =)) (f |> fastype_of |> binder_types |> tl)
hoelzl@31386
   243
                            ) fs []
hoelzl@31386
   244
        val (vs, ctxt') = Variable.variant_fixes (replicate (length tys) "vs") ctxt
wenzelm@42361
   245
        val thy = Proof_Context.theory_of ctxt'
hoelzl@31386
   246
        val cert = cterm_of thy
hoelzl@31386
   247
        val vstys = map (fn (t,v) => (t,SOME (cert (Free(v,t)))))
hoelzl@31386
   248
                    (tys ~~ vs)
hoelzl@31386
   249
        val is_Var = can dest_Var
hoelzl@31386
   250
        fun insteq eq vs =
hoelzl@31386
   251
          let
haftmann@46763
   252
            val subst = map (fn (v as Var(_, t)) => (cert v, (the o the) (AList.lookup (op =) vstys t)))
hoelzl@31386
   253
                        (filter is_Var vs)
hoelzl@31386
   254
          in Thm.instantiate ([],subst) eq
hoelzl@31386
   255
          end
chaieb@20564
   256
hoelzl@31387
   257
        val bds = AList.make (fn _ => ([],[])) tys
hoelzl@31386
   258
        val eqs = map (fn eq => eq |> prop_of |> HOLogic.dest_Trueprop
wenzelm@32960
   259
                                   |> HOLogic.dest_eq |> fst |> strip_comb |> snd |> tl
hoelzl@31386
   260
                                   |> (insteq eq)) raw_eqs
hoelzl@31386
   261
        val (ps,congs) = split_list (map (mk_congeq ctxt' fs) eqs)
hoelzl@31412
   262
      in (ps ~~ (Variable.export ctxt' ctxt congs), bds)
hoelzl@31386
   263
      end
hoelzl@31386
   264
hoelzl@31412
   265
    val (congs, bds) = mk_congs ctxt raw_eqs
hoelzl@31387
   266
    val congs = rearrange congs
hoelzl@31412
   267
    val (th, bds) = divide_and_conquer' (decomp_genreif (mk_decompatom raw_eqs) congs) (t,ctxt) bds
hoelzl@31386
   268
    fun is_listVar (Var (_,t)) = can dest_listT t
hoelzl@31386
   269
         | is_listVar _ = false
hoelzl@31386
   270
    val vars = th |> prop_of |> HOLogic.dest_Trueprop |> HOLogic.dest_eq |> snd
wenzelm@32960
   271
                  |> strip_comb |> snd |> filter is_listVar
wenzelm@42361
   272
    val cert = cterm_of (Proof_Context.theory_of ctxt)
haftmann@46763
   273
    val cvs = map (fn (v as Var(_, t)) => (cert v,
hoelzl@31387
   274
                  the (AList.lookup Type.could_unify bds t) |> snd |> HOLogic.mk_list (dest_listT t) |> cert)) vars
wenzelm@43333
   275
    val th' = Drule.instantiate_normalize ([], cvs) th
hoelzl@31386
   276
    val t' = (fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o prop_of) th'
hoelzl@31386
   277
    val th'' = Goal.prove ctxt [] [] (HOLogic.mk_Trueprop (HOLogic.mk_eq (t, t')))
wenzelm@32960
   278
               (fn _ => simp_tac (simpset_of ctxt) 1)
hoelzl@31386
   279
  in FWD trans [th'',th']
hoelzl@31386
   280
  end
wenzelm@20319
   281
chaieb@23648
   282
chaieb@23648
   283
fun genreflect ctxt conv corr_thms raw_eqs t =
hoelzl@31386
   284
  let
hoelzl@31386
   285
    val reifth = genreif ctxt raw_eqs t
hoelzl@31386
   286
    fun trytrans [] = error "No suitable correctness theorem found"
hoelzl@31386
   287
      | trytrans (th::ths) =
hoelzl@31386
   288
           (FWD trans [reifth, th RS sym] handle THM _ => trytrans ths)
hoelzl@31386
   289
    val th = trytrans corr_thms
hoelzl@31386
   290
    val ft = (Thm.dest_arg1 o Thm.dest_arg o Thm.dest_arg o cprop_of) th
hoelzl@31386
   291
    val rth = conv ft
wenzelm@46510
   292
  in
wenzelm@46510
   293
    simplify (HOL_basic_ss addsimps raw_eqs addsimps @{thms nth_Cons_0 nth_Cons_Suc})
hoelzl@31386
   294
             (simplify (HOL_basic_ss addsimps [rth]) th)
hoelzl@31386
   295
  end
wenzelm@20319
   296
wenzelm@42368
   297
fun genreify_tac ctxt eqs to = SUBGOAL (fn (goal, i) =>
wenzelm@20319
   298
  let
wenzelm@42368
   299
    val t = (case to of NONE => HOLogic.dest_Trueprop goal | SOME x => x)
wenzelm@42368
   300
    val th = genreif ctxt eqs t RS ssubst
wenzelm@42368
   301
  in rtac th i end);
wenzelm@20319
   302
wenzelm@20319
   303
    (* Reflection calls reification and uses the correctness *)
bulwahn@43959
   304
        (* theorem assumed to be the head of the list *)
wenzelm@42368
   305
fun gen_reflection_tac ctxt conv corr_thms raw_eqs to = SUBGOAL (fn (goal, i) =>
haftmann@21878
   306
  let
wenzelm@42368
   307
    val t = (case to of NONE => HOLogic.dest_Trueprop goal | SOME x => x)
wenzelm@42368
   308
    val th = genreflect ctxt conv corr_thms raw_eqs t RS ssubst
wenzelm@42368
   309
  in rtac th i THEN TRY (rtac TrueI i) end);  (* FIXME THEN_ALL_NEW !? *)
haftmann@21878
   310
bulwahn@43960
   311
fun reflection_tac ctxt = gen_reflection_tac ctxt
bulwahn@43960
   312
  (Code_Evaluation.dynamic_conv (Proof_Context.theory_of ctxt));
bulwahn@43960
   313
  (*FIXME why Code_Evaluation.dynamic_conv?  very specific...*)
haftmann@29650
   314
wenzelm@20797
   315
end