src/Pure/meta_simplifier.ML
changeset 26626 c6231d64d264
parent 26424 a6cad32a27b0
child 26939 1035c89b4c02
equal deleted inserted replaced
26625:e0cc4169626e 26626:c6231d64d264
   456     orelse
   456     orelse
   457   is_Const lhs andalso not (is_Const rhs);
   457   is_Const lhs andalso not (is_Const rhs);
   458 
   458 
   459 fun decomp_simp thm =
   459 fun decomp_simp thm =
   460   let
   460   let
   461     val {thy, prop, ...} = Thm.rep_thm thm;
   461     val thy = Thm.theory_of_thm thm;
       
   462     val prop = Thm.prop_of thm;
   462     val prems = Logic.strip_imp_prems prop;
   463     val prems = Logic.strip_imp_prems prop;
   463     val concl = Drule.strip_imp_concl (Thm.cprop_of thm);
   464     val concl = Drule.strip_imp_concl (Thm.cprop_of thm);
   464     val (lhs, rhs) = Thm.dest_equals concl handle TERM _ =>
   465     val (lhs, rhs) = Thm.dest_equals concl handle TERM _ =>
   465       raise SIMPLIFIER ("Rewrite rule not a meta-equality", thm);
   466       raise SIMPLIFIER ("Rewrite rule not a meta-equality", thm);
   466     val elhs = Thm.dest_arg (Thm.cprop_of (Thm.eta_conversion lhs));
   467     val elhs = Thm.dest_arg (Thm.cprop_of (Thm.eta_conversion lhs));
   831     val thm'' = transitive thm thm' handle THM _ =>
   832     val thm'' = transitive thm thm' handle THM _ =>
   832      transitive thm (transitive
   833      transitive thm (transitive
   833        (symmetric (Drule.beta_eta_conversion (Thm.lhs_of thm'))) thm')
   834        (symmetric (Drule.beta_eta_conversion (Thm.lhs_of thm'))) thm')
   834   in if msg then trace_thm (fn () => "SUCCEEDED") ss thm' else (); SOME thm'' end
   835   in if msg then trace_thm (fn () => "SUCCEEDED") ss thm' else (); SOME thm'' end
   835   handle THM _ =>
   836   handle THM _ =>
   836     let val {thy, prop = _ $ _ $ prop0, ...} = Thm.rep_thm thm in
   837     let
       
   838       val thy = Thm.theory_of_thm thm;
       
   839       val _ $ _ $ prop0 = Thm.prop_of thm;
       
   840     in
   837       trace_thm (fn () => "Proved wrong thm (Check subgoaler?)") ss thm';
   841       trace_thm (fn () => "Proved wrong thm (Check subgoaler?)") ss thm';
   838       trace_term false (fn () => "Should have proved:") ss thy prop0;
   842       trace_term false (fn () => "Should have proved:") ss thy prop0;
   839       NONE
   843       NONE
   840     end;
   844     end;
   841 
   845 
   895     val eta_thm = Thm.eta_conversion t;
   899     val eta_thm = Thm.eta_conversion t;
   896     val eta_t' = Thm.rhs_of eta_thm;
   900     val eta_t' = Thm.rhs_of eta_thm;
   897     val eta_t = term_of eta_t';
   901     val eta_t = term_of eta_t';
   898     fun rew {thm, name, lhs, elhs, extra, fo, perm} =
   902     fun rew {thm, name, lhs, elhs, extra, fo, perm} =
   899       let
   903       let
   900         val {thy, prop, maxidx, ...} = rep_thm thm;
   904         val thy = Thm.theory_of_thm thm;
       
   905         val {prop, maxidx, ...} = rep_thm thm;
   901         val (rthm, elhs') =
   906         val (rthm, elhs') =
   902           if maxt = ~1 orelse not extra then (thm, elhs)
   907           if maxt = ~1 orelse not extra then (thm, elhs)
   903           else (Thm.incr_indexes (maxt + 1) thm, Thm.incr_indexes_cterm (maxt + 1) elhs);
   908           else (Thm.incr_indexes (maxt + 1) thm, Thm.incr_indexes_cterm (maxt + 1) elhs);
   904         val insts =
   909         val insts =
   905           if fo then Thm.first_order_match (elhs', eta_t')
   910           if fo then Thm.first_order_match (elhs', eta_t')
  1231     end
  1236     end
  1232   else ();
  1237   else ();
  1233 
  1238 
  1234 fun rewrite_cterm mode prover raw_ss raw_ct =
  1239 fun rewrite_cterm mode prover raw_ss raw_ct =
  1235   let
  1240   let
       
  1241     val thy = Thm.theory_of_cterm raw_ct;
  1236     val ct = Thm.adjust_maxidx_cterm ~1 raw_ct;
  1242     val ct = Thm.adjust_maxidx_cterm ~1 raw_ct;
  1237     val {thy, t, maxidx, ...} = Thm.rep_cterm ct;
  1243     val {t, maxidx, ...} = Thm.rep_cterm ct;
  1238     val ss = inc_simp_depth (activate_context thy raw_ss);
  1244     val ss = inc_simp_depth (activate_context thy raw_ss);
  1239     val depth = simp_depth ss;
  1245     val depth = simp_depth ss;
  1240     val _ =
  1246     val _ =
  1241       if depth mod 20 = 0 then
  1247       if depth mod 20 = 0 then
  1242         warning ("Simplification depth " ^ string_of_int depth)
  1248         warning ("Simplification depth " ^ string_of_int depth)