src/HOL/Tools/ATP/atp_problem_generate.ML
changeset 47039 1b36a05a070d
parent 47038 2409b484e1cc
child 47046 62ca06cc5a99
equal deleted inserted replaced
47038:2409b484e1cc 47039:1b36a05a070d
  1937           | IAbs ((name, T), tm) =>
  1937           | IAbs ((name, T), tm) =>
  1938             if is_type_enc_higher_order type_enc then
  1938             if is_type_enc_higher_order type_enc then
  1939               AAbs ((name, ho_type_from_typ format type_enc true 0 T),
  1939               AAbs ((name, ho_type_from_typ format type_enc true 0 T),
  1940                     term Elsewhere tm)
  1940                     term Elsewhere tm)
  1941             else
  1941             else
  1942               ATerm (("LAMBDA", "LAMBDA"), []) (*###*)
       
  1943 (*###
       
  1944               raise Fail "unexpected lambda-abstraction"
  1942               raise Fail "unexpected lambda-abstraction"
  1945 *)
       
  1946           | IApp _ => raise Fail "impossible \"IApp\""
  1943           | IApp _ => raise Fail "impossible \"IApp\""
  1947         val T = ityp_of u
  1944         val T = ityp_of u
  1948       in
  1945       in
  1949         if should_tag_with_type ctxt mono type_enc site u T then
  1946         if should_tag_with_type ctxt mono type_enc site u T then
  1950           tag_with_type ctxt format mono type_enc pos T t
  1947           tag_with_type ctxt format mono type_enc pos T t
  2762       #> Graph.add_edge_acyclic (s, s')
  2759       #> Graph.add_edge_acyclic (s, s')
  2763     fun add_term_deps head (ATerm (s, args)) =
  2760     fun add_term_deps head (ATerm (s, args)) =
  2764         is_tptp_user_symbol s ? perhaps (try (add_edge s head))
  2761         is_tptp_user_symbol s ? perhaps (try (add_edge s head))
  2765         #> fold (add_term_deps head) args
  2762         #> fold (add_term_deps head) args
  2766       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2763       | add_term_deps head (AAbs (_, tm)) = add_term_deps head tm
  2767     fun add_eq_deps (ATerm (s, [lhs as _, rhs])) =
  2764     fun add_eq_deps (SOME true) (ATerm (s, [lhs as _, rhs])) =
  2768         if is_tptp_equal s then
  2765         if is_tptp_equal s then
  2769           case make_head_roll lhs of
  2766           case make_head_roll lhs of
  2770             (head, rest as _ :: _) =>
  2767             (head, rest as _ :: _) =>
  2771             is_tptp_user_symbol head ? fold (add_term_deps head) (rhs :: rest)
  2768             is_tptp_user_symbol head ? fold (add_term_deps head) (rhs :: rest)
  2772           | _ => I
  2769           | _ => I
  2773         else
  2770         else
  2774           I
  2771           I
  2775       | add_eq_deps _ = I
  2772       | add_eq_deps _ _ = I
  2776     fun add_line_deps _ (Decl _) = I
  2773     fun add_deps pred (Formula (_, role, phi, _, info)) =
  2777       | add_line_deps status (Formula (_, _, phi, _, info)) =
  2774         if pred (role, info) then
  2778         if extract_isabelle_status info = SOME status then
  2775           formula_fold (SOME (role <> Conjecture)) add_eq_deps phi
  2779           formula_fold NONE (K add_eq_deps) phi
       
  2780         else
  2776         else
  2781           I
  2777           I
       
  2778       | add_deps _ _ = I
       
  2779     fun has_status status (_, info) =
       
  2780       extract_isabelle_status info = SOME status
       
  2781     fun is_conj (role, _) = (role = Conjecture orelse role = Hypothesis)
  2782     val graph =
  2782     val graph =
  2783       Graph.empty |> fold (fold (add_line_deps spec_eqN) o snd) problem
  2783       Graph.empty
  2784                   |> fold (fold (add_line_deps simpN) o snd) problem
  2784       |> fold (fold (add_deps (has_status spec_eqN)) o snd) problem
       
  2785       |> fold (fold (add_deps (has_status simpN orf is_conj)) o snd) problem
  2785     fun next_weight w = if w + w <= max_term_order_weight then w + w else w + 1
  2786     fun next_weight w = if w + w <= max_term_order_weight then w + w else w + 1
  2786     fun add_weights _ [] = I
  2787     fun add_weights _ [] = I
  2787       | add_weights weight syms =
  2788       | add_weights weight syms =
  2788         fold (AList.update (op =) o rpair weight) syms
  2789         fold (AList.update (op =) o rpair weight) syms
  2789         #> add_weights (next_weight weight)
  2790         #> add_weights (next_weight weight)