src/HOL/Tools/Sledgehammer/sledgehammer_isar_preplay.ML
changeset 55275 e1bf9f0c5420
parent 55272 236114c5eb44
child 55278 73372494fd80
equal deleted inserted replaced
55274:b84867d6550b 55275:e1bf9f0c5420
   182     end
   182     end
   183   | set_preplay_outcomes_of_isar_step _ _ _ _ _ = ()
   183   | set_preplay_outcomes_of_isar_step _ _ _ _ _ = ()
   184 
   184 
   185 fun peek_at_outcome outcome = if Lazy.is_finished outcome then Lazy.force outcome else Not_Played
   185 fun peek_at_outcome outcome = if Lazy.is_finished outcome then Lazy.force outcome else Not_Played
   186 
   186 
       
   187 fun get_best_method_outcome force =
       
   188   tap (List.app (K () o Lazy.future Future.default_params o snd)) (* optional parallelism *)
       
   189   #> map (apsnd force)
       
   190   #> sort (play_outcome_ord o pairself snd)
       
   191   #> hd
       
   192 
   187 fun forced_intermediate_preplay_outcome_of_isar_step preplay_data l =
   193 fun forced_intermediate_preplay_outcome_of_isar_step preplay_data l =
   188   let
   194   let
   189     fun get_best_outcome_available get_one =
   195     val meths_outcomes as (meth1, outcome1) :: _ = the (Canonical_Label_Tab.lookup preplay_data l)
   190       the (Canonical_Label_Tab.lookup preplay_data l)
   196   in
   191       |> map (apsnd get_one)
   197     if forall (not o Lazy.is_finished o snd) meths_outcomes then
   192       |> sort (play_outcome_ord o pairself snd)
   198       (case Lazy.force outcome1 of
   193       |> hd |> snd
   199         outcome as Played _ => outcome
   194   in
   200       | _ => snd (get_best_method_outcome Lazy.force meths_outcomes))
   195     (case get_best_outcome_available peek_at_outcome of
   201     else
   196       Not_Played => get_best_outcome_available Lazy.force
   202       (case get_best_method_outcome peek_at_outcome meths_outcomes of
   197     | outcome => outcome)
   203         (_, Not_Played) => snd (get_best_method_outcome Lazy.force meths_outcomes)
       
   204       | (_, outcome) => outcome)
   198   end
   205   end
   199 
   206 
   200 fun preplay_outcome_of_isar_step_for_method preplay_data l =
   207 fun preplay_outcome_of_isar_step_for_method preplay_data l =
   201   the o AList.lookup (op =) (the (Canonical_Label_Tab.lookup preplay_data l))
   208   the o AList.lookup (op =) (the (Canonical_Label_Tab.lookup preplay_data l))
   202 
   209 
   203 fun fastest_method_of_isar_step preplay_data =
   210 fun fastest_method_of_isar_step preplay_data =
   204   the o Canonical_Label_Tab.lookup preplay_data
   211   the o Canonical_Label_Tab.lookup preplay_data
   205   #> tap (List.app (K () o Lazy.future Future.default_params o snd)) (* optional parallelism *)
   212   #> get_best_method_outcome Lazy.force
   206   #> map (apsnd Lazy.force)
   213   #> fst
   207   #> sort (play_outcome_ord o pairself snd)
       
   208   #> hd #> fst
       
   209 
   214 
   210 fun forced_outcome_of_step preplay_data (Prove (_, _, l, _, _, (_, meths))) =
   215 fun forced_outcome_of_step preplay_data (Prove (_, _, l, _, _, (_, meths))) =
   211     Lazy.force (preplay_outcome_of_isar_step_for_method preplay_data l (the_single meths))
   216     Lazy.force (preplay_outcome_of_isar_step_for_method preplay_data l (the_single meths))
   212   | forced_outcome_of_step _ _ = Played Time.zeroTime
   217   | forced_outcome_of_step _ _ = Played Time.zeroTime
   213 
   218