src/HOL/Tools/ATP/atp_translate.ML
changeset 45551 a62c7a21f4ab
parent 45520 2b1dde0b1c30
child 45554 09ad83de849c
equal deleted inserted replaced
45550:73a4f31d41c4 45551:a62c7a21f4ab
    99   val factsN : string
    99   val factsN : string
   100   val prepare_atp_problem :
   100   val prepare_atp_problem :
   101     Proof.context -> atp_format -> formula_kind -> formula_kind -> type_enc
   101     Proof.context -> atp_format -> formula_kind -> formula_kind -> type_enc
   102     -> bool -> string -> bool -> bool -> term list -> term
   102     -> bool -> string -> bool -> bool -> term list -> term
   103     -> ((string * locality) * term) list
   103     -> ((string * locality) * term) list
   104     -> string problem * string Symtab.table * int * int
   104     -> string problem * string Symtab.table * (string * locality) list vector
   105        * (string * locality) list vector * int list * (string * term) list
   105        * (string * term) list * int Symtab.table
   106        * int Symtab.table
       
   107   val atp_problem_weights : string problem -> (string * real) list
   106   val atp_problem_weights : string problem -> (string * real) list
   108 end;
   107 end;
   109 
   108 
   110 structure ATP_Translate : ATP_TRANSLATE =
   109 structure ATP_Translate : ATP_TRANSLATE =
   111 struct
   110 struct
  2309     Config.get ctxt type_tag_idempotence andalso
  2308     Config.get ctxt type_tag_idempotence andalso
  2310     is_type_level_monotonicity_based level andalso
  2309     is_type_level_monotonicity_based level andalso
  2311     poly <> Mangled_Monomorphic
  2310     poly <> Mangled_Monomorphic
  2312   | needs_type_tag_idempotence _ _ = false
  2311   | needs_type_tag_idempotence _ _ = false
  2313 
  2312 
  2314 fun offset_of_heading_in_problem _ [] j = j
       
  2315   | offset_of_heading_in_problem needle ((heading, lines) :: problem) j =
       
  2316     if heading = needle then j
       
  2317     else offset_of_heading_in_problem needle problem (j + length lines)
       
  2318 
       
  2319 val implicit_declsN = "Should-be-implicit typings"
  2313 val implicit_declsN = "Should-be-implicit typings"
  2320 val explicit_declsN = "Explicit typings"
  2314 val explicit_declsN = "Explicit typings"
  2321 val factsN = "Relevant facts"
  2315 val factsN = "Relevant facts"
  2322 val class_relsN = "Class relationships"
  2316 val class_relsN = "Class relationships"
  2323 val aritiesN = "Arities"
  2317 val aritiesN = "Arities"
  2404           | TFF (_, TPTP_Implicit) => I
  2398           | TFF (_, TPTP_Implicit) => I
  2405           | THF (_, TPTP_Implicit, _) => I
  2399           | THF (_, TPTP_Implicit, _) => I
  2406           | _ => declare_undeclared_syms_in_atp_problem type_decl_prefix
  2400           | _ => declare_undeclared_syms_in_atp_problem type_decl_prefix
  2407                                                         implicit_declsN)
  2401                                                         implicit_declsN)
  2408     val (problem, pool) = problem |> nice_atp_problem readable_names
  2402     val (problem, pool) = problem |> nice_atp_problem readable_names
  2409     val helpers_offset = offset_of_heading_in_problem helpersN problem 0
       
  2410     val typed_helpers =
       
  2411       map_filter (fn (j, {name, ...}) =>
       
  2412                      if String.isSuffix typed_helper_suffix name then SOME j
       
  2413                      else NONE)
       
  2414                  ((helpers_offset + 1 upto helpers_offset + length helpers)
       
  2415                   ~~ helpers)
       
  2416     fun add_sym_ary (s, {min_ary, ...} : sym_info) =
  2403     fun add_sym_ary (s, {min_ary, ...} : sym_info) =
  2417       min_ary > 0 ? Symtab.insert (op =) (s, min_ary)
  2404       min_ary > 0 ? Symtab.insert (op =) (s, min_ary)
  2418   in
  2405   in
  2419     (problem,
  2406     (problem,
  2420      case pool of SOME the_pool => snd the_pool | NONE => Symtab.empty,
  2407      case pool of SOME the_pool => snd the_pool | NONE => Symtab.empty,
  2421      offset_of_heading_in_problem conjsN problem 0,
       
  2422      offset_of_heading_in_problem factsN problem 0,
       
  2423      fact_names |> Vector.fromList,
  2408      fact_names |> Vector.fromList,
  2424      typed_helpers,
       
  2425      lifted,
  2409      lifted,
  2426      Symtab.empty |> Symtab.fold add_sym_ary sym_tab)
  2410      Symtab.empty |> Symtab.fold add_sym_ary sym_tab)
  2427   end
  2411   end
  2428 
  2412 
  2429 (* FUDGE *)
  2413 (* FUDGE *)