307 | NONE => (G, visited) |
307 | NONE => (G, visited) |
308 in |
308 in |
309 fst (extend' key (G, [])) |
309 fst (extend' key (G, [])) |
310 end |
310 end |
311 |
311 |
|
312 fun print_intros ctxt gr consts = |
|
313 tracing (cat_lines (map (fn const => |
|
314 "Constant " ^ const ^ "has intros:\n" ^ |
|
315 cat_lines (map (Display.string_of_thm ctxt) (Graph.get_node gr const))) consts)) |
|
316 |
312 fun generate ensure_groundness ctxt const = |
317 fun generate ensure_groundness ctxt const = |
313 let |
318 let |
314 fun strong_conn_of gr keys = |
319 fun strong_conn_of gr keys = |
315 Graph.strong_conn (Graph.subgraph (member (op =) (Graph.all_succs gr keys)) gr) |
320 Graph.strong_conn (Graph.subgraph (member (op =) (Graph.all_succs gr keys)) gr) |
316 val gr = Predicate_Compile_Core.intros_graph_of ctxt |
321 val gr = Predicate_Compile_Core.intros_graph_of ctxt |
317 val gr' = add_edges depending_preds_of const gr |
322 val gr' = add_edges depending_preds_of const gr |
318 val scc = strong_conn_of gr' [const] |
323 val scc = strong_conn_of gr' [const] |
|
324 val _ = print_intros ctxt gr (flat scc) |
319 val constant_table = declare_consts (flat scc) [] |
325 val constant_table = declare_consts (flat scc) [] |
320 in |
326 in |
321 apfst flat (fold_map (translate_intros ensure_groundness ctxt gr) (flat scc) constant_table) |
327 apfst flat (fold_map (translate_intros ensure_groundness ctxt gr) (flat scc) constant_table) |
322 end |
328 end |
323 |
329 |