src/HOL/Tools/Sledgehammer/sledgehammer_isar_preplay.ML
changeset 55266 d9d31354834e
parent 55264 43473497fb65
child 55268 a46458d368d5
equal deleted inserted replaced
55265:bd9f033b9896 55266:d9d31354834e
    20   val enrich_context_with_local_facts : isar_proof -> Proof.context -> Proof.context
    20   val enrich_context_with_local_facts : isar_proof -> Proof.context -> Proof.context
    21   val preplay_isar_step : Proof.context -> Time.time -> proof_method -> isar_step -> play_outcome
    21   val preplay_isar_step : Proof.context -> Time.time -> proof_method -> isar_step -> play_outcome
    22   val set_preplay_outcomes_of_isar_step : Proof.context -> Time.time ->
    22   val set_preplay_outcomes_of_isar_step : Proof.context -> Time.time ->
    23     isar_preplay_data Unsynchronized.ref -> isar_step ->
    23     isar_preplay_data Unsynchronized.ref -> isar_step ->
    24     (proof_method * play_outcome Lazy.lazy) list -> unit
    24     (proof_method * play_outcome Lazy.lazy) list -> unit
    25   val preplay_outcome_of_isar_step : isar_preplay_data -> label -> proof_method ->
    25   val preplay_outcome_of_isar_step_for_method : isar_preplay_data -> label -> proof_method ->
    26     play_outcome Lazy.lazy
    26     play_outcome Lazy.lazy
       
    27   val fastest_method_of_isar_step : isar_preplay_data -> label -> proof_method
    27   val preplay_outcome_of_isar_proof : isar_preplay_data -> isar_proof -> play_outcome
    28   val preplay_outcome_of_isar_proof : isar_preplay_data -> isar_proof -> play_outcome
    28 end;
    29 end;
    29 
    30 
    30 structure Sledgehammer_Isar_Preplay : SLEDGEHAMMER_ISAR_PREPLAY =
    31 structure Sledgehammer_Isar_Preplay : SLEDGEHAMMER_ISAR_PREPLAY =
    31 struct
    32 struct
   178       preplay_data := Canonical_Label_Tab.map_default (l, [])
   179       preplay_data := Canonical_Label_Tab.map_default (l, [])
   179         (fold (AList.update (op =)) meths_outcomes) (!preplay_data)
   180         (fold (AList.update (op =)) meths_outcomes) (!preplay_data)
   180     end
   181     end
   181   | set_preplay_outcomes_of_isar_step _ _ _ _ _ = ()
   182   | set_preplay_outcomes_of_isar_step _ _ _ _ _ = ()
   182 
   183 
   183 fun preplay_outcome_of_isar_step preplay_data l meth =
   184 fun preplay_outcome_of_isar_step_for_method preplay_data l meth =
   184   (case Canonical_Label_Tab.lookup preplay_data l of
   185   let val SOME meths_outcomes = Canonical_Label_Tab.lookup preplay_data l in
   185     SOME meths_outcomes =>
   186     the (AList.lookup (op =) meths_outcomes meth)
   186     (case AList.lookup (op =) meths_outcomes meth of
   187   end
   187       SOME outcome => outcome
   188 
   188     | NONE => raise Fail "Sledgehammer_Isar_Preplay: missing method")
   189 fun fastest_method_of_isar_step preplay_data l =
   189   | NONE => raise Fail "Sledgehammer_Isar_Preplay: missing label")
   190   the (Canonical_Label_Tab.lookup preplay_data l)
   190 
   191   |> map (fn (meth, outcome) =>
   191 fun forced_outcome_of_step preplay_data (Prove (_, _, l, _, _, (_, meth :: _))) =
   192        (meth, Time.toMilliseconds (case Lazy.force outcome of Played time => time | _ => one_year)))
   192     Lazy.force (preplay_outcome_of_isar_step preplay_data l meth)
   193   |> sort (int_ord o pairself snd)
       
   194   |> hd |> fst
       
   195 
       
   196 fun forced_outcome_of_step preplay_data (Prove (_, _, l, _, _, (_, meths))) =
       
   197     Lazy.force (preplay_outcome_of_isar_step_for_method preplay_data l (the_single meths))
   193   | forced_outcome_of_step _ _ = Played Time.zeroTime
   198   | forced_outcome_of_step _ _ = Played Time.zeroTime
   194 
   199 
   195 fun preplay_outcome_of_isar_proof preplay_data (Proof (_, _, steps)) =
   200 fun preplay_outcome_of_isar_proof preplay_data (Proof (_, _, steps)) =
   196   fold_isar_steps (add_preplay_outcomes o forced_outcome_of_step preplay_data) steps
   201   fold_isar_steps (add_preplay_outcomes o forced_outcome_of_step preplay_data) steps
   197     (Played Time.zeroTime)
   202     (Played Time.zeroTime)