666 |
666 |
667 fun timing_estimate elem = |
667 fun timing_estimate elem = |
668 let val trs = tl (Thy_Syntax.flat_element elem) |
668 let val trs = tl (Thy_Syntax.flat_element elem) |
669 in fold (fn tr => fn t => get_timing tr + t) trs Time.zeroTime end; |
669 in fold (fn tr => fn t => get_timing tr + t) trs Time.zeroTime end; |
670 |
670 |
671 fun proof_future_enabled estimate st = |
671 fun future_proofs_enabled estimate st = |
672 (case try proof_of st of |
672 (case try proof_of st of |
673 NONE => false |
673 NONE => false |
674 | SOME state => |
674 | SOME state => |
675 not (Proof.is_relevant state) andalso |
675 not (Proof.is_relevant state) andalso |
676 (if can (Proof.assert_bottom true) state |
676 (if can (Proof.assert_bottom true) state |
677 then Goal.future_enabled 1 |
677 then Future.proofs_enabled 1 |
678 else Goal.future_enabled 2 orelse Goal.future_enabled_timing estimate)); |
678 else Future.proofs_enabled 2 orelse Future.proofs_enabled_timing estimate)); |
679 |
679 |
680 fun atom_result keywords tr st = |
680 fun atom_result keywords tr st = |
681 let |
681 let |
682 val st' = |
682 val st' = |
683 if Goal.future_enabled 1 andalso Keyword.is_diag keywords (name_of tr) then |
683 if Future.proofs_enabled 1 andalso Keyword.is_diag keywords (name_of tr) then |
684 (Execution.fork |
684 (Execution.fork |
685 {name = "Toplevel.diag", pos = pos_of tr, pri = ~1} |
685 {name = "Toplevel.diag", pos = pos_of tr, pri = ~1} |
686 (fn () => command tr st); st) |
686 (fn () => command tr st); st) |
687 else command tr st; |
687 else command tr st; |
688 in (Result (tr, st'), st') end; |
688 in (Result (tr, st'), st') end; |
694 let |
694 let |
695 val (head_result, st') = atom_result keywords head_tr st; |
695 val (head_result, st') = atom_result keywords head_tr st; |
696 val (body_elems, end_tr) = element_rest; |
696 val (body_elems, end_tr) = element_rest; |
697 val estimate = timing_estimate elem; |
697 val estimate = timing_estimate elem; |
698 in |
698 in |
699 if not (proof_future_enabled estimate st') |
699 if not (future_proofs_enabled estimate st') |
700 then |
700 then |
701 let |
701 let |
702 val proof_trs = maps Thy_Syntax.flat_element body_elems @ [end_tr]; |
702 val proof_trs = maps Thy_Syntax.flat_element body_elems @ [end_tr]; |
703 val (proof_results, st'') = fold_map (atom_result keywords) proof_trs st'; |
703 val (proof_results, st'') = fold_map (atom_result keywords) proof_trs st'; |
704 in (Result_List (head_result :: proof_results), st'') end |
704 in (Result_List (head_result :: proof_results), st'') end |