src/HOL/Tools/Sledgehammer/sledgehammer_hol_clause.ML
author blanchet
Mon, 19 Apr 2010 19:41:30 +0200
changeset 36233 1263bef003b3
parent 36231 bede2d49ba3b
child 36235 61159615a0c5
permissions -rw-r--r--
cosmetics
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35825
diff changeset
     1
(*  Title:      HOL/Sledgehammer/sledgehammer_hol_clause.ML
33311
49cd8abb2863 proper header;
wenzelm
parents: 33042
diff changeset
     2
    Author:     Jia Meng, NICTA
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     3
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
     4
FOL clauses translated from HOL formulae.
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     5
*)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     6
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35825
diff changeset
     7
signature SLEDGEHAMMER_HOL_CLAUSE =
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
     8
sig
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
     9
  type name = Sledgehammer_FOL_Clause.name
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    10
  type kind = Sledgehammer_FOL_Clause.kind
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    11
  type fol_type = Sledgehammer_FOL_Clause.fol_type
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    12
  type classrel_clause = Sledgehammer_FOL_Clause.classrel_clause
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    13
  type arity_clause = Sledgehammer_FOL_Clause.arity_clause
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    14
  type axiom_name = string
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    15
  type polarity = bool
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    16
  type hol_clause_id = int
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    17
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    18
  datatype combterm =
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    19
    CombConst of name * fol_type * fol_type list (* Const and Free *) |
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    20
    CombVar of name * fol_type |
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    21
    CombApp of combterm * combterm
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    22
  datatype literal = Literal of polarity * combterm
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    23
  datatype hol_clause =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    24
    HOLClause of {clause_id: hol_clause_id, axiom_name: axiom_name, th: thm,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    25
                  kind: kind, literals: literal list, ctypes_sorts: typ list}
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    26
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    27
  val type_of_combterm : combterm -> fol_type
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    28
  val strip_combterm_comb : combterm -> combterm * combterm list
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    29
  val literals_of_term : theory -> term -> literal list * typ list
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    30
  exception TRIVIAL
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    31
  val make_conjecture_clauses : bool -> theory -> thm list -> hol_clause list
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    32
  val make_axiom_clauses : bool -> theory ->
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    33
       (thm * (axiom_name * hol_clause_id)) list -> (axiom_name * hol_clause) list
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    34
  val get_helper_clauses : bool -> theory -> bool ->
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    35
       hol_clause list * (thm * (axiom_name * hol_clause_id)) list * string list ->
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    36
       hol_clause list
36169
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
    37
  val write_tptp_file : bool -> bool -> Path.T ->
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    38
    hol_clause list * hol_clause list * hol_clause list * hol_clause list *
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
    39
    classrel_clause list * arity_clause list -> unit
36222
0e3e49bd658d don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents: 36219
diff changeset
    40
  val write_dfg_file : bool -> Path.T ->
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    41
    hol_clause list * hol_clause list * hol_clause list * hol_clause list *
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
    42
    classrel_clause list * arity_clause list -> unit
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    43
end
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    44
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35825
diff changeset
    45
structure Sledgehammer_HOL_Clause : SLEDGEHAMMER_HOL_CLAUSE =
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    46
struct
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    47
36167
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 35963
diff changeset
    48
open Sledgehammer_Util
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    49
open Sledgehammer_FOL_Clause
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    50
open Sledgehammer_Fact_Preprocessor
22825
bd774e01d6d5 Fixing bugs in the partial-typed and fully-typed translations
paulson
parents: 22130
diff changeset
    51
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35865
diff changeset
    52
(* Parameter "full_types" below indicates that full type information is to be
31800
477f2abf90a4 Streamlined code
nipkow
parents: 31791
diff changeset
    53
exported *)
22825
bd774e01d6d5 Fixing bugs in the partial-typed and fully-typed translations
paulson
parents: 22130
diff changeset
    54
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    55
(* If true, each function will be directly applied to as many arguments as
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    56
   possible, avoiding use of the "apply" operator. Use of hBOOL is also
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    57
   minimized. *)
30153
051d3825a15d turned "read-only refs" typ_level and minimize_applies into constant values;
wenzelm
parents: 30151
diff changeset
    58
val minimize_applies = true;
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
    59
33035
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 33029
diff changeset
    60
fun min_arity_of const_min_arity c = the_default 0 (Symtab.lookup const_min_arity c);
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
    61
22825
bd774e01d6d5 Fixing bugs in the partial-typed and fully-typed translations
paulson
parents: 22130
diff changeset
    62
(*True if the constant ever appears outside of the top-level position in literals.
bd774e01d6d5 Fixing bugs in the partial-typed and fully-typed translations
paulson
parents: 22130
diff changeset
    63
  If false, the constant always receives all of its arguments and is used as a predicate.*)
33035
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 33029
diff changeset
    64
fun needs_hBOOL const_needs_hBOOL c =
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 33029
diff changeset
    65
  not minimize_applies orelse
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 33029
diff changeset
    66
    the_default false (Symtab.lookup const_needs_hBOOL c);
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
    67
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
    68
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    69
(******************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    70
(* data types for typed combinator expressions        *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    71
(******************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    72
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    73
type axiom_name = string;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    74
type polarity = bool;
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    75
type hol_clause_id = int;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    76
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    77
datatype combterm =
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    78
  CombConst of name * fol_type * fol_type list (* Const and Free *) |
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    79
  CombVar of name * fol_type |
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    80
  CombApp of combterm * combterm
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
    81
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    82
datatype literal = Literal of polarity * combterm;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    83
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    84
datatype hol_clause =
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    85
  HOLClause of {clause_id: hol_clause_id, axiom_name: axiom_name, th: thm,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    86
                kind: kind, literals: literal list, ctypes_sorts: typ list};
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    87
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    88
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    89
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    90
(* convert a clause with type Term.term to a clause with type clause *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    91
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    92
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    93
fun isFalse (Literal (pol, CombConst ((c, _), _, _))) =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
    94
      (pol andalso c = "c_False") orelse (not pol andalso c = "c_True")
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    95
  | isFalse _ = false;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    96
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
    97
fun isTrue (Literal (pol, CombConst ((c, _), _, _))) =
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    98
      (pol andalso c = "c_True") orelse
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    99
      (not pol andalso c = "c_False")
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   100
  | isTrue _ = false;
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   101
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   102
fun isTaut (HOLClause {literals,...}) = exists isTrue literals;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   103
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   104
fun type_of dfg (Type (a, Ts)) =
36169
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   105
    let val (folTypes,ts) = types_of dfg Ts in
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   106
      (TyConstr (`(make_fixed_type_const dfg) a, folTypes), ts)
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   107
    end
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   108
  | type_of _ (tp as TFree (a, _)) = (TyFree (`make_fixed_type_var a), [tp])
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   109
  | type_of _ (tp as TVar (x, _)) =
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   110
    (TyVar (make_schematic_type_var x, string_of_indexname x), [tp])
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   111
and types_of dfg Ts =
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   112
      let val (folTyps,ts) = ListPair.unzip (map (type_of dfg) Ts)
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   113
      in  (folTyps, union_all ts)  end;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   114
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   115
(* same as above, but no gathering of sort information *)
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   116
fun simp_type_of dfg (Type (a, Ts)) =
36169
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   117
      TyConstr (`(make_fixed_type_const dfg) a, map (simp_type_of dfg) Ts)
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   118
  | simp_type_of _ (TFree (a, _)) = TyFree (`make_fixed_type_var a)
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   119
  | simp_type_of _ (TVar (x, _)) =
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   120
    TyVar (make_schematic_type_var x, string_of_indexname x);
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   121
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   122
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   123
fun const_type_of dfg thy (c,t) =
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   124
      let val (tp,ts) = type_of dfg t
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   125
      in  (tp, ts, map (simp_type_of dfg) (Sign.const_typargs thy (c,t))) end;
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   126
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   127
(* convert a Term.term (with combinators) into a combterm, also accummulate sort info *)
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   128
fun combterm_of dfg thy (Const(c,t)) =
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   129
      let val (tp,ts,tvar_list) = const_type_of dfg thy (c,t)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   130
          val c' = CombConst (`(make_fixed_const dfg) c, tp, tvar_list)
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   131
      in  (c',ts)  end
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   132
  | combterm_of dfg _ (Free(v,t)) =
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   133
      let val (tp,ts) = type_of dfg t
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   134
          val v' = CombConst (`make_fixed_var v, tp, [])
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   135
      in  (v',ts)  end
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   136
  | combterm_of dfg _ (Var(v,t)) =
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   137
      let val (tp,ts) = type_of dfg t
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   138
          val v' = CombVar ((make_schematic_var v, string_of_indexname v), tp)
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   139
      in  (v',ts)  end
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   140
  | combterm_of dfg thy (P $ Q) =
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   141
      let val (P',tsP) = combterm_of dfg thy P
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   142
          val (Q',tsQ) = combterm_of dfg thy Q
33042
ddf1f03a9ad9 curried union as canonical list operation
haftmann
parents: 33039
diff changeset
   143
      in  (CombApp(P',Q'), union (op =) tsP tsQ)  end
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   144
  | combterm_of _ _ (t as Abs _) = raise CLAUSE ("HOL CLAUSE", t);
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   145
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   146
fun predicate_of dfg thy ((@{const Not} $ P), polarity) = predicate_of dfg thy (P, not polarity)
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   147
  | predicate_of dfg thy (t,polarity) = (combterm_of dfg thy (Envir.eta_contract t), polarity);
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   148
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   149
fun literals_of_term1 dfg thy args (@{const Trueprop} $ P) = literals_of_term1 dfg thy args P
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   150
  | literals_of_term1 dfg thy args (@{const "op |"} $ P $ Q) =
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   151
      literals_of_term1 dfg thy (literals_of_term1 dfg thy args P) Q
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   152
  | literals_of_term1 dfg thy (lits,ts) P =
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   153
      let val ((pred,ts'),pol) = predicate_of dfg thy (P,true)
21509
6c5755ad9cae ATP linkup now generates "new TPTP" rather than "old TPTP"
paulson
parents: 21470
diff changeset
   154
      in
33042
ddf1f03a9ad9 curried union as canonical list operation
haftmann
parents: 33039
diff changeset
   155
          (Literal(pol,pred)::lits, union (op =) ts ts')
21509
6c5755ad9cae ATP linkup now generates "new TPTP" rather than "old TPTP"
paulson
parents: 21470
diff changeset
   156
      end;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   157
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   158
fun literals_of_term_dfg dfg thy P = literals_of_term1 dfg thy ([],[]) P;
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   159
val literals_of_term = literals_of_term_dfg false;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   160
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   161
(* Trivial problem, which resolution cannot handle (empty clause) *)
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   162
exception TRIVIAL;
28835
d4d8eba5f781 changes by Fabian Immler:
wenzelm
parents: 27187
diff changeset
   163
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   164
(* making axiom and conjecture clauses *)
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   165
fun make_clause dfg thy (clause_id, axiom_name, kind, th) =
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   166
    let val (lits,ctypes_sorts) = literals_of_term_dfg dfg thy (prop_of th)
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   167
    in
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   168
        if forall isFalse lits then
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   169
            raise TRIVIAL
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   170
        else
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   171
            HOLClause {clause_id = clause_id, axiom_name = axiom_name, th = th,
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   172
                       kind = kind, literals = lits, ctypes_sorts = ctypes_sorts}
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   173
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   174
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   175
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   176
fun add_axiom_clause dfg thy (th, (name, id)) =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   177
  let val cls = make_clause dfg thy (id, name, Axiom, th) in
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   178
    not (isTaut cls) ? cons (name, cls)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   179
  end
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   180
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   181
fun make_axiom_clauses dfg thy clauses =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   182
  fold (add_axiom_clause dfg thy) clauses []
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   183
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   184
fun make_conjecture_clauses_aux _ _ _ [] = []
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   185
  | make_conjecture_clauses_aux dfg thy n (th::ths) =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   186
      make_clause dfg thy (n,"conjecture", Conjecture, th) ::
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   187
      make_conjecture_clauses_aux dfg thy (n+1) ths;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   188
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   189
fun make_conjecture_clauses dfg thy = make_conjecture_clauses_aux dfg thy 0;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   190
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   191
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   192
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   193
(* convert clause into ATP specific formats:                          *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   194
(* TPTP used by Vampire and E                                         *)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   195
(* DFG used by SPASS                                                  *)
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   196
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   197
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   198
(*Result of a function type; no need to check that the argument type matches.*)
36169
27b1cc58715e store nonmangled names along with mangled type names in Sledgehammer for debugging purposes
blanchet
parents: 36168
diff changeset
   199
fun result_type (TyConstr (("tc_fun", _), [_, tp2])) = tp2
36168
0a6ed065683d give more sensible names to "fol_type" constructors, as requested by a FIXME comment
blanchet
parents: 36167
diff changeset
   200
  | result_type _ = raise Fail "Non-function type"
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   201
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   202
fun type_of_combterm (CombConst (_, tp, _)) = tp
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   203
  | type_of_combterm (CombVar (_, tp)) = tp
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   204
  | type_of_combterm (CombApp (t1, _)) = result_type (type_of_combterm t1);
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   205
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   206
(*gets the head of a combinator application, along with the list of arguments*)
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   207
fun strip_combterm_comb u =
22078
5084f53cef39 Streamlining: removing the type argument of CombApp; abbreviating ResClause as RC
paulson
parents: 22064
diff changeset
   208
    let fun stripc (CombApp(t,u), ts) = stripc (t, u::ts)
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   209
        |   stripc  x =  x
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   210
    in  stripc(u,[])  end;
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   211
22851
7b7d6e1c70b6 First-order variant of the fully-typed translation
paulson
parents: 22825
diff changeset
   212
val type_wrapper = "ti";
7b7d6e1c70b6 First-order variant of the fully-typed translation
paulson
parents: 22825
diff changeset
   213
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   214
fun head_needs_hBOOL const_needs_hBOOL (CombConst((c, _), _, _)) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   215
    needs_hBOOL const_needs_hBOOL c
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   216
  | head_needs_hBOOL _ _ = true;
22851
7b7d6e1c70b6 First-order variant of the fully-typed translation
paulson
parents: 22825
diff changeset
   217
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   218
fun wrap_type full_types (s, ty) pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   219
  if full_types then
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   220
    let val (s', pool) = string_of_fol_type ty pool in
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   221
      (type_wrapper ^ paren_pack [s, s'], pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   222
    end
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   223
  else
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   224
    (s, pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   225
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   226
fun wrap_type_if full_types cnh (head, s, tp) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   227
  if head_needs_hBOOL cnh head then wrap_type full_types (s, tp) else pair s
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   228
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   229
fun apply ss = "hAPP" ^ paren_pack ss;
22851
7b7d6e1c70b6 First-order variant of the fully-typed translation
paulson
parents: 22825
diff changeset
   230
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   231
fun rev_apply (v, []) = v
22851
7b7d6e1c70b6 First-order variant of the fully-typed translation
paulson
parents: 22825
diff changeset
   232
  | rev_apply (v, arg::args) = apply [rev_apply (v, args), arg];
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   233
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   234
fun string_apply (v, args) = rev_apply (v, rev args);
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   235
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   236
(* Apply an operator to the argument strings, using either the "apply" operator
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   237
   or direct function application. *)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   238
fun string_of_application full_types cma (CombConst ((s, s'), _, tvars), args)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   239
                          pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   240
    let
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   241
      val s = if s = "equal" then "c_fequal" else s
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   242
      val nargs = min_arity_of cma s
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   243
      val args1 = List.take (args, nargs)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   244
        handle Subscript =>
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   245
               raise Fail (quote s ^ " has arity " ^ Int.toString nargs ^
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   246
                           " but is applied to " ^ commas (map quote args))
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   247
      val args2 = List.drop (args, nargs)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   248
      val (targs, pool) = if full_types then ([], pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   249
                          else pool_map string_of_fol_type tvars pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   250
      val (s, pool) = nice_name (s, s') pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   251
    in (string_apply (s ^ paren_pack (args1 @ targs), args2), pool) end
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   252
  | string_of_application _ _ (CombVar (name, _), args) pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   253
    nice_name name pool |>> (fn s => string_apply (s, args))
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   254
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   255
fun string_of_combterm (params as (full_types, cma, cnh)) t pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   256
  let
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   257
    val (head, args) = strip_combterm_comb t
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   258
    val (ss, pool) = pool_map (string_of_combterm params) args pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   259
    val (s, pool) = string_of_application full_types cma (head, ss) pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   260
  in wrap_type_if full_types cnh (head, s, type_of_combterm t) pool end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   261
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   262
(*Boolean-valued terms are here converted to literals.*)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   263
fun boolify params c =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   264
  string_of_combterm params c #>> prefix "hBOOL" o paren_pack o single
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   265
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   266
fun string_of_predicate (params as (_, _, cnh)) t =
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   267
  case t of
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   268
    (CombApp (CombApp (CombConst (("equal", _), _, _), t1), t2)) =>
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   269
    (* DFG only: new TPTP prefers infix equality *)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   270
    pool_map (string_of_combterm params) [t1, t2]
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   271
    #>> prefix "equal" o paren_pack
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   272
  | _ =>
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   273
    case #1 (strip_combterm_comb t) of
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   274
      CombConst ((s, _), _, _) =>
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   275
      (if needs_hBOOL cnh s then boolify else string_of_combterm) params t
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   276
    | _ => boolify params t
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   277
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   278
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   279
(*** TPTP format ***)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   280
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   281
fun tptp_of_equality params pos (t1, t2) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   282
  pool_map (string_of_combterm params) [t1, t2]
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   283
  #>> space_implode (if pos then " = " else " != ")
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   284
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   285
fun tptp_literal params
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   286
        (Literal (pos, CombApp (CombApp (CombConst (("equal", _), _, _), t1),
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   287
                                         t2))) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   288
    tptp_of_equality params pos (t1, t2)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   289
  | tptp_literal params (Literal (pos, pred)) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   290
    string_of_predicate params pred #>> tptp_sign pos
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   291
 
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   292
(* Given a clause, returns its literals paired with a list of literals
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   293
   concerning TFrees; the latter should only occur in conjecture clauses. *)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   294
fun tptp_type_literals params pos (HOLClause {literals, ctypes_sorts, ...}) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   295
  pool_map (tptp_literal params) literals
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   296
  #>> rpair (map (tptp_of_typeLit pos) (add_typs ctypes_sorts))
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   297
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   298
fun tptp_clause params (cls as HOLClause {axiom_name, clause_id, kind, ...})
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   299
                pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   300
let
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   301
    val ((lits, tylits), pool) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   302
      tptp_type_literals params (kind = Conjecture) cls pool
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24385
diff changeset
   303
  in
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   304
    ((gen_tptp_cls (clause_id, axiom_name, kind, lits, tylits), tylits), pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   305
  end
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   306
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   307
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   308
(*** DFG format ***)
21561
cfd2258f0b23 Tidied code. Bool constructor is not needed.
paulson
parents: 21513
diff changeset
   309
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   310
fun dfg_literal params (Literal (pos, pred)) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   311
  string_of_predicate params pred #>> dfg_sign pos
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   312
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   313
fun dfg_type_literals params pos (HOLClause {literals, ctypes_sorts, ...}) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   314
  pool_map (dfg_literal params) literals
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   315
  #>> rpair (map (dfg_of_typeLit pos) (add_typs ctypes_sorts))
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   316
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   317
fun get_uvars (CombConst _) vars pool = (vars, pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   318
  | get_uvars (CombVar (name, _)) vars pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   319
    nice_name name pool |>> (fn var => var :: vars)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   320
  | get_uvars (CombApp (P, Q)) vars pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   321
    let val (vars, pool) = get_uvars P vars pool in get_uvars Q vars pool end
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   322
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   323
fun get_uvars_l (Literal (_, c)) = get_uvars c [];
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   324
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   325
fun dfg_vars (HOLClause {literals, ...}) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   326
  pool_map get_uvars_l literals #>> union_all
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   327
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   328
fun dfg_clause params (cls as HOLClause {axiom_name, clause_id, kind,
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   329
                                         ctypes_sorts, ...}) pool =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   330
  let
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   331
    val ((lits, tylits), pool) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   332
      dfg_type_literals params (kind = Conjecture) cls pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   333
    val (vars, pool) = dfg_vars cls pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   334
    val tvars = get_tvar_strs ctypes_sorts
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24385
diff changeset
   335
  in
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   336
    ((gen_dfg_cls (clause_id, axiom_name, kind, lits, tylits, tvars @ vars),
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   337
      tylits), pool)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   338
  end
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24385
diff changeset
   339
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   340
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   341
(** For DFG format: accumulate function and predicate declarations **)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   342
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   343
fun add_types tvars = fold add_fol_type_funcs tvars
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   344
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   345
fun add_decls (full_types, cma, cnh) (CombConst ((c, _), _, tvars))
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   346
              (funcs, preds) =
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   347
      if c = "equal" then
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   348
        (add_types tvars funcs, preds)
21561
cfd2258f0b23 Tidied code. Bool constructor is not needed.
paulson
parents: 21513
diff changeset
   349
      else
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32955
diff changeset
   350
        let val arity = min_arity_of cma c
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35865
diff changeset
   351
            val ntys = if not full_types then length tvars else 0
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32955
diff changeset
   352
            val addit = Symtab.update(c, arity+ntys)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32955
diff changeset
   353
        in
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   354
            if needs_hBOOL cnh c then (add_types tvars (addit funcs), preds)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   355
            else (add_types tvars funcs, addit preds)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32955
diff changeset
   356
        end
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   357
  | add_decls _ (CombVar (_, ctp)) (funcs, preds) =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   358
      (add_fol_type_funcs ctp funcs, preds)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   359
  | add_decls params (CombApp (P, Q)) decls =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   360
      decls |> add_decls params P |> add_decls params Q
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   361
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   362
fun add_literal_decls params (Literal (_, c)) = add_decls params c
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   363
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   364
fun add_clause_decls params (HOLClause {literals, ...}) decls =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   365
    fold (add_literal_decls params) literals decls
27187
17b63e145986 use regular error function;
wenzelm
parents: 27178
diff changeset
   366
    handle Symtab.DUP a => error ("function " ^ a ^ " has multiple arities")
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   367
31800
477f2abf90a4 Streamlined code
nipkow
parents: 31791
diff changeset
   368
fun decls_of_clauses params clauses arity_clauses =
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   369
  let val functab = init_functab |> Symtab.update (type_wrapper, 2)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   370
                                 |> Symtab.update ("hAPP", 2)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   371
      val predtab = Symtab.empty |> Symtab.update ("hBOOL", 1)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   372
      val (functab, predtab) =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   373
        (functab, predtab) |> fold (add_clause_decls params) clauses
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   374
                           |>> fold add_arity_clause_funcs arity_clauses
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   375
  in (Symtab.dest functab, Symtab.dest predtab) end
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   376
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   377
fun add_clause_preds (HOLClause {ctypes_sorts, ...}) preds =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   378
  fold add_type_sort_preds ctypes_sorts preds
27187
17b63e145986 use regular error function;
wenzelm
parents: 27178
diff changeset
   379
  handle Symtab.DUP a => error ("predicate " ^ a ^ " has multiple arities")
21398
11996e938dfe Includes type:sort constraints in its code to collect predicates in axiom clauses.
paulson
parents: 21254
diff changeset
   380
11996e938dfe Includes type:sort constraints in its code to collect predicates in axiom clauses.
paulson
parents: 21254
diff changeset
   381
(*Higher-order clauses have only the predicates hBOOL and type classes.*)
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   382
fun preds_of_clauses clauses clsrel_clauses arity_clauses =
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   383
  Symtab.empty
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   384
  |> fold add_clause_preds clauses
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   385
  |> fold add_arity_clause_preds arity_clauses
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   386
  |> fold add_classrel_clause_preds clsrel_clauses
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   387
  |> Symtab.dest
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   388
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   389
(**********************************************************************)
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   390
(* write clauses to files                                             *)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   391
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   392
21573
8a7a68c0096c Removed the references for counting combinators. Instead they are counted in actual clauses.
paulson
parents: 21561
diff changeset
   393
val init_counters =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   394
  Symtab.make [("c_COMBI", 0), ("c_COMBK", 0), ("c_COMBB", 0), ("c_COMBC", 0),
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   395
               ("c_COMBS", 0)];
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   396
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   397
fun count_combterm (CombConst ((c, _), _, _)) =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   398
    Symtab.map_entry c (Integer.add 1)
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   399
  | count_combterm (CombVar _) = I
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   400
  | count_combterm (CombApp (t1, t2)) = count_combterm t1 #> count_combterm t2
21573
8a7a68c0096c Removed the references for counting combinators. Instead they are counted in actual clauses.
paulson
parents: 21561
diff changeset
   401
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   402
fun count_literal (Literal (_, t)) = count_combterm t
21573
8a7a68c0096c Removed the references for counting combinators. Instead they are counted in actual clauses.
paulson
parents: 21561
diff changeset
   403
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   404
fun count_clause (HOLClause {literals, ...}) = fold count_literal literals
21573
8a7a68c0096c Removed the references for counting combinators. Instead they are counted in actual clauses.
paulson
parents: 21561
diff changeset
   405
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   406
fun count_user_clause user_lemmas (HOLClause {axiom_name, literals, ...}) =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   407
  member (op =) user_lemmas axiom_name ? fold count_literal literals
21573
8a7a68c0096c Removed the references for counting combinators. Instead they are counted in actual clauses.
paulson
parents: 21561
diff changeset
   408
36228
df47dc6c0e03 got rid of somewhat pointless "pairname" function in Sledgehammer
blanchet
parents: 36222
diff changeset
   409
fun cnf_helper_thms thy = cnf_rules_pairs thy o map (`Thm.get_name_hint)
20644
ff938c7b15e8 Introduced combinators B', C' and S'.
mengj
parents: 20421
diff changeset
   410
31752
19a5f1c8a844 use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents: 31749
diff changeset
   411
fun get_helper_clauses dfg thy isFO (conjectures, axcls, user_lemmas) =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   412
  if isFO then
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   413
    []
23386
9255c1a75ba9 Now also handles FO problems
paulson
parents: 22851
diff changeset
   414
  else
31752
19a5f1c8a844 use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents: 31749
diff changeset
   415
    let
19a5f1c8a844 use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents: 31749
diff changeset
   416
        val axclauses = map #2 (make_axiom_clauses dfg thy axcls)
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   417
        val ct = init_counters |> fold count_clause conjectures
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   418
                               |> fold (count_user_clause user_lemmas) axclauses
33035
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 33029
diff changeset
   419
        fun needed c = the (Symtab.lookup ct c) > 0
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   420
        val IK = if needed "c_COMBI" orelse needed "c_COMBK"
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   421
                 then cnf_helper_thms thy [@{thm COMBI_def}, @{thm COMBK_def}]
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   422
                 else []
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   423
        val BC = if needed "c_COMBB" orelse needed "c_COMBC"
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   424
                 then cnf_helper_thms thy [@{thm COMBB_def}, @{thm COMBC_def}]
21135
07549f79d19c Numerous cosmetic changes.
paulson
parents: 21108
diff changeset
   425
                 else []
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   426
        val S = if needed "c_COMBS" then cnf_helper_thms thy [@{thm COMBS_def}]
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   427
                else []
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   428
        val other = cnf_helper_thms thy [@{thm fequal_imp_equal},
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   429
                                         @{thm equal_imp_fequal}]
20791
497e1c9d4a9f Combinator axioms are now from Isabelle theorems, no need to use helper files.
mengj
parents: 20660
diff changeset
   430
    in
30151
629f3a92863e removed global ref dfg_format
immler@in.tum.de
parents: 30150
diff changeset
   431
        map #2 (make_axiom_clauses dfg thy (other @ IK @ BC @ S))
23386
9255c1a75ba9 Now also handles FO problems
paulson
parents: 22851
diff changeset
   432
    end;
20791
497e1c9d4a9f Combinator axioms are now from Isabelle theorems, no need to use helper files.
mengj
parents: 20660
diff changeset
   433
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   434
(*Find the minimal arity of each function mentioned in the term. Also, note which uses
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   435
  are not at top level, to see if hBOOL is needed.*)
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   436
fun count_constants_term toplev t (const_min_arity, const_needs_hBOOL) =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   437
  let val (head, args) = strip_combterm_comb t
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   438
      val n = length args
36233
1263bef003b3 cosmetics
blanchet
parents: 36231
diff changeset
   439
      val (const_min_arity, const_needs_hBOOL) =
1263bef003b3 cosmetics
blanchet
parents: 36231
diff changeset
   440
        (const_min_arity, const_needs_hBOOL)
1263bef003b3 cosmetics
blanchet
parents: 36231
diff changeset
   441
        |> fold (count_constants_term false) args
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   442
  in
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   443
      case head of
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   444
          CombConst ((a, _),_,_) => (*predicate or function version of "equal"?*)
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   445
            let val a = if a="equal" andalso not toplev then "c_fequal" else a
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   446
            in
36233
1263bef003b3 cosmetics
blanchet
parents: 36231
diff changeset
   447
              (const_min_arity |> Symtab.map_default (a, n) (Integer.min n),
1263bef003b3 cosmetics
blanchet
parents: 36231
diff changeset
   448
               const_needs_hBOOL |> not toplev ? Symtab.update (a, true))
24311
d6864b34eecd proper signature;
wenzelm
parents: 24215
diff changeset
   449
            end
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32960
diff changeset
   450
        | _ => (const_min_arity, const_needs_hBOOL)
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   451
  end;
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   452
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   453
(*A literal is a top-level term*)
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   454
fun count_constants_lit (Literal (_,t)) (const_min_arity, const_needs_hBOOL) =
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   455
  count_constants_term true t (const_min_arity, const_needs_hBOOL);
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   456
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   457
fun count_constants_clause (HOLClause {literals, ...})
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   458
                           (const_min_arity, const_needs_hBOOL) =
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   459
  fold count_constants_lit literals (const_min_arity, const_needs_hBOOL);
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   460
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   461
fun display_arity const_needs_hBOOL (c,n) =
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   462
  trace_msg (fn () => "Constant: " ^ c ^
35826
1590abc3d42a renamed Sledgehammer structures
blanchet
parents: 35825
diff changeset
   463
                " arity:\t" ^ Int.toString n ^
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   464
                (if needs_hBOOL const_needs_hBOOL c then " needs hBOOL" else ""));
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   465
31865
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   466
fun count_constants (conjectures, _, extra_clauses, helper_clauses, _, _) =
30153
051d3825a15d turned "read-only refs" typ_level and minimize_applies into constant values;
wenzelm
parents: 30151
diff changeset
   467
  if minimize_applies then
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   468
     let val (const_min_arity, const_needs_hBOOL) =
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   469
          fold count_constants_clause conjectures (Symtab.empty, Symtab.empty)
31865
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   470
       |> fold count_constants_clause extra_clauses
30149
6b7ad52c5770 removed local ref const_min_arity
immler@in.tum.de
parents: 28835
diff changeset
   471
       |> fold count_constants_clause helper_clauses
30150
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   472
     val _ = List.app (display_arity const_needs_hBOOL) (Symtab.dest (const_min_arity))
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   473
     in (const_min_arity, const_needs_hBOOL) end
4d5a98cebb24 removed local ref const_needs_hBOOL;
immler@in.tum.de
parents: 30149
diff changeset
   474
  else (Symtab.empty, Symtab.empty);
22064
3d716cc9bd7a optimized translation of HO problems
paulson
parents: 21858
diff changeset
   475
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   476
fun header () =
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   477
  "% This file was generated by Isabelle (most likely Sledgehammer)\n" ^
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   478
  "% " ^ timestamp () ^ "\n"
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   479
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   480
(* TPTP format *)
31749
8ee34e3ceb5a corrected comments
immler@in.tum.de
parents: 31409
diff changeset
   481
36222
0e3e49bd658d don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents: 36219
diff changeset
   482
fun write_tptp_file readable_names full_types file clauses =
31409
d8537ba165b5 split preparing clauses and writing problemfile;
immler@in.tum.de
parents: 30242
diff changeset
   483
  let
36167
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 35963
diff changeset
   484
    fun section _ [] = []
c1a35be8e476 make Sledgehammer's output more debugging friendly
blanchet
parents: 35963
diff changeset
   485
      | section name ss = "\n% " ^ name ^ plural_s (length ss) ^ "\n" :: ss
36222
0e3e49bd658d don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents: 36219
diff changeset
   486
    val pool = empty_name_pool readable_names
31865
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   487
    val (conjectures, axclauses, _, helper_clauses,
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   488
      classrel_clauses, arity_clauses) = clauses
31791
c9a1caf218c8 New ATP option: full types
nipkow
parents: 31752
diff changeset
   489
    val (cma, cnh) = count_constants clauses
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35865
diff changeset
   490
    val params = (full_types, cma, cnh)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   491
    val ((conjecture_clss, tfree_litss), pool) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   492
      pool_map (tptp_clause params) conjectures pool |>> ListPair.unzip
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   493
    val tfree_clss = map tptp_tfree_clause (fold (union (op =)) tfree_litss [])
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   494
    val (ax_clss, pool) = pool_map (apfst fst oo tptp_clause params) axclauses
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   495
                                   pool
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   496
    val classrel_clss = map tptp_classrel_clause classrel_clauses
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   497
    val arity_clss = map tptp_arity_clause arity_clauses
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   498
    val (helper_clss, pool) = pool_map (apfst fst oo tptp_clause params)
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   499
                                       helper_clauses pool
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   500
  in
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   501
    File.write_list file
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   502
        (header () ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   503
         section "Relevant fact" ax_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   504
         section "Type variable" tfree_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   505
         section "Conjecture" conjecture_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   506
         section "Class relationship" classrel_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   507
         section "Arity declaration" arity_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   508
         section "Helper fact" helper_clss)
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   509
  end
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   510
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   511
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   512
(* DFG format *)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   513
36222
0e3e49bd658d don't use readable names if proof reconstruction is needed, because it uses the structure of names
blanchet
parents: 36219
diff changeset
   514
fun write_dfg_file full_types file clauses =
31409
d8537ba165b5 split preparing clauses and writing problemfile;
immler@in.tum.de
parents: 30242
diff changeset
   515
  let
36219
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36218
diff changeset
   516
    (* Some of the helper functions below are not name-pool-aware. However,
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36218
diff changeset
   517
       there's no point in adding name pool support if the DFG format is on its
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36218
diff changeset
   518
       way out anyway. *)
16670b4f0baa set SPASS option on the command-line, so that it doesn't vanish when moving to TPTP format
blanchet
parents: 36218
diff changeset
   519
    val pool = NONE
31865
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   520
    val (conjectures, axclauses, _, helper_clauses,
5e97c4abd18e fixed: count constants with supplementary lemmas
immler@in.tum.de
parents: 31839
diff changeset
   521
      classrel_clauses, arity_clauses) = clauses
31791
c9a1caf218c8 New ATP option: full types
nipkow
parents: 31752
diff changeset
   522
    val (cma, cnh) = count_constants clauses
35963
943e2582dc87 added options to Sledgehammer;
blanchet
parents: 35865
diff changeset
   523
    val params = (full_types, cma, cnh)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   524
    val ((conjecture_clss, tfree_litss), pool) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   525
      pool_map (dfg_clause params) conjectures pool |>> ListPair.unzip
31838
607a984b70e3 use structure File instead of TextIO;
immler@in.tum.de
parents: 31837
diff changeset
   526
    and probname = Path.implode (Path.base file)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   527
    val (axstrs, pool) = pool_map (apfst fst oo dfg_clause params) axclauses pool
35865
2f8fb5242799 more Sledgehammer refactoring
blanchet
parents: 35827
diff changeset
   528
    val tfree_clss = map dfg_tfree_clause (union_all tfree_litss)
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   529
    val (helper_clauses_strs, pool) =
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   530
      pool_map (apfst fst oo dfg_clause params) helper_clauses pool
36218
0e4a01f3e7d3 get rid of "List.foldl" + add timestamp to SPASS
blanchet
parents: 36186
diff changeset
   531
    val (funcs, cl_preds) = decls_of_clauses params (helper_clauses @ conjectures @ axclauses) arity_clauses
31409
d8537ba165b5 split preparing clauses and writing problemfile;
immler@in.tum.de
parents: 30242
diff changeset
   532
    and ty_preds = preds_of_clauses axclauses classrel_clauses arity_clauses
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   533
  in
36231
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   534
    File.write_list file
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   535
        (header () ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   536
         string_of_start probname ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   537
         string_of_descrip probname ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   538
         string_of_symbols (string_of_funcs funcs)
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   539
                           (string_of_preds (cl_preds @ ty_preds)) ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   540
         "list_of_clauses(axioms, cnf).\n" ::
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   541
         axstrs @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   542
         map dfg_classrel_clause classrel_clauses @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   543
         map dfg_arity_clause arity_clauses @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   544
         helper_clauses_strs @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   545
         ["end_of_list.\n\nlist_of_clauses(conjectures, cnf).\n"] @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   546
         tfree_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   547
         conjecture_clss @
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   548
         ["end_of_list.\n\n",
bede2d49ba3b get rid of "conjecture_pos", which is no longer necessary now that it's Metis's job, not Sledgehammer's, to report inconsistent contexts
blanchet
parents: 36228
diff changeset
   549
          "end_problem.\n"])
36170
0cdb76723c88 added original constant names to Sledgehammer internal terms + output short names if "debug" is set (for increased readability)
blanchet
parents: 36169
diff changeset
   550
  end
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   551
33311
49cd8abb2863 proper header;
wenzelm
parents: 33042
diff changeset
   552
end;