src/HOL/Tools/Sledgehammer/sledgehammer_isar_compress.ML
changeset 55252 0dc4993b4f56
parent 55250 982e082cd2ba
child 55255 eceebcea3e00
equal deleted inserted replaced
55251:85f5d7da4ab6 55252:0dc4993b4f56
    96 val merge_timeout_slack = 1.25
    96 val merge_timeout_slack = 1.25
    97 
    97 
    98 (* Precondition: The proof must be labeled canonically
    98 (* Precondition: The proof must be labeled canonically
    99    (cf. "Slegehammer_Isar_Proof.relabel_isar_proof_canonically"). *)
    99    (cf. "Slegehammer_Isar_Proof.relabel_isar_proof_canonically"). *)
   100 fun compress_isar_proof compress_isar
   100 fun compress_isar_proof compress_isar
   101     ({preplay_outcome, set_preplay_outcome, preplay_quietly, ...} : isar_preplay_data) proof =
   101     ({preplay_outcome, set_preplay_outcomes, preplay_quietly, ...} : isar_preplay_data) proof =
   102   if compress_isar <= 1.0 then
   102   if compress_isar <= 1.0 then
   103     proof
   103     proof
   104   else
   104   else
   105     let
   105     let
   106       val (compress_further, decrement_step_count) =
   106       val (compress_further, decrement_step_count) =
   135         in
   135         in
   136           (get_successors, replace_successor)
   136           (get_successors, replace_successor)
   137         end
   137         end
   138 
   138 
   139       (* elimination of trivial, one-step subproofs *)
   139       (* elimination of trivial, one-step subproofs *)
   140       fun elim_subproofs' time qs fix l t lfs gfs (meths as meth :: _) subs nontriv_subs =
   140       fun elim_subproofs' time qs fix l t lfs gfs (meths as meth :: meths') subs nontriv_subs =
   141         if null subs orelse not (compress_further ()) then
   141         if null subs orelse not (compress_further ()) then
   142           (set_preplay_outcome l meth (Played time);
   142           (set_preplay_outcomes l ((meth, Lazy.value (Played time)) ::
       
   143              map (rpair (Lazy.value Not_Played)(*FIXME*)) meths');
   143            Prove (qs, fix, l, t, List.revAppend (nontriv_subs, subs), ((lfs, gfs), meths)))
   144            Prove (qs, fix, l, t, List.revAppend (nontriv_subs, subs), ((lfs, gfs), meths)))
   144         else
   145         else
   145           (case subs of
   146           (case subs of
   146             (sub as Proof (_, assms, sub_steps)) :: subs =>
   147             (sub as Proof (_, assms, sub_steps)) :: subs =>
   147             (let
   148             (let
   213           fun try_eliminate (i, l, _) succ_lbls steps =
   214           fun try_eliminate (i, l, _) succ_lbls steps =
   214             let
   215             let
   215               val ((cand as Prove (_, _, l, _, _, ((lfs, _), meth :: _))) :: steps') = drop i steps
   216               val ((cand as Prove (_, _, l, _, _, ((lfs, _), meth :: _))) :: steps') = drop i steps
   216 
   217 
   217               val succs = collect_successors steps' succ_lbls
   218               val succs = collect_successors steps' succ_lbls
   218               val succ_meths = map (hd o snd o the o byline_of_isar_step) succs
   219               val succ_methss = map (snd o the o byline_of_isar_step) succs
       
   220               val succ_meths = map hd succ_methss (* FIXME *)
   219 
   221 
   220               (* only touch steps that can be preplayed successfully *)
   222               (* only touch steps that can be preplayed successfully *)
   221               val Played time = Lazy.force (preplay_outcome l meth)
   223               val Played time = Lazy.force (preplay_outcome l meth)
   222 
   224 
   223               val succs' = map (try_merge cand #> the) succs
   225               val succs' = map (try_merge cand #> the) succs
   242               val true = forall (fn Played _ => true) play_outcomes
   244               val true = forall (fn Played _ => true) play_outcomes
   243 
   245 
   244               val (steps1, _ :: steps2) = chop i steps
   246               val (steps1, _ :: steps2) = chop i steps
   245               (* replace successors with their modified versions *)
   247               (* replace successors with their modified versions *)
   246               val steps2 = update_steps steps2 succs'
   248               val steps2 = update_steps steps2 succs'
       
   249 
       
   250               val succ_meths_outcomess =
       
   251                 map2 (fn meth :: meths => fn outcome => (meth, Lazy.value outcome) ::
       
   252                   map (rpair (Lazy.value Not_Played)(*FIXME*)) meths) succ_methss play_outcomes
   247             in
   253             in
   248               decrement_step_count (); (* candidate successfully eliminated *)
   254               decrement_step_count (); (* candidate successfully eliminated *)
   249               map3 set_preplay_outcome succ_lbls succ_meths play_outcomes;
   255               map2 set_preplay_outcomes succ_lbls succ_meths_outcomess;
   250               map (replace_successor l succ_lbls) lfs;
   256               map (replace_successor l succ_lbls) lfs;
   251               (* removing the step would mess up the indices; replace with dummy step instead *)
   257               (* removing the step would mess up the indices; replace with dummy step instead *)
   252               steps1 @ dummy_isar_step :: steps2
   258               steps1 @ dummy_isar_step :: steps2
   253             end
   259             end
   254             handle Bind => steps
   260             handle Bind => steps