src/HOL/ex/reflection.ML
changeset 21878 cfc07819bb47
parent 21757 093ca3efb132
child 22199 b617ddd200eb
equal deleted inserted replaced
21877:e871f57b1adb 21878:cfc07819bb47
     6 *)
     6 *)
     7 
     7 
     8 signature REFLECTION = sig
     8 signature REFLECTION = sig
     9   val genreify_tac: Proof.context -> thm list -> term option -> int -> tactic
     9   val genreify_tac: Proof.context -> thm list -> term option -> int -> tactic
    10   val reflection_tac: Proof.context -> thm list -> term option -> int -> tactic
    10   val reflection_tac: Proof.context -> thm list -> term option -> int -> tactic
       
    11   val gen_reflection_tac: Proof.context -> (cterm -> thm)
       
    12     -> thm list -> term option -> int -> tactic
    11 end;
    13 end;
    12 
    14 
    13 structure Reflection : REFLECTION
    15 structure Reflection : REFLECTION
    14 = struct
    16 = struct
    15 
    17 
   277 			(fn _ => Simp_tac 1)
   279 			(fn _ => Simp_tac 1)
   278   val _ = bds := []
   280   val _ = bds := []
   279  in FWD trans [th'',th']
   281  in FWD trans [th'',th']
   280  end;
   282  end;
   281 
   283 
   282 fun genreflect ctxt corr_thm raw_eqs t =
   284 fun genreflect ctxt conv corr_thm raw_eqs t =
   283     let val th = FWD trans [genreif ctxt raw_eqs t, corr_thm RS sym]
   285     let val th = FWD trans [genreif ctxt raw_eqs t, corr_thm RS sym]
   284         val ft = (snd o Thm.dest_comb o snd o Thm.dest_comb o snd o Thm.dest_comb o cprop_of) th
   286         val ft = (snd o Thm.dest_comb o snd o Thm.dest_comb o snd o Thm.dest_comb o cprop_of) th
   285         val rth = NBE.normalization_conv ft
   287         val rth = conv ft
   286     in simplify (HOL_basic_ss addsimps raw_eqs addsimps [nth_Cons_0, nth_Cons_Suc])
   288     in simplify (HOL_basic_ss addsimps raw_eqs addsimps [nth_Cons_0, nth_Cons_Suc])
   287                 (simplify (HOL_basic_ss addsimps [rth]) th)
   289                 (simplify (HOL_basic_ss addsimps [rth]) th)
   288     end
   290     end
   289 
   291 
   290 fun genreify_tac ctxt eqs to i = (fn st =>
   292 fun genreify_tac ctxt eqs to i = (fn st =>
   295   in rtac th i st
   297   in rtac th i st
   296   end);
   298   end);
   297 
   299 
   298     (* Reflection calls reification and uses the correctness *)
   300     (* Reflection calls reification and uses the correctness *)
   299         (* theorem assumed to be the dead of the list *)
   301         (* theorem assumed to be the dead of the list *)
   300  fun reflection_tac ctxt (corr_thm::raw_eqs) to i =
   302 fun gen_reflection_tac ctxt conv (corr_thm :: raw_eqs) to i = (fn st =>
   301     (fn st =>
   303   let
   302         let val P = (HOLogic.dest_Trueprop (List.nth (prems_of st, i - 1)))
   304     val P = HOLogic.dest_Trueprop (nth (prems_of st) (i - 1));
   303             val t = (case to of NONE => P | SOME x => x)
   305     val t = the_default P to;
   304             val th = (genreflect ctxt corr_thm raw_eqs t) RS ssubst
   306     val th = genreflect ctxt conv corr_thm raw_eqs t
   305         in rtac th i st end);
   307       RS ssubst;
       
   308   in rtac th i st end);
       
   309 
       
   310 fun reflection_tac ctxt = gen_reflection_tac ctxt NBE.normalization_conv;
   306 
   311 
   307 end
   312 end