src/HOL/Tools/res_hol_clause.ML
changeset 31838 607a984b70e3
parent 31837 a50de97f1b08
child 31839 26f18ec0e293
     1.1 --- a/src/HOL/Tools/res_hol_clause.ML	Sun Jun 28 15:01:28 2009 +0200
     1.2 +++ b/src/HOL/Tools/res_hol_clause.ML	Sun Jun 28 15:01:28 2009 +0200
     1.3 @@ -26,18 +26,18 @@
     1.4    val strip_comb: combterm -> combterm * combterm list
     1.5    val literals_of_term: theory -> term -> literal list * typ list
     1.6    exception TOO_TRIVIAL
     1.7 -  val make_conjecture_clauses:  bool -> theory -> thm list -> clause list (* dfg thy ccls *)
     1.8 +  val make_conjecture_clauses:  bool -> theory -> thm list -> clause list
     1.9    val make_axiom_clauses: bool ->
    1.10         theory ->
    1.11 -       (thm * (axiom_name * clause_id)) list -> (axiom_name * clause) list (* dfg thy axcls *)
    1.12 +       (thm * (axiom_name * clause_id)) list -> (axiom_name * clause) list
    1.13    val get_helper_clauses: bool ->
    1.14         theory ->
    1.15         bool ->
    1.16         clause list * (thm * (axiom_name * clause_id)) list * string list ->
    1.17         clause list
    1.18 -  val tptp_write_file: bool -> string ->
    1.19 +  val tptp_write_file: bool -> Path.T ->
    1.20      clause list * clause list * clause list * ResClause.classrelClause list * ResClause.arityClause list -> unit
    1.21 -  val dfg_write_file: bool -> string -> 
    1.22 +  val dfg_write_file: bool -> Path.T ->
    1.23      clause list * clause list * clause list * ResClause.classrelClause list * ResClause.arityClause list -> unit
    1.24  end
    1.25  
    1.26 @@ -469,59 +469,56 @@
    1.27  
    1.28  (* tptp format *)
    1.29  
    1.30 -fun tptp_write_file t_full filename clauses =
    1.31 +fun tptp_write_file t_full file clauses =
    1.32    let
    1.33      val (conjectures, axclauses, helper_clauses, classrel_clauses, arity_clauses) = clauses
    1.34      val (cma, cnh) = count_constants clauses
    1.35      val params = (t_full, cma, cnh)
    1.36      val (tptp_clss,tfree_litss) = ListPair.unzip (map (clause2tptp params) conjectures)
    1.37      val tfree_clss = map RC.tptp_tfree_clause (List.foldl (op union_string) [] tfree_litss)
    1.38 -    val out = TextIO.openOut filename
    1.39    in
    1.40 -    List.app (curry TextIO.output out o #1 o (clause2tptp params)) axclauses;
    1.41 -    RC.writeln_strs out tfree_clss;
    1.42 -    RC.writeln_strs out tptp_clss;
    1.43 -    List.app (curry TextIO.output out o RC.tptp_classrelClause) classrel_clauses;
    1.44 -    List.app (curry TextIO.output out o RC.tptp_arity_clause) arity_clauses;
    1.45 -    List.app (curry TextIO.output out o #1 o (clause2tptp params)) helper_clauses;
    1.46 -    TextIO.closeOut out
    1.47 +    File.write_list file (
    1.48 +      map (#1 o (clause2tptp params)) axclauses @
    1.49 +      tfree_clss @
    1.50 +      tptp_clss @
    1.51 +      map RC.tptp_classrelClause classrel_clauses @
    1.52 +      map RC.tptp_arity_clause arity_clauses @
    1.53 +      map (#1 o (clause2tptp params)) helper_clauses)
    1.54    end;
    1.55  
    1.56  
    1.57  (* dfg format *)
    1.58  
    1.59 -fun dfg_write_file t_full filename clauses =
    1.60 +fun dfg_write_file t_full file clauses =
    1.61    let
    1.62      val (conjectures, axclauses, helper_clauses, classrel_clauses, arity_clauses) = clauses
    1.63      val (cma, cnh) = count_constants clauses
    1.64      val params = (t_full, cma, cnh)
    1.65      val (dfg_clss, tfree_litss) = ListPair.unzip (map (clause2dfg params) conjectures)
    1.66 -    and probname = Path.implode (Path.base (Path.explode filename))
    1.67 +    and probname = Path.implode (Path.base file)
    1.68      val axstrs = map (#1 o (clause2dfg params)) axclauses
    1.69      val tfree_clss = map RC.dfg_tfree_clause (RC.union_all tfree_litss)
    1.70 -    val out = TextIO.openOut filename
    1.71      val helper_clauses_strs = map (#1 o (clause2dfg params)) helper_clauses
    1.72      val (funcs,cl_preds) = decls_of_clauses params (helper_clauses @ conjectures @ axclauses) arity_clauses
    1.73      and ty_preds = preds_of_clauses axclauses classrel_clauses arity_clauses
    1.74    in
    1.75 -    TextIO.output (out, RC.string_of_start probname);
    1.76 -    TextIO.output (out, RC.string_of_descrip probname);
    1.77 -    TextIO.output (out, RC.string_of_symbols
    1.78 -                          (RC.string_of_funcs funcs)
    1.79 -                          (RC.string_of_preds (cl_preds @ ty_preds)));
    1.80 -    TextIO.output (out, "list_of_clauses(axioms,cnf).\n");
    1.81 -    RC.writeln_strs out axstrs;
    1.82 -    List.app (curry TextIO.output out o RC.dfg_classrelClause) classrel_clauses;
    1.83 -    List.app (curry TextIO.output out o RC.dfg_arity_clause) arity_clauses;
    1.84 -    RC.writeln_strs out helper_clauses_strs;
    1.85 -    TextIO.output (out, "end_of_list.\n\nlist_of_clauses(conjectures,cnf).\n");
    1.86 -    RC.writeln_strs out tfree_clss;
    1.87 -    RC.writeln_strs out dfg_clss;
    1.88 -    TextIO.output (out, "end_of_list.\n\n");
    1.89 -    (*VarWeight=3 helps the HO problems, probably by counteracting the presence of hAPP*)
    1.90 -    TextIO.output (out, "list_of_settings(SPASS).\n{*\nset_flag(VarWeight,3).\n*}\nend_of_list.\n\n");
    1.91 -    TextIO.output (out, "end_problem.\n");
    1.92 -    TextIO.closeOut out
    1.93 +    File.write_list file (
    1.94 +      RC.string_of_start probname ::
    1.95 +      RC.string_of_descrip probname ::
    1.96 +      RC.string_of_symbols (RC.string_of_funcs funcs)
    1.97 +        (RC.string_of_preds (cl_preds @ ty_preds)) ::
    1.98 +      "list_of_clauses(axioms,cnf).\n" ::
    1.99 +      axstrs @
   1.100 +      map RC.dfg_classrelClause classrel_clauses @
   1.101 +      map RC.dfg_arity_clause arity_clauses @
   1.102 +      helper_clauses_strs @
   1.103 +      ["end_of_list.\n\nlist_of_clauses(conjectures,cnf).\n"] @
   1.104 +      tfree_clss @
   1.105 +      dfg_clss @
   1.106 +      ["end_of_list.\n\n",
   1.107 +      (*VarWeight=3 helps the HO problems, probably by counteracting the presence of hAPP*)
   1.108 +       "list_of_settings(SPASS).\n{*\nset_flag(VarWeight,3).\n*}\nend_of_list.\n\n",
   1.109 +       "end_problem.\n"])
   1.110    end;
   1.111  
   1.112  end