changeset 57764 | cac309e2b1f7 |
parent 57760 | 7f11f325c47d |
child 57766 | 77b48e7c0d89 |
57763:e913a87bd5d2 | 57764:cac309e2b1f7 |
---|---|
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 val cand_key = apfst (length o get_successors) |
196 val cand_ord = prod_ord int_ord (int_ord o swap) o pairself cand_key |
196 val cand_ord = |
197 prod_ord int_ord (prod_ord (int_ord o swap) (int_ord o swap)) o pairself cand_key |
|
197 |
198 |
198 fun pop_next_candidate [] = (NONE, []) |
199 fun pop_next_candidate [] = (NONE, []) |
199 | pop_next_candidate (cands as (cand :: cands')) = |
200 | pop_next_candidate (cands as (cand :: cands')) = |
200 fold (fn x => fn y => if cand_ord (x, y) = LESS then x else y) cands' cand |
201 fold (fn x => fn y => if cand_ord (x, y) = LESS then x else y) cands' cand |
201 |> (fn best => (SOME best, remove (op =) best cands)) |
202 |> (fn best => (SOME best, remove (op =) best cands)) |
246 steps |
247 steps |
247 |> not (null successors) ? try_eliminate i l successors |
248 |> not (null successors) ? try_eliminate i l successors |
248 |> compression_loop candidates' |
249 |> compression_loop candidates' |
249 end)) |
250 end)) |
250 |
251 |
251 fun add_cand (Prove (_, _, l, t, _, _, _, _)) = cons (l, size_of_term t) |
252 fun add_cand (Prove (_, xs, l, t, _, _, _, _)) = cons (l, (length xs, size_of_term t)) |
252 | add_cand _ = I |
253 | add_cand _ = I |
253 |
254 |
254 (* the very last step is not a candidate *) |
255 (* the very last step is not a candidate *) |
255 val candidates = fold add_cand (fst (split_last steps)) [] |
256 val candidates = fold add_cand (fst (split_last steps)) [] |
256 in |
257 in |