src/HOL/Tools/ATP/atp_problem_generate.ML
changeset 47032 73cdeed236c0
parent 47030 7e80e14247fc
child 47038 2409b484e1cc
equal deleted inserted replaced
47031:26dd49368db6 47032:73cdeed236c0
  2744             [explicit_declsN, class_relsN, aritiesN]
  2744             [explicit_declsN, class_relsN, aritiesN]
  2745     |> Symtab.dest
  2745     |> Symtab.dest
  2746     |> sort (prod_ord Real.compare string_ord o pairself swap)
  2746     |> sort (prod_ord Real.compare string_ord o pairself swap)
  2747   end
  2747   end
  2748 
  2748 
  2749 fun have_head_rolling (ATerm (s, args)) =
  2749 fun make_head_roll (ATerm (s, args)) =
  2750     (* ugly hack: may make innocent victims *)
  2750     (* ugly hack: may make innocent victims (collateral damage) *)
  2751     if String.isPrefix app_op_name s andalso length args = 2 then
  2751     if String.isPrefix app_op_name s andalso length args = 2 then
  2752       have_head_rolling (hd args) ||> append (tl args)
  2752       make_head_roll (hd args) ||> append (tl args)
  2753     else
  2753     else
  2754       (s, args)
  2754       (s, args)
  2755   | have_head_rolling _ = ("", [])
  2755   | make_head_roll _ = ("", [])
  2756 
  2756 
  2757 val max_term_order_weight = 2147483647
  2757 val max_term_order_weight = 2147483647
  2758 
  2758 
  2759 fun atp_problem_term_order_weights problem =
  2759 fun atp_problem_term_order_weights problem =
  2760   let
  2760   let
  2762         is_tptp_user_symbol s ? perhaps (try (Graph.add_edge_acyclic (s, head)))
  2762         is_tptp_user_symbol s ? perhaps (try (Graph.add_edge_acyclic (s, head)))
  2763         #> fold (add_term_deps head) args
  2763         #> fold (add_term_deps head) args
  2764       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2764       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2765     fun add_eq_deps (ATerm (s, [lhs as _, rhs])) =
  2765     fun add_eq_deps (ATerm (s, [lhs as _, rhs])) =
  2766         if is_tptp_equal s then
  2766         if is_tptp_equal s then
  2767           let val (head, rest) = have_head_rolling lhs in
  2767           let val (head, rest) = make_head_roll lhs in
  2768             fold (add_term_deps head) (rhs :: rest)
  2768             fold (add_term_deps head) (rhs :: rest)
  2769           end
  2769           end
  2770         else
  2770         else
  2771           I
  2771           I
  2772       | add_eq_deps _ = I
  2772       | add_eq_deps _ = I