src/HOL/Tools/ATP/atp_proof_reconstruct.ML
changeset 54799 565f9af86d67
parent 54789 6ff7855a6cc2
child 54811 df56a01f5684
equal deleted inserted replaced
54798:287e569eebb2 54799:565f9af86d67
   534       let
   534       let
   535         fun add_sko (Free (s, _)) = String.isPrefix spass_skolem_prefix s ? insert (op =) s
   535         fun add_sko (Free (s, _)) = String.isPrefix spass_skolem_prefix s ? insert (op =) s
   536           | add_sko _ = I
   536           | add_sko _ = I
   537 
   537 
   538         (* union-find would be faster *)
   538         (* union-find would be faster *)
   539         fun add_cycle _ [] = I
   539         fun add_cycle [] = I
   540           | add_cycle name ss =
   540           | add_cycle ss =
   541             fold (fn s => Graph.default_node (s, ())) ss
   541             fold (fn s => Graph.default_node (s, ())) ss
   542             #> fold Graph.add_edge (ss ~~ tl ss @ [hd ss])
   542             #> fold Graph.add_edge (ss ~~ tl ss @ [hd ss])
   543 
   543 
   544         val (input_steps, other_steps) = List.partition (null o #5) proof
   544         val (input_steps, other_steps) = List.partition (null o #5) proof
   545 
   545 
   546         val skoss = map (fn (_, _, t, _, _) => Term.fold_aterms add_sko t []) input_steps
   546         val skoss = map (fn (_, _, t, _, _) => Term.fold_aterms add_sko t []) input_steps
   547         val skoss_input_steps = filter_out (null o fst) (skoss ~~ input_steps)
   547         val skoss_input_steps = filter_out (null o fst) (skoss ~~ input_steps)
   548 
   548         val groups = Graph.strong_conn (fold add_cycle skoss Graph.empty)
   549         val groups =
       
   550           Graph.empty
       
   551           |> fold (fn (skos, (name, _, _, _, _)) => add_cycle name skos) skoss_input_steps
       
   552           |> Graph.strong_conn
       
   553 
   549 
   554         fun step_name_of_group skos = (implode skos, [])
   550         fun step_name_of_group skos = (implode skos, [])
   555         fun in_group group = member (op =) group o hd
   551         fun in_group group = member (op =) group o hd
   556         fun group_of sko = the (find_first (fn group => in_group group sko) groups)
   552         fun group_of sko = the (find_first (fn group => in_group group sko) groups)
   557 
   553 
   580   else
   576   else
   581     proof
   577     proof
   582 
   578 
   583 fun factify_atp_proof fact_names hyp_ts concl_t atp_proof =
   579 fun factify_atp_proof fact_names hyp_ts concl_t atp_proof =
   584   let
   580   let
   585     fun factify_step ((num, ss), role, t, rule, deps) =
   581     fun factify_step ((num, ss), _, t, rule, deps) =
   586       let
   582       let
   587         val (ss', role', t') =
   583         val (ss', role', t') =
   588           (case resolve_conjecture ss of
   584           (case resolve_conjecture ss of
   589             [j] =>
   585             [j] =>
   590             if j = length hyp_ts then ([], Conjecture, concl_t) else ([], Hypothesis, nth hyp_ts j)
   586             if j = length hyp_ts then ([], Conjecture, concl_t) else ([], Hypothesis, nth hyp_ts j)