src/HOL/Tools/ATP/atp_problem.ML
author nik
Thu, 25 Aug 2011 13:55:52 +0100
changeset 44495 4c2242c8a96c
parent 44407 7b6629037127
child 44499 8870232a87ad
permissions -rw-r--r--
added choice operator output for Satallax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38047
9033c03cc214 consequence of directory renaming
blanchet
parents: 38046
diff changeset
     1
(*  Title:      HOL/Tools/ATP/atp_problem.ML
38027
505657ddb047 standardize "Author" tags
blanchet
parents: 38025
diff changeset
     2
    Author:     Jia Meng, Cambridge University Computer Laboratory and NICTA
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
     3
    Author:     Jasmin Blanchette, TU Muenchen
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
     4
39452
70a57e40f795 factored out TSTP/SPASS/Vampire proof parsing;
blanchet
parents: 39384
diff changeset
     5
Abstract representation of ATP problems and TPTP syntax.
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
     6
*)
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
     7
38019
e207a64e1e0b complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents: 38018
diff changeset
     8
signature ATP_PROBLEM =
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
     9
sig
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
    10
  datatype ('a, 'b) ho_term =
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
    11
    ATerm of 'a * ('a, 'b) ho_term list |
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
    12
    AAbs of ('a * 'b) * ('a, 'b) ho_term
37992
7911e78a7122 renamed internal function
blanchet
parents: 37962
diff changeset
    13
  datatype quantifier = AForall | AExists
43163
31babd4b1552 killed odd connectives
blanchet
parents: 43126
diff changeset
    14
  datatype connective = ANot | AAnd | AOr | AImplies | AIff
42531
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
    15
  datatype ('a, 'b, 'c) formula =
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
    16
    AQuant of quantifier * ('a * 'b option) list * ('a, 'b, 'c) formula |
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
    17
    AConn of connective * ('a, 'b, 'c) formula list |
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
    18
    AAtom of 'c
37994
b04307085a09 make TPTP generator accept full first-order formulas
blanchet
parents: 37993
diff changeset
    19
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
    20
  datatype 'a ho_type = AType of 'a | AFun of 'a ho_type * 'a ho_type
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
    21
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    22
  datatype thf_flavor = Without_Choice | With_Choice
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    23
  datatype format =
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    24
    CNF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    25
    CNF_UEQ |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    26
    FOF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    27
    TFF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    28
    THF of thf_flavor
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    29
42525
7a506b0b644f distinguish FOF and TFF (typed first-order) in ATP abstract syntax tree
blanchet
parents: 42449
diff changeset
    30
  datatype formula_kind = Axiom | Definition | Lemma | Hypothesis | Conjecture
42527
6a9458524f01 reintroduced constructor for formulas, and automatically detect which logic to use (TFF or FOF) to avoid clutter
blanchet
parents: 42526
diff changeset
    31
  datatype 'a problem_line =
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
    32
    Decl of string * 'a * 'a ho_type |
44402
f0bc74b9161e clearer terminology
blanchet
parents: 44235
diff changeset
    33
    Formula of string * formula_kind
f0bc74b9161e clearer terminology
blanchet
parents: 44235
diff changeset
    34
               * ('a, 'a ho_type, ('a, 'a ho_type) ho_term) formula
f0bc74b9161e clearer terminology
blanchet
parents: 44235
diff changeset
    35
               * (string, string ho_type) ho_term option
f0bc74b9161e clearer terminology
blanchet
parents: 44235
diff changeset
    36
               * (string, string ho_type) ho_term option
38017
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
    37
  type 'a problem = (string * 'a problem_line list) list
37992
7911e78a7122 renamed internal function
blanchet
parents: 37962
diff changeset
    38
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    39
  val tptp_cnf : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    40
  val tptp_fof : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    41
  val tptp_tff : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    42
  val tptp_thf : string
42967
blanchet
parents: 42966
diff changeset
    43
  val tptp_has_type : string
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
    44
  val tptp_type_of_types : string
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
    45
  val tptp_bool_type : string
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
    46
  val tptp_individual_type : string
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
    47
  val tptp_fun_type : string
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    48
  val tptp_product_type : string
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    49
  val tptp_forall : string
43678
56d352659500 improved translation of lambdas in THF
nik
parents: 43677
diff changeset
    50
  val tptp_ho_forall : string
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    51
  val tptp_exists : string
43678
56d352659500 improved translation of lambdas in THF
nik
parents: 43677
diff changeset
    52
  val tptp_ho_exists : string
44495
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
    53
  val tptp_choice : string
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    54
  val tptp_not : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    55
  val tptp_and : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    56
  val tptp_or : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    57
  val tptp_implies : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    58
  val tptp_if : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    59
  val tptp_iff : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    60
  val tptp_not_iff : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    61
  val tptp_app : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    62
  val tptp_not_infix : string
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
    63
  val tptp_equal : string
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
    64
  val tptp_old_equal : string
42966
4e2d6c1e5392 more work on parsing LEO-II proofs without lambdas
blanchet
parents: 42963
diff changeset
    65
  val tptp_false : string
4e2d6c1e5392 more work on parsing LEO-II proofs without lambdas
blanchet
parents: 42963
diff changeset
    66
  val tptp_true : string
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
    67
  val tptp_empty_list : string
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
    68
  val is_tptp_equal : string -> bool
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    69
  val is_built_in_tptp_symbol : string -> bool
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    70
  val is_tptp_variable : string -> bool
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    71
  val is_tptp_user_symbol : string -> bool
42942
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
    72
  val mk_anot : ('a, 'b, 'c) formula -> ('a, 'b, 'c) formula
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
    73
  val mk_aconn :
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
    74
    connective -> ('a, 'b, 'c) formula -> ('a, 'b, 'c) formula
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
    75
    -> ('a, 'b, 'c) formula
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    76
  val aconn_fold :
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    77
    bool option -> (bool option -> 'a -> 'b -> 'b) -> connective * 'a list
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    78
    -> 'b -> 'b
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    79
  val aconn_map :
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    80
    bool option -> (bool option -> 'a -> ('b, 'c, 'd) formula)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    81
    -> connective * 'a list -> ('b, 'c, 'd) formula
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    82
  val formula_fold :
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    83
    bool option -> (bool option -> 'c -> 'd -> 'd) -> ('a, 'b, 'c) formula
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    84
    -> 'd -> 'd
42944
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
    85
  val formula_map : ('c -> 'd) -> ('a, 'b, 'c) formula -> ('a, 'b, 'd) formula
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
    86
  val is_format_thf : format -> bool
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    87
  val is_format_typed : format -> bool
43224
97906dfd39b7 renamed ML function
blanchet
parents: 43193
diff changeset
    88
  val tptp_lines_for_atp_problem : format -> string problem -> string list
43092
93ec303e1917 more work on new metis that exploits the powerful new type encodings
blanchet
parents: 43085
diff changeset
    89
  val ensure_cnf_problem :
93ec303e1917 more work on new metis that exploits the powerful new type encodings
blanchet
parents: 43085
diff changeset
    90
    (string * string) problem -> (string * string) problem
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
    91
  val filter_cnf_ueq_problem :
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
    92
    (string * string) problem -> (string * string) problem
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    93
  val declare_undeclared_syms_in_atp_problem :
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
    94
    string -> string -> (string * string) problem -> (string * string) problem
39452
70a57e40f795 factored out TSTP/SPASS/Vampire proof parsing;
blanchet
parents: 39384
diff changeset
    95
  val nice_atp_problem :
38017
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
    96
    bool -> ('a * (string * string) problem_line list) list
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
    97
    -> ('a * string problem_line list) list
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
    98
       * (string Symtab.table * string Symtab.table) option
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
    99
end;
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
   100
38019
e207a64e1e0b complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents: 38018
diff changeset
   101
structure ATP_Problem : ATP_PROBLEM =
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
   102
struct
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
   103
43085
0a2f5b86bdd7 first step in sharing more code between ATP and Metis translation
blanchet
parents: 43000
diff changeset
   104
open ATP_Util
0a2f5b86bdd7 first step in sharing more code between ATP and Metis translation
blanchet
parents: 43000
diff changeset
   105
0a2f5b86bdd7 first step in sharing more code between ATP and Metis translation
blanchet
parents: 43000
diff changeset
   106
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   107
(** ATP problem **)
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   108
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   109
datatype ('a, 'b) ho_term =
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   110
  ATerm of 'a * ('a, 'b) ho_term list |
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   111
  AAbs of ('a * 'b) * ('a, 'b) ho_term
37961
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   112
datatype quantifier = AForall | AExists
43163
31babd4b1552 killed odd connectives
blanchet
parents: 43126
diff changeset
   113
datatype connective = ANot | AAnd | AOr | AImplies | AIff
42531
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
   114
datatype ('a, 'b, 'c) formula =
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
   115
  AQuant of quantifier * ('a * 'b option) list * ('a, 'b, 'c) formula |
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
   116
  AConn of connective * ('a, 'b, 'c) formula list |
a462dbaa584f added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents: 42530
diff changeset
   117
  AAtom of 'c
37961
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   118
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   119
datatype 'a ho_type = AType of 'a | AFun of 'a ho_type * 'a ho_type
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   120
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   121
datatype thf_flavor = Without_Choice | With_Choice
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   122
datatype format =
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   123
  CNF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   124
  CNF_UEQ |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   125
  FOF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   126
  TFF |
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   127
  THF of thf_flavor
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   128
42525
7a506b0b644f distinguish FOF and TFF (typed first-order) in ATP abstract syntax tree
blanchet
parents: 42449
diff changeset
   129
datatype formula_kind = Axiom | Definition | Lemma | Hypothesis | Conjecture
42527
6a9458524f01 reintroduced constructor for formulas, and automatically detect which logic to use (TFF or FOF) to avoid clutter
blanchet
parents: 42526
diff changeset
   130
datatype 'a problem_line =
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   131
  Decl of string * 'a * 'a ho_type |
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   132
  Formula of string * formula_kind * ('a, 'a ho_type, ('a, 'a ho_type) ho_term) formula
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   133
             * (string, string ho_type) ho_term option * (string, string ho_type) ho_term option
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   134
type 'a problem = (string * 'a problem_line list) list
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   135
42722
626e292d22a7 renamed type systems for more consistency
blanchet
parents: 42709
diff changeset
   136
(* official TPTP syntax *)
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   137
val tptp_cnf = "cnf"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   138
val tptp_fof = "fof"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   139
val tptp_tff = "tff"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   140
val tptp_thf = "thf"
42967
blanchet
parents: 42966
diff changeset
   141
val tptp_has_type = ":"
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   142
val tptp_type_of_types = "$tType"
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   143
val tptp_bool_type = "$o"
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   144
val tptp_individual_type = "$i"
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   145
val tptp_fun_type = ">"
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   146
val tptp_product_type = "*"
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   147
val tptp_forall = "!"
43678
56d352659500 improved translation of lambdas in THF
nik
parents: 43677
diff changeset
   148
val tptp_ho_forall = "!!"
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   149
val tptp_exists = "?"
43678
56d352659500 improved translation of lambdas in THF
nik
parents: 43677
diff changeset
   150
val tptp_ho_exists = "??"
44495
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   151
val tptp_choice = "@+"
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   152
val tptp_not = "~"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   153
val tptp_and = "&"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   154
val tptp_or = "|"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   155
val tptp_implies = "=>"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   156
val tptp_if = "<="
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   157
val tptp_iff = "<=>"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   158
val tptp_not_iff = "<~>"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   159
val tptp_app = "@"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   160
val tptp_not_infix = "!"
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   161
val tptp_equal = "="
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   162
val tptp_old_equal = "equal"
42966
4e2d6c1e5392 more work on parsing LEO-II proofs without lambdas
blanchet
parents: 42963
diff changeset
   163
val tptp_false = "$false"
4e2d6c1e5392 more work on parsing LEO-II proofs without lambdas
blanchet
parents: 42963
diff changeset
   164
val tptp_true = "$true"
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   165
val tptp_empty_list = "[]"
42722
626e292d22a7 renamed type systems for more consistency
blanchet
parents: 42709
diff changeset
   166
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   167
fun is_tptp_equal s = (s = tptp_equal orelse s = tptp_old_equal)
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   168
fun is_built_in_tptp_symbol s =
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   169
  s = tptp_old_equal orelse not (Char.isAlpha (String.sub (s, 0)))
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   170
fun is_tptp_variable s = Char.isUpper (String.sub (s, 0))
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   171
val is_tptp_user_symbol = not o (is_tptp_variable orf is_built_in_tptp_symbol)
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   172
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   173
fun raw_polarities_of_conn ANot = (SOME false, NONE)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   174
  | raw_polarities_of_conn AAnd = (SOME true, SOME true)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   175
  | raw_polarities_of_conn AOr = (SOME true, SOME true)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   176
  | raw_polarities_of_conn AImplies = (SOME false, SOME true)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   177
  | raw_polarities_of_conn AIff = (NONE, NONE)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   178
fun polarities_of_conn NONE = K (NONE, NONE)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   179
  | polarities_of_conn (SOME pos) =
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   180
    raw_polarities_of_conn #> not pos ? pairself (Option.map not)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   181
42942
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
   182
fun mk_anot (AConn (ANot, [phi])) = phi
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
   183
  | mk_anot phi = AConn (ANot, [phi])
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
   184
fun mk_aconn c phi1 phi2 = AConn (c, [phi1, phi2])
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
   185
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   186
fun aconn_fold pos f (ANot, [phi]) = f (Option.map not pos) phi
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   187
  | aconn_fold pos f (AImplies, [phi1, phi2]) =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   188
    f (Option.map not pos) phi1 #> f pos phi2
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   189
  | aconn_fold pos f (AAnd, phis) = fold (f pos) phis
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   190
  | aconn_fold pos f (AOr, phis) = fold (f pos) phis
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   191
  | aconn_fold _ f (_, phis) = fold (f NONE) phis
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   192
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   193
fun aconn_map pos f (ANot, [phi]) = AConn (ANot, [f (Option.map not pos) phi])
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   194
  | aconn_map pos f (AImplies, [phi1, phi2]) =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   195
    AConn (AImplies, [f (Option.map not pos) phi1, f pos phi2])
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   196
  | aconn_map pos f (AAnd, phis) = AConn (AAnd, map (f pos) phis)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   197
  | aconn_map pos f (AOr, phis) = AConn (AOr, map (f pos) phis)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   198
  | aconn_map _ f (c, phis) = AConn (c, map (f NONE) phis)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   199
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   200
fun formula_fold pos f =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   201
  let
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   202
    fun aux pos (AQuant (_, _, phi)) = aux pos phi
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   203
      | aux pos (AConn conn) = aconn_fold pos aux conn
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   204
      | aux pos (AAtom tm) = f pos tm
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   205
  in aux pos end
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   206
42944
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   207
fun formula_map f (AQuant (q, xs, phi)) = AQuant (q, xs, formula_map f phi)
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   208
  | formula_map f (AConn (c, phis)) = AConn (c, map (formula_map f) phis)
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   209
  | formula_map f (AAtom tm) = AAtom (f tm)
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   210
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   211
fun is_format_thf (THF _) = true
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   212
  | is_format_thf _ = false
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   213
fun is_format_typed TFF = true
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   214
  | is_format_typed (THF _) = true
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   215
  | is_format_typed _ = false
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   216
38631
979a0b37f981 prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents: 38613
diff changeset
   217
fun string_for_kind Axiom = "axiom"
41769
eb2e39555f98 extended ATP problem syntax to support other applications than Sledgehammer, e.g. experiments with ATPs
blanchet
parents: 41491
diff changeset
   218
  | string_for_kind Definition = "definition"
eb2e39555f98 extended ATP problem syntax to support other applications than Sledgehammer, e.g. experiments with ATPs
blanchet
parents: 41491
diff changeset
   219
  | string_for_kind Lemma = "lemma"
38631
979a0b37f981 prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents: 38613
diff changeset
   220
  | string_for_kind Hypothesis = "hypothesis"
979a0b37f981 prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents: 38613
diff changeset
   221
  | string_for_kind Conjecture = "conjecture"
979a0b37f981 prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents: 38613
diff changeset
   222
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   223
fun strip_tff_type (AFun (AType s, ty)) = strip_tff_type ty |>> cons s
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   224
  | strip_tff_type (AFun (AFun _, _)) =
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   225
    raise Fail "unexpected higher-order type in first-order format"
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   226
  | strip_tff_type (AType s) = ([], s)
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   227
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   228
fun string_for_type (THF _) ty =
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   229
    let
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   230
      fun aux _ (AType s) = s
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   231
        | aux rhs (AFun (ty1, ty2)) =
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   232
          aux false ty1 ^ " " ^ tptp_fun_type ^ " " ^ aux true ty2
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   233
          |> not rhs ? enclose "(" ")"
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   234
    in aux true ty end
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   235
  | string_for_type TFF ty =
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   236
    (case strip_tff_type ty of
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   237
       ([], s) => s
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   238
     | ([s'], s) => s' ^ " " ^ tptp_fun_type ^ " " ^ s
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   239
     | (ss, s) =>
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   240
       "(" ^ space_implode (" " ^ tptp_product_type ^ " ") ss ^ ") " ^
42994
fe291ab75eb5 towards supporting non-simply-typed encodings for TFF and THF (for orthogonality and experiments)
blanchet
parents: 42974
diff changeset
   241
       tptp_fun_type ^ " " ^ s)
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   242
  | string_for_type _ _ = raise Fail "unexpected type in untyped format"
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   243
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   244
fun string_for_quantifier AForall = tptp_forall
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   245
  | string_for_quantifier AExists = tptp_exists
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   246
42967
blanchet
parents: 42966
diff changeset
   247
fun string_for_connective ANot = tptp_not
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   248
  | string_for_connective AAnd = tptp_and
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   249
  | string_for_connective AOr = tptp_or
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   250
  | string_for_connective AImplies = tptp_implies
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   251
  | string_for_connective AIff = tptp_iff
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   252
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   253
fun string_for_bound_var format (s, ty) =
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   254
  s ^ (if is_format_typed format then
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   255
         " " ^ tptp_has_type ^ " " ^
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   256
         string_for_type format (ty |> the_default (AType tptp_individual_type))
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   257
       else
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   258
         "")
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   259
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   260
fun string_for_term _ (ATerm (s, [])) = s
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   261
  | string_for_term format (ATerm (s, ts)) =
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   262
    if s = tptp_empty_list then
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   263
      (* used for lists in the optional "source" field of a derivation *)
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   264
      "[" ^ commas (map (string_for_term format) ts) ^ "]"
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   265
    else if is_tptp_equal s then
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   266
      space_implode (" " ^ tptp_equal ^ " ") (map (string_for_term format) ts)
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   267
      |> is_format_thf format ? enclose "(" ")"
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   268
    else
44495
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   269
      (case (s = tptp_ho_forall orelse s = tptp_ho_exists,
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   270
             s = tptp_choice andalso format = THF With_Choice, ts) of
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   271
         (true, _, [AAbs ((s', ty), tm)]) =>
43987
2850b7dc27a4 further worked around LEO-II parser limitation, with eta-expansion
blanchet
parents: 43986
diff changeset
   272
         (* Use syntactic sugar "!" and "?" instead of "!!" and "??" whenever
2850b7dc27a4 further worked around LEO-II parser limitation, with eta-expansion
blanchet
parents: 43986
diff changeset
   273
            possible, to work around LEO-II 1.2.8 parser limitation. *)
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   274
         string_for_formula format
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   275
             (AQuant (if s = tptp_ho_forall then AForall else AExists,
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   276
                      [(s', SOME ty)], AAtom tm))
44495
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   277
       | (_, true, [AAbs ((s', ty), tm)]) =>
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   278
         (*There is code in ATP_Translate to ensure that Eps is always applied
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   279
           to an abstraction*)
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   280
         tptp_choice ^ "[" ^ s' ^ " : " ^ string_for_type format ty ^ "] : " ^
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   281
           string_for_term format tm ^ ""
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   282
         |> enclose "(" ")"
4c2242c8a96c added choice operator output for
nik
parents: 44407
diff changeset
   283
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   284
       | _ =>
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   285
         let val ss = map (string_for_term format) ts in
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   286
           if is_format_thf format then
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   287
             "(" ^ space_implode (" " ^ tptp_app ^ " ") (s :: ss) ^ ")"
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   288
           else
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   289
             s ^ "(" ^ commas ss ^ ")"
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   290
         end)
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   291
  | string_for_term (format as THF _) (AAbs ((s, ty), tm)) =
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   292
    "(^[" ^ s ^ " : " ^ string_for_type format ty ^ "] : " ^
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   293
    string_for_term format tm ^ ")"
43986
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   294
  | string_for_term _ _ = raise Fail "unexpected term in first-order format"
85c91284ed94 use syntactic sugar whenever possible in THF problems, to work around current LEO-II parser limitation (bang bang and query query are not handled correctly)
blanchet
parents: 43827
diff changeset
   295
and string_for_formula format (AQuant (q, xs, phi)) =
42974
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   296
    string_for_quantifier q ^
42722
626e292d22a7 renamed type systems for more consistency
blanchet
parents: 42709
diff changeset
   297
    "[" ^ commas (map (string_for_bound_var format) xs) ^ "] : " ^
42974
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   298
    string_for_formula format phi
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   299
    |> enclose "(" ")"
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   300
  | string_for_formula format
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   301
        (AConn (ANot, [AAtom (ATerm ("=" (* tptp_equal *), ts))])) =
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   302
    space_implode (" " ^ tptp_not_infix ^ tptp_equal ^ " ")
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   303
                  (map (string_for_term format) ts)
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   304
    |> is_format_thf format ? enclose "(" ")"
42722
626e292d22a7 renamed type systems for more consistency
blanchet
parents: 42709
diff changeset
   305
  | string_for_formula format (AConn (c, [phi])) =
42974
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   306
    string_for_connective c ^ " " ^
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   307
    (string_for_formula format phi |> is_format_thf format ? enclose "(" ")")
42974
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   308
    |> enclose "(" ")"
42722
626e292d22a7 renamed type systems for more consistency
blanchet
parents: 42709
diff changeset
   309
  | string_for_formula format (AConn (c, phis)) =
42974
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   310
    space_implode (" " ^ string_for_connective c ^ " ")
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   311
                  (map (string_for_formula format) phis)
347d5197896e ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents: 42968
diff changeset
   312
    |> enclose "(" ")"
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   313
  | string_for_formula format (AAtom tm) = string_for_term format tm
37961
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   314
43692
264881a20f50 make SML/NJ happy + tuning
blanchet
parents: 43678
diff changeset
   315
fun the_source (SOME source) = source
264881a20f50 make SML/NJ happy + tuning
blanchet
parents: 43678
diff changeset
   316
  | the_source NONE =
264881a20f50 make SML/NJ happy + tuning
blanchet
parents: 43678
diff changeset
   317
    ATerm ("inference",
264881a20f50 make SML/NJ happy + tuning
blanchet
parents: 43678
diff changeset
   318
           ATerm ("isabelle", []) :: replicate 2 (ATerm ("[]", [])))
42639
9d774c5d42a2 proper default for TPTP source filed
blanchet
parents: 42589
diff changeset
   319
43092
93ec303e1917 more work on new metis that exploits the powerful new type encodings
blanchet
parents: 43085
diff changeset
   320
fun string_for_format CNF = tptp_cnf
93ec303e1917 more work on new metis that exploits the powerful new type encodings
blanchet
parents: 43085
diff changeset
   321
  | string_for_format CNF_UEQ = tptp_cnf
42968
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   322
  | string_for_format FOF = tptp_fof
74415622d293 more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents: 42967
diff changeset
   323
  | string_for_format TFF = tptp_tff
44235
85e9dad3c187 distinguish THF syntax with and without choice (Satallax vs. LEO-II)
blanchet
parents: 43987
diff changeset
   324
  | string_for_format (THF _) = tptp_thf
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   325
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   326
fun string_for_problem_line format (Decl (ident, sym, ty)) =
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   327
    string_for_format format ^ "(" ^ ident ^ ", type,\n    " ^ sym ^ " : " ^
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   328
    string_for_type format ty ^ ").\n"
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   329
  | string_for_problem_line format (Formula (ident, kind, phi, source, info)) =
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   330
    string_for_format format ^ "(" ^ ident ^ ", " ^ string_for_kind kind ^
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   331
    ",\n    (" ^ string_for_formula format phi ^ ")" ^
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   332
    (case (source, info) of
42709
e7af132d48fe allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet
parents: 42659
diff changeset
   333
       (NONE, NONE) => ""
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   334
     | (SOME tm, NONE) => ", " ^ string_for_term format tm
42709
e7af132d48fe allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet
parents: 42659
diff changeset
   335
     | (_, SOME tm) =>
43692
264881a20f50 make SML/NJ happy + tuning
blanchet
parents: 43678
diff changeset
   336
       ", " ^ string_for_term format (the_source source) ^
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   337
       ", " ^ string_for_term format tm) ^ ").\n"
43224
97906dfd39b7 renamed ML function
blanchet
parents: 43193
diff changeset
   338
fun tptp_lines_for_atp_problem format problem =
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   339
  "% This file was generated by Isabelle (most likely Sledgehammer)\n\
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   340
  \% " ^ timestamp () ^ "\n" ::
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   341
  maps (fn (_, []) => []
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   342
         | (heading, lines) =>
41491
a2ad5b824051 eliminated Int.toString;
wenzelm
parents: 39453
diff changeset
   343
           "\n% " ^ heading ^ " (" ^ string_of_int (length lines) ^ ")\n" ::
42709
e7af132d48fe allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet
parents: 42659
diff changeset
   344
           map (string_for_problem_line format) lines)
38631
979a0b37f981 prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents: 38613
diff changeset
   345
       problem
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   346
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   347
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   348
(** CNF (Metis) and CNF UEQ (Waldmeister) **)
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   349
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   350
fun is_problem_line_negated (Formula (_, _, AConn (ANot, _), _, _)) = true
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   351
  | is_problem_line_negated _ = false
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   352
43193
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   353
fun is_problem_line_cnf_ueq (Formula (_, _, AAtom (ATerm ((s, _), _)), _, _)) =
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   354
    is_tptp_equal s
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   355
  | is_problem_line_cnf_ueq _ = false
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   356
42944
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   357
fun open_conjecture_term (ATerm ((s, s'), tms)) =
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   358
    ATerm (if is_tptp_variable s then (s |> Name.desymbolize false, s')
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   359
           else (s, s'), tms |> map open_conjecture_term)
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   360
  | open_conjecture_term _ = raise Fail "unexpected higher-order term"
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   361
fun open_formula conj =
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   362
  let
43193
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   363
    (* We are conveniently assuming that all bound variable names are
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   364
       distinct, which should be the case for the formulas we generate. *)
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   365
    fun opn (pos as SOME true) (AQuant (AForall, _, phi)) = opn pos phi
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   366
      | opn (pos as SOME false) (AQuant (AExists, _, phi)) = opn pos phi
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   367
      | opn pos (AConn (ANot, [phi])) = mk_anot (opn (Option.map not pos) phi)
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   368
      | opn pos (AConn (c, [phi1, phi2])) =
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   369
        let val (pos1, pos2) = polarities_of_conn pos c in
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   370
          AConn (c, [opn pos1 phi1, opn pos2 phi2])
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   371
        end
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   372
      | opn _ (AAtom t) = AAtom (t |> conj ? open_conjecture_term)
43422
dcbedaf6f80c added missing case in pattern matching -- solves Waldmeister "Match" exceptions that have been plaguing some users
blanchet
parents: 43295
diff changeset
   373
      | opn _ phi = phi
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   374
  in opn (SOME (not conj)) end
42944
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   375
fun open_formula_line (Formula (ident, kind, phi, source, info)) =
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   376
    Formula (ident, kind, open_formula (kind = Conjecture) phi, source, info)
9e620869a576 improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents: 42942
diff changeset
   377
  | open_formula_line line = line
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   378
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   379
fun negate_conjecture_line (Formula (ident, Conjecture, phi, source, info)) =
42942
ad34216cff2f removed SNARK hack now that SNARK is fixed
blanchet
parents: 42939
diff changeset
   380
    Formula (ident, Hypothesis, mk_anot phi, source, info)
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   381
  | negate_conjecture_line line = line
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   382
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   383
exception CLAUSIFY of unit
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   384
43126
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   385
(* This "clausification" only expands syntactic sugar, such as "phi => psi" to
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   386
   "~ phi | psi" and "phi <=> psi" to "~ phi | psi" and "~ psi | phi". We don't
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   387
   attempt to distribute conjunctions over disjunctions. *)
43193
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   388
fun clausify_formula pos (phi as AAtom _) = [phi |> not pos ? mk_anot]
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   389
  | clausify_formula pos (AConn (ANot, [phi])) = clausify_formula (not pos) phi
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   390
  | clausify_formula true (AConn (AOr, [phi1, phi2])) =
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   391
    (phi1, phi2) |> pairself (clausify_formula true)
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   392
                 |> uncurry (map_product (mk_aconn AOr))
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   393
  | clausify_formula false (AConn (AAnd, [phi1, phi2])) =
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   394
    (phi1, phi2) |> pairself (clausify_formula false)
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   395
                 |> uncurry (map_product (mk_aconn AOr))
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   396
  | clausify_formula true (AConn (AImplies, [phi1, phi2])) =
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   397
    clausify_formula true (AConn (AOr, [mk_anot phi1, phi2]))
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   398
  | clausify_formula true (AConn (AIff, phis)) =
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   399
    clausify_formula true (AConn (AImplies, phis)) @
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   400
    clausify_formula true (AConn (AImplies, rev phis))
e11bd628f1a5 improved ATP clausifier so it can deal with "x => (y <=> z)"
blanchet
parents: 43163
diff changeset
   401
  | clausify_formula _ _ = raise CLAUSIFY ()
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   402
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   403
fun clausify_formula_line (Formula (ident, kind, phi, source, info)) =
43126
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   404
    let
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   405
      val (n, phis) = phi |> try (clausify_formula true) |> these |> `length
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   406
    in
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   407
      map2 (fn phi => fn j =>
43295
30aaab778416 pass Metis facts and negated conjecture as facts, with (almost) correctly set localities, so that the correct encoding is used for nonmonotonic occurrences of infinite types
blanchet
parents: 43224
diff changeset
   408
               Formula (ident ^ replicate_string (j - 1) "x", kind, phi, source,
30aaab778416 pass Metis facts and negated conjecture as facts, with (almost) correctly set localities, so that the correct encoding is used for nonmonotonic occurrences of infinite types
blanchet
parents: 43224
diff changeset
   409
                        info))
43126
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   410
           phis (1 upto n)
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   411
    end
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   412
  | clausify_formula_line _ = []
43098
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   413
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   414
fun ensure_cnf_problem_line line =
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   415
  line |> open_formula_line |> negate_conjecture_line |> clausify_formula_line
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   416
e88e974c4846 proper handling of type variable classes in new Metis
blanchet
parents: 43092
diff changeset
   417
fun ensure_cnf_problem problem =
43126
a7db0afd5200 clausify "<=>" (needed for some type information)
blanchet
parents: 43098
diff changeset
   418
  problem |> map (apsnd (maps ensure_cnf_problem_line))
43092
93ec303e1917 more work on new metis that exploits the powerful new type encodings
blanchet
parents: 43085
diff changeset
   419
42962
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   420
fun filter_cnf_ueq_problem problem =
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   421
  problem
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   422
  |> map (apsnd (map open_formula_line
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   423
                 #> filter is_problem_line_cnf_ueq
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   424
                 #> map negate_conjecture_line))
3b50fdeb6cfc started adding support for THF output (but no lambdas)
blanchet
parents: 42961
diff changeset
   425
  |> (fn problem =>
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   426
         let
43824
0234156d3fbe don't generate Waldmeister problems with only a conjecture, since it makes it crash sometimes
blanchet
parents: 43692
diff changeset
   427
           val lines = problem |> maps snd
0234156d3fbe don't generate Waldmeister problems with only a conjecture, since it makes it crash sometimes
blanchet
parents: 43692
diff changeset
   428
           val conjs = lines |> filter is_problem_line_negated
0234156d3fbe don't generate Waldmeister problems with only a conjecture, since it makes it crash sometimes
blanchet
parents: 43692
diff changeset
   429
         in if length conjs = 1 andalso conjs <> lines then problem else [] end)
38017
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
   430
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   431
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   432
(** Symbol declarations **)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   433
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   434
(* TFF allows implicit declarations of types, function symbols, and predicate
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   435
   symbols (with "$i" as the type of individuals), but some provers (e.g.,
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   436
   SNARK) require explicit declarations. The situation is similar for THF. *)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   437
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   438
val atype_of_types = AType (`I tptp_type_of_types)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   439
val bool_atype = AType (`I tptp_bool_type)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   440
val individual_atype = AType (`I tptp_individual_type)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   441
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   442
fun default_type pred_sym =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   443
  let
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   444
    fun typ 0 = if pred_sym then bool_atype else individual_atype
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   445
      | typ ary = AFun (individual_atype, typ (ary - 1))
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   446
  in typ end
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   447
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   448
fun add_declared_syms_in_problem_line (Decl (_, sym, _)) = insert (op =) sym
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   449
  | add_declared_syms_in_problem_line _ = I
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   450
fun declared_syms_in_problem problem =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   451
  fold (fold add_declared_syms_in_problem_line o snd) problem []
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   452
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   453
fun undeclared_syms_in_problem declared problem =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   454
  let
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   455
    fun do_sym name ty =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   456
      if member (op =) declared name then I else AList.default (op =) (name, ty)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   457
    fun do_type (AFun (ty1, ty2)) = fold do_type [ty1, ty2]
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   458
      | do_type (AType name) = do_sym name (K atype_of_types)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   459
    fun do_term pred_sym (ATerm (name as (s, _), tms)) =
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   460
        is_tptp_user_symbol s
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   461
        ? do_sym name (fn _ => default_type pred_sym (length tms))
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   462
        #> fold (do_term false) tms
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   463
      | do_term _ (AAbs ((_, ty), tm)) = do_type ty #> do_term false tm
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   464
    fun do_formula (AQuant (_, xs, phi)) =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   465
        fold do_type (map_filter snd xs) #> do_formula phi
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   466
      | do_formula (AConn (_, phis)) = fold do_formula phis
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   467
      | do_formula (AAtom tm) = do_term true tm
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   468
    fun do_problem_line (Decl (_, _, ty)) = do_type ty
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   469
      | do_problem_line (Formula (_, _, phi, _, _)) = do_formula phi
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   470
  in
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   471
    fold (fold do_problem_line o snd) problem []
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   472
    |> filter_out (is_built_in_tptp_symbol o fst o fst)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   473
  end
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   474
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   475
fun declare_undeclared_syms_in_atp_problem prefix heading problem =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   476
  let
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   477
    fun decl_line (x as (s, _), ty) = Decl (prefix ^ s, x, ty ())
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   478
    val declared = problem |> declared_syms_in_problem
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   479
    val decls =
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   480
      problem |> undeclared_syms_in_problem declared
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   481
              |> sort_wrt (fst o fst)
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   482
              |> map decl_line
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   483
  in (heading, decls) :: problem end
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   484
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   485
(** Nice names **)
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   486
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   487
fun empty_name_pool readable_names =
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   488
  if readable_names then SOME (Symtab.empty, Symtab.empty) else NONE
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   489
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   490
fun pool_fold f xs z = pair z #> fold_rev (fn x => uncurry (f x)) xs
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   491
fun pool_map f xs =
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   492
  pool_fold (fn x => fn ys => fn pool => f x pool |>> (fn y => y :: ys)) xs []
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   493
42227
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   494
val no_qualifiers =
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   495
  let
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   496
    fun skip [] = []
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   497
      | skip (#"." :: cs) = skip cs
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   498
      | skip (c :: cs) = if Char.isAlphaNum c then skip cs else c :: keep cs
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   499
    and keep [] = []
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   500
      | keep (#"." :: cs) = skip cs
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   501
      | keep (c :: cs) = c :: keep cs
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   502
  in String.explode #> rev #> keep #> rev #> String.implode end
662b50b7126f if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents: 41769
diff changeset
   503
42761
8ea9c6fa8b53 fixed several bugs in Isar proof reconstruction, in particular w.r.t. mangled types and hAPP
blanchet
parents: 42752
diff changeset
   504
(* Long names can slow down the ATPs. *)
42724
4d6bcf846759 added "max_mono_instances" option to Sledgehammer and renamed old "monomorphize_limit" option
blanchet
parents: 42722
diff changeset
   505
val max_readable_name_size = 20
42567
d012947edd36 shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents: 42543
diff changeset
   506
43000
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   507
(* "equal" is reserved by some ATPs. "op" is also reserved, to avoid the
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   508
   unreadable "op_1", "op_2", etc., in the problem files. "eq" is reserved to
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   509
   ensure that "HOL.eq" is correctly mapped to equality (not clear whether this
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   510
   is still necessary). *)
bd424c3dde46 cleaner handling of equality and proxies (esp. for THF)
blanchet
parents: 42998
diff changeset
   511
val reserved_nice_names = [tptp_old_equal, "op", "eq"]
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   512
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   513
fun readable_name full_name s =
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   514
  if s = full_name then
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   515
    s
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   516
  else
42567
d012947edd36 shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents: 42543
diff changeset
   517
    s |> no_qualifiers
44407
7b6629037127 tuning ATP problem output
blanchet
parents: 44402
diff changeset
   518
      |> perhaps (try (unprefix "'"))
42567
d012947edd36 shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents: 42543
diff changeset
   519
      |> Name.desymbolize (Char.isUpper (String.sub (full_name, 0)))
42583
84b134118616 avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents: 42577
diff changeset
   520
      |> (fn s =>
42659
8d53e7945078 fixed long name truncation logic
blanchet
parents: 42644
diff changeset
   521
             if size s > max_readable_name_size then
8d53e7945078 fixed long name truncation logic
blanchet
parents: 42644
diff changeset
   522
               String.substring (s, 0, max_readable_name_size div 2 - 4) ^
43827
62d64709af3b added option to control which lambda translation to use (for experiments)
blanchet
parents: 43824
diff changeset
   523
               string_of_int (hash_string full_name) ^
42659
8d53e7945078 fixed long name truncation logic
blanchet
parents: 42644
diff changeset
   524
               String.extract (s, size s - max_readable_name_size div 2 + 4,
8d53e7945078 fixed long name truncation logic
blanchet
parents: 42644
diff changeset
   525
                               NONE)
42583
84b134118616 avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents: 42577
diff changeset
   526
             else
84b134118616 avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents: 42577
diff changeset
   527
               s)
42567
d012947edd36 shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents: 42543
diff changeset
   528
      |> (fn s => if member (op =) reserved_nice_names s then full_name else s)
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   529
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   530
fun nice_name (full_name, _) NONE = (full_name, NONE)
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   531
  | nice_name (full_name, desired_name) (SOME the_pool) =
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   532
    if is_built_in_tptp_symbol full_name then
39384
76603e40bd4c in debug mode, don't touch "$true" and "$false"
blanchet
parents: 39109
diff changeset
   533
      (full_name, SOME the_pool)
76603e40bd4c in debug mode, don't touch "$true" and "$false"
blanchet
parents: 39109
diff changeset
   534
    else case Symtab.lookup (fst the_pool) full_name of
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   535
      SOME nice_name => (nice_name, SOME the_pool)
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   536
    | NONE =>
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   537
      let
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   538
        val nice_prefix = readable_name full_name desired_name
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   539
        fun add j =
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   540
          let
42644
9dd98edd48c2 SNARK workaround
blanchet
parents: 42639
diff changeset
   541
            val nice_name =
44407
7b6629037127 tuning ATP problem output
blanchet
parents: 44402
diff changeset
   542
              nice_prefix ^ (if j = 0 then "" else string_of_int j)
37624
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   543
          in
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   544
            case Symtab.lookup (snd the_pool) nice_name of
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   545
              SOME full_name' =>
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   546
              if full_name = full_name' then (nice_name, the_pool)
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   547
              else add (j + 1)
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   548
            | NONE =>
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   549
              (nice_name,
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   550
               (Symtab.update_new (full_name, nice_name) (fst the_pool),
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   551
                Symtab.update_new (nice_name, full_name) (snd the_pool)))
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   552
          end
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   553
      in add 0 |> apsnd SOME end
3ee568334813 move "nice names" from Metis to TPTP format
blanchet
parents: 37617
diff changeset
   554
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   555
fun nice_type (AType name) = nice_name name #>> AType
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   556
  | nice_type (AFun (ty1, ty2)) = nice_type ty1 ##>> nice_type ty2 #>> AFun
43676
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   557
fun nice_term (ATerm (name, ts)) =
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   558
    nice_name name ##>> pool_map nice_term ts #>> ATerm
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   559
  | nice_term (AAbs ((name, ty), tm)) =
3b0b448b4d69 add support for lambdas in TPTP THF generator + killed an unsound type encoding (because the monotonicity calculus assumes first-order)
nik
parents: 43422
diff changeset
   560
    nice_name name ##>> nice_type ty ##>> nice_term tm #>> AAbs
37961
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   561
fun nice_formula (AQuant (q, xs, phi)) =
42526
46d485f8d144 added room for types in ATP quantifiers
blanchet
parents: 42525
diff changeset
   562
    pool_map nice_name (map fst xs)
46d485f8d144 added room for types in ATP quantifiers
blanchet
parents: 42525
diff changeset
   563
    ##>> pool_map (fn NONE => pair NONE
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   564
                    | SOME ty => nice_type ty #>> SOME) (map snd xs)
42526
46d485f8d144 added room for types in ATP quantifiers
blanchet
parents: 42525
diff changeset
   565
    ##>> nice_formula phi
46d485f8d144 added room for types in ATP quantifiers
blanchet
parents: 42525
diff changeset
   566
    #>> (fn ((ss, ts), phi) => AQuant (q, ss ~~ ts, phi))
37961
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   567
  | nice_formula (AConn (c, phis)) =
6a48c85a211a first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents: 37931
diff changeset
   568
    pool_map nice_formula phis #>> curry AConn c
38034
ecae87b9b9c4 renaming
blanchet
parents: 38027
diff changeset
   569
  | nice_formula (AAtom tm) = nice_term tm #>> AAtom
42963
5725deb11ae7 identify HOL functions with THF functions
blanchet
parents: 42962
diff changeset
   570
fun nice_problem_line (Decl (ident, sym, ty)) =
42998
1c80902d0456 fully support all type system encodings in typed formats (TFF, THF)
blanchet
parents: 42994
diff changeset
   571
    nice_name sym ##>> nice_type ty #>> (fn (sym, ty) => Decl (ident, sym, ty))
42939
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   572
  | nice_problem_line (Formula (ident, kind, phi, source, info)) =
0134d6650092 added support for remote Waldmeister
blanchet
parents: 42937
diff changeset
   573
    nice_formula phi #>> (fn phi => Formula (ident, kind, phi, source, info))
37931
7b452ff6bff0 no polymorphic "var"s
blanchet
parents: 37926
diff changeset
   574
fun nice_problem problem =
37643
f576af716aa6 rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents: 37642
diff changeset
   575
  pool_map (fn (heading, lines) =>
37931
7b452ff6bff0 no polymorphic "var"s
blanchet
parents: 37926
diff changeset
   576
               pool_map nice_problem_line lines #>> pair heading) problem
39452
70a57e40f795 factored out TSTP/SPASS/Vampire proof parsing;
blanchet
parents: 39384
diff changeset
   577
fun nice_atp_problem readable_names problem =
38017
3ad3e3ca2451 move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents: 38014
diff changeset
   578
  nice_problem problem (empty_name_pool readable_names)
37509
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
   579
f39464d971c4 factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff changeset
   580
end;