| author | blanchet |
| Tue, 24 May 2011 18:04:23 +0200 | |
| changeset 42974 | 347d5197896e |
| parent 42968 | 74415622d293 |
| child 42994 | fe291ab75eb5 |
| permissions | -rw-r--r-- |
| 38047 | 1 |
(* Title: HOL/Tools/ATP/atp_problem.ML |
| 38027 | 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 | 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 |
| 37992 | 10 |
datatype 'a fo_term = ATerm of 'a * 'a fo_term list |
11 |
datatype quantifier = AForall | AExists |
|
12 |
datatype connective = ANot | AAnd | AOr | AImplies | AIf | AIff | ANotIff |
|
|
42531
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
13 |
datatype ('a, 'b, 'c) formula =
|
|
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
14 |
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
|
15 |
AConn of connective * ('a, 'b, 'c) formula list |
|
|
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
16 |
AAtom of 'c |
|
37994
b04307085a09
make TPTP generator accept full first-order formulas
blanchet
parents:
37993
diff
changeset
|
17 |
|
| 42963 | 18 |
datatype 'a ho_type = AType of 'a | AFun of 'a ho_type * 'a ho_type |
19 |
||
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
20 |
datatype format = CNF_UEQ | FOF | TFF | THF |
|
42525
7a506b0b644f
distinguish FOF and TFF (typed first-order) in ATP abstract syntax tree
blanchet
parents:
42449
diff
changeset
|
21 |
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
|
22 |
datatype 'a problem_line = |
| 42963 | 23 |
Decl of string * 'a * 'a ho_type | |
24 |
Formula of string * formula_kind * ('a, 'a ho_type, 'a fo_term) formula
|
|
|
42529
747736d8b47e
added "useful_info" argument to ATP formulas -- this will probably be useful later to specify intro, simp, elim to SPASS
blanchet
parents:
42528
diff
changeset
|
25 |
* string fo_term option * string fo_term option |
|
38017
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
26 |
type 'a problem = (string * 'a problem_line list) list |
| 37992 | 27 |
|
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
28 |
val tptp_cnf : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
29 |
val tptp_fof : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
30 |
val tptp_tff : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
31 |
val tptp_thf : string |
| 42752 | 32 |
val tptp_special_prefix : string |
| 42967 | 33 |
val tptp_has_type : string |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
34 |
val tptp_type_of_types : string |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
35 |
val tptp_bool_type : string |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
36 |
val tptp_individual_type : string |
| 42963 | 37 |
val tptp_fun_type : string |
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
38 |
val tptp_prod_type : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
39 |
val tptp_forall : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
40 |
val tptp_exists : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
41 |
val tptp_not : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
42 |
val tptp_and : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
43 |
val tptp_or : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
44 |
val tptp_implies : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
45 |
val tptp_if : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
46 |
val tptp_iff : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
47 |
val tptp_not_iff : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
48 |
val tptp_app : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
49 |
val tptp_not_infix : string |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
50 |
val tptp_equal : string |
|
42966
4e2d6c1e5392
more work on parsing LEO-II proofs without lambdas
blanchet
parents:
42963
diff
changeset
|
51 |
val tptp_false : string |
|
4e2d6c1e5392
more work on parsing LEO-II proofs without lambdas
blanchet
parents:
42963
diff
changeset
|
52 |
val tptp_true : string |
| 42939 | 53 |
val is_atp_variable : string -> bool |
| 42942 | 54 |
val mk_anot : ('a, 'b, 'c) formula -> ('a, 'b, 'c) formula
|
55 |
val mk_aconn : |
|
56 |
connective -> ('a, 'b, 'c) formula -> ('a, 'b, 'c) formula
|
|
57 |
-> ('a, 'b, 'c) formula
|
|
|
42944
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
58 |
val formula_map : ('c -> 'd) -> ('a, 'b, 'c) formula -> ('a, 'b, 'd) formula
|
|
38019
e207a64e1e0b
complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents:
38018
diff
changeset
|
59 |
val timestamp : unit -> string |
|
42567
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
60 |
val hashw : word * word -> word |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
61 |
val hashw_string : string * word -> word |
|
42709
e7af132d48fe
allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet
parents:
42659
diff
changeset
|
62 |
val tptp_strings_for_atp_problem : format -> string problem -> string list |
| 42939 | 63 |
val filter_cnf_ueq_problem : |
64 |
(string * string) problem -> (string * string) problem |
|
| 39452 | 65 |
val nice_atp_problem : |
|
38017
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
66 |
bool -> ('a * (string * string) problem_line list) list
|
|
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
67 |
-> ('a * string problem_line list) list
|
|
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
68 |
* (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
|
69 |
end; |
|
f39464d971c4
factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff
changeset
|
70 |
|
|
38019
e207a64e1e0b
complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents:
38018
diff
changeset
|
71 |
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
|
72 |
struct |
|
f39464d971c4
factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff
changeset
|
73 |
|
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
74 |
(** ATP problem **) |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
75 |
|
|
37961
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
76 |
datatype 'a fo_term = ATerm of 'a * 'a fo_term list |
|
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
77 |
datatype quantifier = AForall | AExists |
| 37992 | 78 |
datatype connective = ANot | AAnd | AOr | AImplies | AIf | AIff | ANotIff |
|
42531
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
79 |
datatype ('a, 'b, 'c) formula =
|
|
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
80 |
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
|
81 |
AConn of connective * ('a, 'b, 'c) formula list |
|
|
a462dbaa584f
added more rudimentary type support to Sledgehammer's ATP encoding
blanchet
parents:
42530
diff
changeset
|
82 |
AAtom of 'c |
|
37961
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
83 |
|
| 42963 | 84 |
datatype 'a ho_type = AType of 'a | AFun of 'a ho_type * 'a ho_type |
85 |
||
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
86 |
datatype format = CNF_UEQ | FOF | TFF | THF |
|
42525
7a506b0b644f
distinguish FOF and TFF (typed first-order) in ATP abstract syntax tree
blanchet
parents:
42449
diff
changeset
|
87 |
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
|
88 |
datatype 'a problem_line = |
| 42963 | 89 |
Decl of string * 'a * 'a ho_type | |
90 |
Formula of string * formula_kind * ('a, 'a ho_type, 'a fo_term) formula
|
|
|
42529
747736d8b47e
added "useful_info" argument to ATP formulas -- this will probably be useful later to specify intro, simp, elim to SPASS
blanchet
parents:
42528
diff
changeset
|
91 |
* string fo_term option * string fo_term option |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
92 |
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
|
93 |
|
| 42722 | 94 |
(* official TPTP syntax *) |
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
95 |
val tptp_cnf = "cnf" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
96 |
val tptp_fof = "fof" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
97 |
val tptp_tff = "tff" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
98 |
val tptp_thf = "thf" |
| 42752 | 99 |
val tptp_special_prefix = "$" |
| 42967 | 100 |
val tptp_has_type = ":" |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
101 |
val tptp_type_of_types = "$tType" |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
102 |
val tptp_bool_type = "$o" |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
103 |
val tptp_individual_type = "$i" |
| 42963 | 104 |
val tptp_fun_type = ">" |
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
105 |
val tptp_prod_type = "*" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
106 |
val tptp_forall = "!" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
107 |
val tptp_exists = "?" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
108 |
val tptp_not = "~" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
109 |
val tptp_and = "&" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
110 |
val tptp_or = "|" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
111 |
val tptp_implies = "=>" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
112 |
val tptp_if = "<=" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
113 |
val tptp_iff = "<=>" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
114 |
val tptp_not_iff = "<~>" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
115 |
val tptp_app = "@" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
116 |
val tptp_not_infix = "!" |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
117 |
val tptp_equal = "=" |
|
42966
4e2d6c1e5392
more work on parsing LEO-II proofs without lambdas
blanchet
parents:
42963
diff
changeset
|
118 |
val tptp_false = "$false" |
|
4e2d6c1e5392
more work on parsing LEO-II proofs without lambdas
blanchet
parents:
42963
diff
changeset
|
119 |
val tptp_true = "$true" |
| 42722 | 120 |
|
| 42939 | 121 |
fun is_atp_variable s = Char.isUpper (String.sub (s, 0)) |
122 |
||
| 42942 | 123 |
fun mk_anot (AConn (ANot, [phi])) = phi |
124 |
| mk_anot phi = AConn (ANot, [phi]) |
|
125 |
fun mk_aconn c phi1 phi2 = AConn (c, [phi1, phi2]) |
|
126 |
||
|
42944
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
127 |
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
|
128 |
| 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
|
129 |
| 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
|
130 |
|
|
38019
e207a64e1e0b
complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents:
38018
diff
changeset
|
131 |
val timestamp = Date.fmt "%Y-%m-%d %H:%M:%S" o Date.fromTimeLocal o Time.now |
|
e207a64e1e0b
complete renaming of "Sledgehammer_TPTP_Format" to "ATP_Problem"
blanchet
parents:
38018
diff
changeset
|
132 |
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
133 |
(* This hash function is recommended in "Compilers: Principles, Techniques, and |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
134 |
Tools" by Aho, Sethi, and Ullman. The "hashpjw" function, which they |
|
42567
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
135 |
particularly recommend, triggers a bug in versions of Poly/ML up to 4.2.0. *) |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
136 |
fun hashw (u, w) = Word.+ (u, Word.* (0w65599, w)) |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
137 |
fun hashw_char (c, w) = hashw (Word.fromInt (Char.ord c), w) |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
138 |
fun hashw_string (s : string, w) = CharVector.foldl hashw_char w s |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
139 |
|
|
38631
979a0b37f981
prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents:
38613
diff
changeset
|
140 |
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
|
141 |
| 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
|
142 |
| string_for_kind Lemma = "lemma" |
|
38631
979a0b37f981
prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents:
38613
diff
changeset
|
143 |
| string_for_kind Hypothesis = "hypothesis" |
|
979a0b37f981
prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents:
38613
diff
changeset
|
144 |
| string_for_kind Conjecture = "conjecture" |
|
979a0b37f981
prefer TPTP "conjecture" tag to "hypothesis" on ATPs where this is possible;
blanchet
parents:
38613
diff
changeset
|
145 |
|
| 42963 | 146 |
fun strip_tff_type (AFun (AType s, ty)) = strip_tff_type ty |>> cons s |
147 |
| strip_tff_type (AFun (AFun _, _)) = |
|
148 |
raise Fail "unexpected higher-order type in first-order format" |
|
149 |
| strip_tff_type (AType s) = ([], s) |
|
150 |
||
151 |
fun string_for_type THF ty = |
|
152 |
let |
|
153 |
fun aux _ (AType s) = s |
|
154 |
| aux rhs (AFun (ty1, ty2)) = |
|
155 |
aux false ty1 ^ " " ^ tptp_fun_type ^ " " ^ aux true ty2 |
|
156 |
|> not rhs ? enclose "(" ")"
|
|
157 |
in aux true ty end |
|
158 |
| string_for_type TFF ty = |
|
159 |
(case strip_tff_type ty of |
|
160 |
([], s) => s |
|
161 |
| ([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
|
162 |
| (ss, s) => |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
163 |
"(" ^ space_implode tptp_prod_type ss ^ ") " ^ tptp_fun_type ^ " " ^ s)
|
| 42963 | 164 |
| string_for_type _ _ = raise Fail "unexpected type in untyped format" |
165 |
||
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
166 |
fun string_for_term _ (ATerm (s, [])) = s |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
167 |
| string_for_term format (ATerm ("equal", ts)) =
|
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
168 |
space_implode (" " ^ tptp_equal ^ " ") (map (string_for_term format) ts)
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
169 |
|> format = THF ? enclose "(" ")"
|
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
170 |
| string_for_term format (ATerm ("[]", ts)) =
|
|
41769
eb2e39555f98
extended ATP problem syntax to support other applications than Sledgehammer, e.g. experiments with ATPs
blanchet
parents:
41491
diff
changeset
|
171 |
(* used for lists in the optional "source" field of a derivation *) |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
172 |
"[" ^ commas (map (string_for_term format) ts) ^ "]" |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
173 |
| string_for_term format (ATerm (s, ts)) = |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
174 |
let val ss = map (string_for_term format) ts in |
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
175 |
if format = THF then |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
176 |
"(" ^ space_implode (" " ^ tptp_app ^ " ") (s :: ss) ^ ")"
|
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
177 |
else |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
178 |
s ^ "(" ^ commas ss ^ ")"
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
179 |
end |
| 42963 | 180 |
|
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
181 |
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
|
182 |
| string_for_quantifier AExists = tptp_exists |
| 42963 | 183 |
|
| 42967 | 184 |
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
|
185 |
| string_for_connective AAnd = tptp_and |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
186 |
| string_for_connective AOr = tptp_or |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
187 |
| string_for_connective AImplies = tptp_implies |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
188 |
| string_for_connective AIf = tptp_if |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
189 |
| string_for_connective AIff = tptp_iff |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
190 |
| string_for_connective ANotIff = tptp_not_iff |
| 42963 | 191 |
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
192 |
fun string_for_bound_var format (s, ty) = |
| 42963 | 193 |
s ^ (if format = TFF orelse format = THF then |
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
194 |
" " ^ tptp_has_type ^ " " ^ |
| 42963 | 195 |
string_for_type format (ty |> the_default (AType tptp_individual_type)) |
196 |
else |
|
197 |
"") |
|
198 |
||
| 42722 | 199 |
fun 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
|
200 |
string_for_quantifier q ^ |
| 42722 | 201 |
"[" ^ 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
|
202 |
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
|
203 |
|> enclose "(" ")"
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
204 |
| string_for_formula format (AConn (ANot, [AAtom (ATerm ("equal", ts))])) =
|
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
205 |
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
|
206 |
(map (string_for_term format) ts) |
| 42963 | 207 |
|> format = THF ? enclose "(" ")"
|
| 42722 | 208 |
| 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
|
209 |
string_for_connective c ^ " " ^ |
|
347d5197896e
ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents:
42968
diff
changeset
|
210 |
(string_for_formula format phi |> format = THF ? enclose "(" ")")
|
|
347d5197896e
ensure that the argument of logical negation is enclosed in parentheses in THF mode
blanchet
parents:
42968
diff
changeset
|
211 |
|> enclose "(" ")"
|
| 42722 | 212 |
| 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
|
213 |
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
|
214 |
(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
|
215 |
|> enclose "(" ")"
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
216 |
| 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
|
217 |
|
| 42639 | 218 |
val default_source = |
219 |
ATerm ("inference", ATerm ("isabelle", []) :: replicate 2 (ATerm ("[]", [])))
|
|
220 |
||
|
42968
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
221 |
fun string_for_format CNF_UEQ = tptp_cnf |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
222 |
| string_for_format FOF = tptp_fof |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
223 |
| string_for_format TFF = tptp_tff |
|
74415622d293
more work on parsing LEO-II proofs and extracting uses of extensionality
blanchet
parents:
42967
diff
changeset
|
224 |
| string_for_format THF = tptp_thf |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
225 |
|
| 42963 | 226 |
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
|
227 |
string_for_format format ^ "(" ^ ident ^ ", type,\n " ^ sym ^ " : " ^
|
| 42963 | 228 |
string_for_type format ty ^ ").\n" |
| 42939 | 229 |
| 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
|
230 |
string_for_format format ^ "(" ^ ident ^ ", " ^ string_for_kind kind ^
|
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
231 |
",\n (" ^ string_for_formula format phi ^ ")" ^
|
| 42939 | 232 |
(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
|
233 |
(NONE, NONE) => "" |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
234 |
| (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
|
235 |
| (_, SOME tm) => |
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
236 |
", " ^ string_for_term format (source |> the_default default_source) ^ |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
237 |
", " ^ string_for_term format tm) ^ ").\n" |
|
42709
e7af132d48fe
allow each prover to specify its own formula kind for symbols occurring in the conjecture
blanchet
parents:
42659
diff
changeset
|
238 |
fun tptp_strings_for_atp_problem format problem = |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
239 |
"% 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
|
240 |
\% " ^ timestamp () ^ "\n" :: |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
241 |
maps (fn (_, []) => [] |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
242 |
| (heading, lines) => |
| 41491 | 243 |
"\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
|
244 |
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
|
245 |
problem |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
246 |
|
| 42939 | 247 |
|
248 |
(** CNF UEQ (Waldmeister) **) |
|
249 |
||
250 |
fun is_problem_line_negated (Formula (_, _, AConn (ANot, _), _, _)) = true |
|
251 |
| is_problem_line_negated _ = false |
|
252 |
||
253 |
fun is_problem_line_cnf_ueq |
|
254 |
(Formula (_, _, AAtom (ATerm (("equal", _), _)), _, _)) = true
|
|
255 |
| is_problem_line_cnf_ueq _ = false |
|
256 |
||
|
42944
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
257 |
fun open_conjecture_term (ATerm ((s, s'), tms)) = |
| 42961 | 258 |
ATerm (if is_atp_variable s then (s |> Name.desymbolize false, s') |
259 |
else (s, s'), tms |> map open_conjecture_term) |
|
|
42944
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
260 |
fun open_formula conj (AQuant (AForall, _, phi)) = open_formula conj phi |
|
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
261 |
| open_formula true (AAtom t) = AAtom (open_conjecture_term t) |
|
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
262 |
| open_formula _ phi = phi |
|
9e620869a576
improved Waldmeister support -- even run it by default on unit equational goals
blanchet
parents:
42942
diff
changeset
|
263 |
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
|
264 |
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
|
265 |
| open_formula_line line = line |
| 42939 | 266 |
|
267 |
fun negate_conjecture_line (Formula (ident, Conjecture, phi, source, info)) = |
|
| 42942 | 268 |
Formula (ident, Hypothesis, mk_anot phi, source, info) |
| 42939 | 269 |
| negate_conjecture_line line = line |
270 |
||
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
271 |
fun filter_cnf_ueq_problem problem = |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
272 |
problem |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
273 |
|> map (apsnd (map open_formula_line |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
274 |
#> filter is_problem_line_cnf_ueq |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
275 |
#> map negate_conjecture_line)) |
|
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
276 |
|> (fn problem => |
| 42939 | 277 |
let |
278 |
val conjs = problem |> maps snd |> filter is_problem_line_negated |
|
279 |
in if length conjs = 1 then problem else [] end) |
|
|
38017
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
280 |
|
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
281 |
|
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
282 |
(** Nice names **) |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
283 |
|
| 37624 | 284 |
fun empty_name_pool readable_names = |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
285 |
if readable_names then SOME (Symtab.empty, Symtab.empty) else NONE |
| 37624 | 286 |
|
287 |
fun pool_fold f xs z = pair z #> fold_rev (fn x => uncurry (f x)) xs |
|
288 |
fun pool_map f xs = |
|
289 |
pool_fold (fn x => fn ys => fn pool => f x pool |>> (fn y => y :: ys)) xs [] |
|
290 |
||
|
42227
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
291 |
val no_qualifiers = |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
292 |
let |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
293 |
fun skip [] = [] |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
294 |
| skip (#"." :: cs) = skip cs |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
295 |
| 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
|
296 |
and keep [] = [] |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
297 |
| keep (#"." :: cs) = skip cs |
|
662b50b7126f
if "monomorphize" is enabled, mangle the type information in the names by default
blanchet
parents:
41769
diff
changeset
|
298 |
| 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
|
299 |
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
|
300 |
|
|
42761
8ea9c6fa8b53
fixed several bugs in Isar proof reconstruction, in particular w.r.t. mangled types and hAPP
blanchet
parents:
42752
diff
changeset
|
301 |
(* 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
|
302 |
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
|
303 |
|
| 39109 | 304 |
(* "op" is also reserved, to avoid the unreadable "op_1", "op_2", etc., in the |
305 |
problem files. "equal" is reserved by some ATPs. "eq" is reserved to ensure |
|
306 |
that "HOL.eq" is correctly mapped to equality. *) |
|
307 |
val reserved_nice_names = ["op", "equal", "eq"] |
|
| 42939 | 308 |
|
| 37624 | 309 |
fun readable_name full_name s = |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
310 |
if s = full_name then |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
311 |
s |
|
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
312 |
else |
|
42567
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
313 |
s |> no_qualifiers |
|
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
314 |
|> Name.desymbolize (Char.isUpper (String.sub (full_name, 0))) |
|
42583
84b134118616
avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents:
42577
diff
changeset
|
315 |
|> (fn s => |
| 42659 | 316 |
if size s > max_readable_name_size then |
317 |
String.substring (s, 0, max_readable_name_size div 2 - 4) ^ |
|
|
42583
84b134118616
avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents:
42577
diff
changeset
|
318 |
Word.toString (hashw_string (full_name, 0w0)) ^ |
| 42659 | 319 |
String.extract (s, size s - max_readable_name_size div 2 + 4, |
320 |
NONE) |
|
|
42583
84b134118616
avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents:
42577
diff
changeset
|
321 |
else |
|
84b134118616
avoid trailing digits for SNARK (type) names -- grr...
blanchet
parents:
42577
diff
changeset
|
322 |
s) |
|
42567
d012947edd36
shorten readable names -- they can get really long with monomorphization, which actually slows down the ATPs
blanchet
parents:
42543
diff
changeset
|
323 |
|> (fn s => if member (op =) reserved_nice_names s then full_name else s) |
| 37624 | 324 |
|
325 |
fun nice_name (full_name, _) NONE = (full_name, NONE) |
|
326 |
| nice_name (full_name, desired_name) (SOME the_pool) = |
|
|
42962
3b50fdeb6cfc
started adding support for THF output (but no lambdas)
blanchet
parents:
42961
diff
changeset
|
327 |
if String.isPrefix tptp_special_prefix full_name then |
| 39384 | 328 |
(full_name, SOME the_pool) |
329 |
else case Symtab.lookup (fst the_pool) full_name of |
|
| 37624 | 330 |
SOME nice_name => (nice_name, SOME the_pool) |
331 |
| NONE => |
|
332 |
let |
|
333 |
val nice_prefix = readable_name full_name desired_name |
|
334 |
fun add j = |
|
335 |
let |
|
| 42644 | 336 |
val nice_name = |
| 42942 | 337 |
nice_prefix ^ (if j = 0 then "" else "_" ^ string_of_int j) |
| 37624 | 338 |
in |
339 |
case Symtab.lookup (snd the_pool) nice_name of |
|
340 |
SOME full_name' => |
|
341 |
if full_name = full_name' then (nice_name, the_pool) |
|
342 |
else add (j + 1) |
|
343 |
| NONE => |
|
344 |
(nice_name, |
|
345 |
(Symtab.update_new (full_name, nice_name) (fst the_pool), |
|
346 |
Symtab.update_new (nice_name, full_name) (snd the_pool))) |
|
347 |
end |
|
348 |
in add 0 |> apsnd SOME end |
|
349 |
||
|
37961
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
350 |
fun nice_term (ATerm (name, ts)) = |
|
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
351 |
nice_name name ##>> pool_map nice_term ts #>> ATerm |
| 42963 | 352 |
fun nice_type (AType name) = nice_name name #>> AType |
353 |
| nice_type (AFun (ty1, ty2)) = nice_type ty1 ##>> nice_type ty2 #>> AFun |
|
|
37961
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
354 |
fun nice_formula (AQuant (q, xs, phi)) = |
| 42526 | 355 |
pool_map nice_name (map fst xs) |
356 |
##>> pool_map (fn NONE => pair NONE |
|
| 42963 | 357 |
| SOME ty => nice_type ty #>> SOME) (map snd xs) |
| 42526 | 358 |
##>> nice_formula phi |
359 |
#>> (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
|
360 |
| nice_formula (AConn (c, phis)) = |
|
6a48c85a211a
first step in using "fof" rather than "cnf" in TPTP problems
blanchet
parents:
37931
diff
changeset
|
361 |
pool_map nice_formula phis #>> curry AConn c |
| 38034 | 362 |
| nice_formula (AAtom tm) = nice_term tm #>> AAtom |
| 42963 | 363 |
fun nice_problem_line (Decl (ident, sym, ty)) = |
364 |
nice_name sym ##>> nice_type ty |
|
365 |
#>> (fn (sym, ty) => Decl (ident, sym, ty)) |
|
| 42939 | 366 |
| nice_problem_line (Formula (ident, kind, phi, source, info)) = |
367 |
nice_formula phi #>> (fn phi => Formula (ident, kind, phi, source, info)) |
|
| 37931 | 368 |
fun nice_problem problem = |
|
37643
f576af716aa6
rewrote the TPTP problem generation code more or less from scratch;
blanchet
parents:
37642
diff
changeset
|
369 |
pool_map (fn (heading, lines) => |
| 37931 | 370 |
pool_map nice_problem_line lines #>> pair heading) problem |
| 39452 | 371 |
fun nice_atp_problem readable_names problem = |
|
38017
3ad3e3ca2451
move Sledgehammer-specific code out of "Sledgehammer_TPTP_Format"
blanchet
parents:
38014
diff
changeset
|
372 |
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
|
373 |
|
|
f39464d971c4
factor out TPTP format output into file of its own, to facilitate further changes
blanchet
parents:
diff
changeset
|
374 |
end; |