src/HOL/Tools/Sledgehammer/sledgehammer_tptp_format.ML
changeset 37925 1188e6bff48d
parent 37924 17f36ad210d6
child 37926 e6ff246c0cdb
equal deleted inserted replaced
37924:17f36ad210d6 37925:1188e6bff48d
     5 TPTP syntax.
     5 TPTP syntax.
     6 *)
     6 *)
     7 
     7 
     8 signature SLEDGEHAMMER_TPTP_FORMAT =
     8 signature SLEDGEHAMMER_TPTP_FORMAT =
     9 sig
     9 sig
    10   type classrel_clause = Metis_Clauses.classrel_clause
    10   type class_rel_clause = Metis_Clauses.class_rel_clause
    11   type arity_clause = Metis_Clauses.arity_clause
    11   type arity_clause = Metis_Clauses.arity_clause
    12   type fol_clause = Metis_Clauses.fol_clause
    12   type fol_clause = Metis_Clauses.fol_clause
    13   type name_pool = string Symtab.table * string Symtab.table
    13   type name_pool = string Symtab.table * string Symtab.table
    14 
    14 
    15   val write_tptp_file :
    15   val write_tptp_file :
    16     theory -> bool -> bool -> bool -> Path.T
    16     theory -> bool -> bool -> bool -> Path.T
    17     -> fol_clause list * fol_clause list * fol_clause list * fol_clause list
    17     -> fol_clause list * fol_clause list * fol_clause list * fol_clause list
    18        * classrel_clause list * arity_clause list
    18        * class_rel_clause list * arity_clause list
    19     -> name_pool option * int
    19     -> name_pool option * int
    20 end;
    20 end;
    21 
    21 
    22 structure Sledgehammer_TPTP_Format : SLEDGEHAMMER_TPTP_FORMAT =
    22 structure Sledgehammer_TPTP_Format : SLEDGEHAMMER_TPTP_FORMAT =
    23 struct
    23 struct
   162 fun problem_line_for_axiom full_types
   162 fun problem_line_for_axiom full_types
   163         (clause as FOLClause {axiom_name, clause_id, kind, ...}) =
   163         (clause as FOLClause {axiom_name, clause_id, kind, ...}) =
   164   Cnf (hol_ident axiom_name clause_id, kind,
   164   Cnf (hol_ident axiom_name clause_id, kind,
   165        atp_literals_for_axiom full_types clause)
   165        atp_literals_for_axiom full_types clause)
   166 
   166 
   167 fun problem_line_for_classrel
   167 fun problem_line_for_class_rel
   168         (ClassrelClause {axiom_name, subclass, superclass, ...}) =
   168         (ClassRelClause {axiom_name, subclass, superclass, ...}) =
   169   let val ty_arg = ATerm (("T", "T"), []) in
   169   let val ty_arg = ATerm (("T", "T"), []) in
   170     Cnf (ascii_of axiom_name, Axiom, [(false, ATerm (subclass, [ty_arg])),
   170     Cnf (ascii_of axiom_name, Axiom, [(false, ATerm (subclass, [ty_arg])),
   171                                       (true, ATerm (superclass, [ty_arg]))])
   171                                       (true, ATerm (superclass, [ty_arg]))])
   172   end
   172   end
   173 
   173 
   301   repair_problem_with_const_table thy full_types
   301   repair_problem_with_const_table thy full_types
   302       (const_table_for_problem explicit_apply problem) problem
   302       (const_table_for_problem explicit_apply problem) problem
   303 
   303 
   304 fun write_tptp_file thy readable_names full_types explicit_apply file
   304 fun write_tptp_file thy readable_names full_types explicit_apply file
   305                     (conjectures, axiom_clauses, extra_clauses, helper_clauses,
   305                     (conjectures, axiom_clauses, extra_clauses, helper_clauses,
   306                      classrel_clauses, arity_clauses) =
   306                      class_rel_clauses, arity_clauses) =
   307   let
   307   let
   308     val axiom_lines = map (problem_line_for_axiom full_types) axiom_clauses
   308     val axiom_lines = map (problem_line_for_axiom full_types) axiom_clauses
   309     val classrel_lines = map problem_line_for_classrel classrel_clauses
   309     val class_rel_lines = map problem_line_for_class_rel class_rel_clauses
   310     val arity_lines = map problem_line_for_arity arity_clauses
   310     val arity_lines = map problem_line_for_arity arity_clauses
   311     val helper_lines = map (problem_line_for_axiom full_types) helper_clauses
   311     val helper_lines = map (problem_line_for_axiom full_types) helper_clauses
   312     val conjecture_lines =
   312     val conjecture_lines =
   313       map (problem_line_for_conjecture full_types) conjectures
   313       map (problem_line_for_conjecture full_types) conjectures
   314     val tfree_lines = problem_lines_for_free_types conjectures
   314     val tfree_lines = problem_lines_for_free_types conjectures
   315     val problem = [("Relevant facts", axiom_lines),
   315     val problem = [("Relevant facts", axiom_lines),
   316                    ("Class relationships", classrel_lines),
   316                    ("Class relationships", class_rel_lines),
   317                    ("Arity declarations", arity_lines),
   317                    ("Arity declarations", arity_lines),
   318                    ("Helper facts", helper_lines),
   318                    ("Helper facts", helper_lines),
   319                    ("Conjectures", conjecture_lines),
   319                    ("Conjectures", conjecture_lines),
   320                    ("Type variables", tfree_lines)]
   320                    ("Type variables", tfree_lines)]
   321                   |> repair_problem thy full_types explicit_apply
   321                   |> repair_problem thy full_types explicit_apply
   322     val (problem, pool) = nice_problem problem (empty_name_pool readable_names)
   322     val (problem, pool) = nice_problem problem (empty_name_pool readable_names)
   323     val conjecture_offset =
   323     val conjecture_offset =
   324       length axiom_lines + length classrel_lines + length arity_lines
   324       length axiom_lines + length class_rel_lines + length arity_lines
   325       + length helper_lines
   325       + length helper_lines
   326     val _ = File.write_list file (strings_for_problem problem)
   326     val _ = File.write_list file (strings_for_problem problem)
   327   in (pool, conjecture_offset) end
   327   in (pool, conjecture_offset) end
   328 
   328 
   329 end;
   329 end;