145 |> set_successors dest |
145 |> set_successors dest |
146 in |
146 in |
147 (get_successors, replace_successor) |
147 (get_successors, replace_successor) |
148 end |
148 end |
149 |
149 |
|
150 fun reference_time l = |
|
151 (case forced_intermediate_preplay_outcome_of_isar_step (!preplay_data) l of |
|
152 Played time => time |
|
153 | _ => preplay_timeout) |
|
154 |
150 (* elimination of trivial, one-step subproofs *) |
155 (* elimination of trivial, one-step subproofs *) |
151 fun elim_one_subproof time (step as Prove (qs, fix, l, t, _, (lfs, gfs), meths, comment)) subs |
156 fun elim_one_subproof time (step as Prove (qs, fix, l, t, _, (lfs, gfs), meths, comment)) subs |
152 nontriv_subs = |
157 nontriv_subs = |
153 if null subs orelse not (compress_further ()) then |
158 if null subs orelse not (compress_further ()) then |
154 Prove (qs, fix, l, t, List.revAppend (nontriv_subs, subs), (lfs, gfs), meths, comment) |
159 Prove (qs, fix, l, t, List.revAppend (nontriv_subs, subs), (lfs, gfs), meths, comment) |
155 else |
160 else |
156 (case subs of |
161 (case subs of |
157 (sub as Proof (_, assms, sub_steps)) :: subs => |
162 (sub as Proof (_, assms, [Prove (_, _, l', _, [], (lfs', gfs'), meths', _)])) :: subs => |
158 (let |
163 let |
159 (* trivial subproofs have exactly one "Prove" step *) |
|
160 val [Prove (_, _, l', _, [], (lfs', gfs'), meths', _)] = sub_steps |
|
161 |
|
162 (* only touch proofs that can be preplayed sucessfully *) |
|
163 val Played time' = forced_intermediate_preplay_outcome_of_isar_step (!preplay_data) l' |
|
164 |
|
165 (* merge steps *) |
164 (* merge steps *) |
166 val subs'' = subs @ nontriv_subs |
165 val subs'' = subs @ nontriv_subs |
167 val lfs'' = union (op =) lfs (subtract (op =) (map fst assms) lfs') |
166 val lfs'' = union (op =) lfs (subtract (op =) (map fst assms) lfs') |
168 val gfs'' = union (op =) gfs' gfs |
167 val gfs'' = union (op =) gfs' gfs |
169 val (meths'' as _ :: _, hopeless) = |
168 val (meths'' as _ :: _, hopeless) = |
170 merge_methods (!preplay_data) (l', meths') (l, meths) |
169 merge_methods (!preplay_data) (l', meths') (l, meths) |
171 val step'' = Prove (qs, fix, l, t, subs'', (lfs'', gfs''), meths'', comment) |
170 val step'' = Prove (qs, fix, l, t, subs'', (lfs'', gfs''), meths'', comment) |
172 |
171 |
173 (* check if the modified step can be preplayed fast enough *) |
172 (* check if the modified step can be preplayed fast enough *) |
174 val timeout = adjust_merge_timeout preplay_timeout (Time.+ (time, time')) |
173 val timeout = adjust_merge_timeout preplay_timeout (Time.+ (time, reference_time l')) |
175 val meths_outcomes as (_, Played time'') :: _ = |
|
176 preplay_isar_step ctxt timeout hopeless step'' |
|
177 in |
174 in |
178 (* l' successfully eliminated *) |
175 (case preplay_isar_step ctxt timeout hopeless step'' of |
179 decrement_step_count (); |
176 meths_outcomes as (_, Played time'') :: _ => |
180 set_preplay_outcomes_of_isar_step ctxt time'' preplay_data step'' meths_outcomes; |
177 (* l' successfully eliminated *) |
181 map (replace_successor l' [l]) lfs'; |
178 (decrement_step_count (); |
182 elim_one_subproof time'' step'' subs nontriv_subs |
179 set_preplay_outcomes_of_isar_step ctxt time'' preplay_data step'' meths_outcomes; |
|
180 map (replace_successor l' [l]) lfs'; |
|
181 elim_one_subproof time'' step'' subs nontriv_subs) |
|
182 | _ => elim_one_subproof time step subs (sub :: nontriv_subs)) |
183 end |
183 end |
184 handle Bind => elim_one_subproof time step subs (sub :: nontriv_subs)) |
184 | sub :: subs => elim_one_subproof time step subs (sub :: nontriv_subs)) |
185 | _ => raise Fail "Sledgehammer_Isar_Compress: elim_one_subproof") |
185 |
186 |
186 fun elim_subproofs (step as Prove (_, _, l, _, subproofs, _, _, _)) = |
187 fun elim_subproofs (step as Prove (_, _, l, _, subproofs as _ :: _, _, _, _)) = |
187 if exists (null o tl o steps_of_isar_proof) subproofs then |
188 (case forced_intermediate_preplay_outcome_of_isar_step (!preplay_data) l of |
188 elim_one_subproof (reference_time l) step subproofs [] |
189 Played time => elim_one_subproof time step subproofs [] |
189 else |
190 | _ => step) |
190 step |
191 | elim_subproofs step = step |
191 | elim_subproofs step = step |
192 |
192 |
193 fun compress_top_level steps = |
193 fun compress_top_level steps = |
194 let |
194 let |
195 fun cand_key (l, t_size) = (length (get_successors l), t_size) |
195 fun cand_key (l, t_size) = (length (get_successors l), t_size) |