src/HOL/Tools/ATP/atp_problem_generate.ML
changeset 46443 c86276014571
parent 46442 1e07620d724c
child 46446 45ff234921a3
equal deleted inserted replaced
46442:1e07620d724c 46443:c86276014571
  2704   end
  2704   end
  2705 
  2705 
  2706 val use_topo_for_kbo = false (* experimental *)
  2706 val use_topo_for_kbo = false (* experimental *)
  2707 val default_kbo_weight = 1
  2707 val default_kbo_weight = 1
  2708 
  2708 
       
  2709 fun have_head_rolling (ATerm (s, args)) =
       
  2710     (* ugly hack: may make innocent victims *)
       
  2711     if String.isPrefix app_op_name s andalso length args = 2 then
       
  2712       have_head_rolling (hd args) ||> append (tl args)
       
  2713     else
       
  2714       (s, args)
       
  2715   | have_head_rolling _ = ("", [])
       
  2716 
  2709 fun atp_problem_kbo_weights problem =
  2717 fun atp_problem_kbo_weights problem =
  2710   let
  2718   let
  2711     fun add_term_deps head (ATerm (s, args)) =
  2719     fun add_term_deps head (ATerm (s, args)) =
  2712         is_tptp_user_symbol s ? perhaps (try (Graph.add_edge_acyclic (s, head)))
  2720         is_tptp_user_symbol s ? perhaps (try (Graph.add_edge_acyclic (s, head)))
  2713         #> fold (add_term_deps head) args
  2721         #> fold (add_term_deps head) args
  2714       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2722       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2715     fun add_eq_deps (ATerm (s, [ATerm (head, args as _ :: _), rhs])) =
  2723     fun add_eq_deps (ATerm (s, [lhs as _, rhs])) =
  2716         is_tptp_equal s ? fold (add_term_deps head) (rhs :: args)
  2724         if is_tptp_equal s then
       
  2725           let val (head, rest) = have_head_rolling lhs in
       
  2726             fold (add_term_deps head) (rhs :: rest)
       
  2727           end
       
  2728         else
       
  2729           I
  2717       | add_eq_deps _ = I
  2730       | add_eq_deps _ = I
  2718     fun add_line_deps _ (Decl (_, s, ty)) =
  2731     fun add_line_deps _ (Decl (_, s, ty)) =
  2719         is_function_type ty ? Graph.default_node (s, ())
  2732         is_function_type ty ? Graph.default_node (s, ())
  2720       | add_line_deps status (Formula (_, _, phi, _, info)) =
  2733       | add_line_deps status (Formula (_, _, phi, _, info)) =
  2721         if extract_isabelle_status info = SOME status then
  2734         if extract_isabelle_status info = SOME status then