src/HOL/Tools/Sledgehammer/sledgehammer_isar_minimize.ML
changeset 55280 f0187a12b8f2
parent 55278 73372494fd80
child 55287 ffa306239316
equal deleted inserted replaced
55279:df41d34d1324 55280:f0187a12b8f2
    23 
    23 
    24 open Sledgehammer_Reconstructor
    24 open Sledgehammer_Reconstructor
    25 open Sledgehammer_Isar_Proof
    25 open Sledgehammer_Isar_Proof
    26 open Sledgehammer_Isar_Preplay
    26 open Sledgehammer_Isar_Preplay
    27 
    27 
    28 fun keep_fastest_method_of_isar_step preplay_data
    28 fun keep_fastest_method_of_isar_step preplay_data (Prove (qs, xs, l, t, subproofs, facts, _)) =
    29       (Prove (qs, xs, l, t, subproofs, (facts, _))) =
    29     Prove (qs, xs, l, t, subproofs, facts, [fastest_method_of_isar_step preplay_data l])
    30     Prove (qs, xs, l, t, subproofs, (facts, [fastest_method_of_isar_step preplay_data l]))
       
    31   | keep_fastest_method_of_isar_step _ step = step
    30   | keep_fastest_method_of_isar_step _ step = step
    32 
    31 
    33 val slack = seconds 0.1
    32 val slack = seconds 0.1
    34 
    33 
    35 fun minimize_isar_step_dependencies ctxt preplay_data
    34 fun minimize_isar_step_dependencies ctxt preplay_data
    36       (step as Prove (qs, xs, l, t, subproofs, ((lfs0, gfs0), meths as meth :: _))) =
    35       (step as Prove (qs, xs, l, t, subproofs, (lfs0, gfs0), meths as meth :: _)) =
    37     (case Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth) of
    36     (case Lazy.force (preplay_outcome_of_isar_step_for_method (!preplay_data) l meth) of
    38       Played time =>
    37       Played time =>
    39       let
    38       let
    40         fun mk_step_lfs_gfs lfs gfs = Prove (qs, xs, l, t, subproofs, ((lfs, gfs), meths))
    39         fun mk_step_lfs_gfs lfs gfs = Prove (qs, xs, l, t, subproofs, (lfs, gfs), meths)
    41 
    40 
    42         fun minimize_facts _ time min_facts [] = (time, min_facts)
    41         fun minimize_facts _ time min_facts [] = (time, min_facts)
    43           | minimize_facts mk_step time min_facts (f :: facts) =
    42           | minimize_facts mk_step time min_facts (f :: facts) =
    44             (case preplay_isar_step_for_method ctxt (Time.+ (time, slack)) meth
    43             (case preplay_isar_step_for_method ctxt (Time.+ (time, slack)) meth
    45                 (mk_step (min_facts @ facts)) of
    44                 (mk_step (min_facts @ facts)) of
    74         if Ord_List.member label_ord used l then
    73         if Ord_List.member label_ord used l then
    75           process_used_step step |>> Ord_List.union label_ord used ||> (fn step => step :: accu)
    74           process_used_step step |>> Ord_List.union label_ord used ||> (fn step => step :: accu)
    76         else
    75         else
    77           (used, accu))
    76           (used, accu))
    78     and process_used_step step = step |> postproc_step |> process_used_step_subproofs
    77     and process_used_step step = step |> postproc_step |> process_used_step_subproofs
    79     and process_used_step_subproofs (Prove (qs, xs, l, t, subproofs, ((lfs, gfs), meths))) =
    78     and process_used_step_subproofs (Prove (qs, xs, l, t, subproofs, (lfs, gfs), meths)) =
    80       let
    79       let
    81         val (used, subproofs) =
    80         val (used, subproofs) =
    82           map process_proof subproofs
    81           map process_proof subproofs
    83           |> split_list
    82           |> split_list
    84           |>> Ord_List.unions label_ord
    83           |>> Ord_List.unions label_ord
    85           |>> fold (Ord_List.insert label_ord) lfs
    84           |>> fold (Ord_List.insert label_ord) lfs
    86         val step = Prove (qs, xs, l, t, subproofs, ((lfs, gfs), meths))
       
    87       in
    85       in
    88         (used, step)
    86         (used, Prove (qs, xs, l, t, subproofs, (lfs, gfs), meths))
    89       end
    87       end
    90   in
    88   in
    91     snd o process_proof
    89     snd o process_proof
    92   end
    90   end
    93 
    91