author | nipkow |
Tue, 17 Jun 2025 14:11:40 +0200 | |
changeset 82733 | 8b537e1af2ec |
parent 80910 | 406a85a25189 |
permissions | -rw-r--r-- |
46844 | 1 |
(* Title: HOL/TPTP/TPTP_Parser/tptp_syntax.ML |
2 |
Author: Nik Sultana, Cambridge University Computer Laboratory |
|
3 |
||
4 |
TPTP abstract syntax and parser-related definitions. |
|
5 |
*) |
|
6 |
||
7 |
signature TPTP_SYNTAX = |
|
8 |
sig |
|
9 |
exception TPTP_SYNTAX of string |
|
10 |
val debug: ('a -> unit) -> 'a -> unit |
|
11 |
||
12 |
(*Note that in THF "^ [X] : ^ [Y] : f @ g" should parse |
|
13 |
as "(^ [X] : (^ [Y] : f)) @ g" |
|
14 |
*) |
|
15 |
||
16 |
datatype number_kind = Int_num | Real_num | Rat_num |
|
17 |
||
18 |
datatype status_value = |
|
19 |
Suc | Unp | Sap | Esa | Sat | Fsa |
|
20 |
| Thm | Eqv | Tac | Wec | Eth | Tau |
|
21 |
| Wtc | Wth | Cax | Sca | Tca | Wca |
|
22 |
| Cup | Csp | Ecs | Csa | Cth | Ceq |
|
23 |
| Unc | Wcc | Ect | Fun | Uns | Wuc |
|
24 |
| Wct | Scc | Uca | Noc |
|
25 |
||
26 |
type name = string |
|
27 |
type atomic_word = string |
|
28 |
type inference_rule = atomic_word |
|
29 |
type file_info = name option |
|
30 |
type single_quoted = string |
|
31 |
type file_name = single_quoted |
|
32 |
type creator_name = atomic_word |
|
33 |
type variable = string |
|
34 |
type upper_word = string |
|
35 |
||
36 |
datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic |
|
37 |
and role = |
|
38 |
Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption | |
|
39 |
Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture | |
|
40 |
Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates | |
|
41 |
Role_Type | Role_Unknown |
|
42 |
||
43 |
and general_data = (*Bind of variable * formula_data*) |
|
44 |
Atomic_Word of string |
|
45 |
| Application of string * general_term list (*general_function*) |
|
46 |
| V of upper_word (*variable*) |
|
47 |
| Number of number_kind * string |
|
48 |
| Distinct_Object of string |
|
49 |
| (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *) |
|
50 |
| (*formula_data*) Term_Data of tptp_term |
|
51 |
||
52 |
and interpreted_symbol = |
|
53 |
UMinus | Sum | Difference | Product | Quotient | Quotient_E | |
|
54 |
Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F | |
|
55 |
Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real | |
|
47360 | 56 |
(*FIXME these should be in defined_pred, but that's not being used in TPTP*) |
46844 | 57 |
Less | LessEq | Greater | GreaterEq | EvalEq | Is_Int | Is_Rat | |
47360 | 58 |
Distinct | Apply |
46844 | 59 |
|
60 |
and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor | |
|
61 |
Nor | Nand | Not | Op_Forall | Op_Exists | |
|
47360 | 62 |
(*FIXME these should be in defined_pred, but that's not being used in TPTP*) |
46844 | 63 |
True | False |
64 |
||
65 |
and quantifier = (*interpreted binders*) |
|
66 |
Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum |
|
67 |
||
68 |
and tptp_base_type = |
|
57808 | 69 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real | Type_Dummy |
46844 | 70 |
|
71 |
and symbol = |
|
72 |
Uninterpreted of string |
|
73 |
| Interpreted_ExtraLogic of interpreted_symbol |
|
74 |
| Interpreted_Logic of logic_symbol |
|
75 |
| TypeSymbol of tptp_base_type |
|
76 |
| System of string |
|
77 |
||
78 |
and general_term = |
|
79 |
General_Data of general_data (*general_data*) |
|
80 |
| General_Term of general_data * general_term (*general_data : general_term*) |
|
81 |
| General_List of general_term list |
|
82 |
||
83 |
and tptp_term = |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
84 |
Term_FuncG of symbol * tptp_type list (*special hack for TPTP_Interpret*) * tptp_term list |
46844 | 85 |
| Term_Var of string |
86 |
| Term_Conditional of tptp_formula * tptp_term * tptp_term |
|
87 |
| Term_Num of number_kind * string |
|
88 |
| Term_Distinct_Object of string |
|
53394 | 89 |
| Term_Let of tptp_let * tptp_term |
46844 | 90 |
|
91 |
and tptp_atom = |
|
92 |
TFF_Typed_Atom of symbol * tptp_type option (*only TFF*) |
|
93 |
| THF_Atom_term of tptp_term (*from here on, only THF*) |
|
94 |
| THF_Atom_conn_term of symbol |
|
95 |
||
96 |
and tptp_formula = |
|
97 |
Pred of symbol * tptp_term list |
|
98 |
| Fmla of symbol * tptp_formula list |
|
99 |
| Sequent of tptp_formula list * tptp_formula list |
|
100 |
| Quant of quantifier * (string * tptp_type option) list * tptp_formula |
|
101 |
| Conditional of tptp_formula * tptp_formula * tptp_formula |
|
53394 | 102 |
| Let of tptp_let * tptp_formula |
46844 | 103 |
| Atom of tptp_atom |
47360 | 104 |
| Type_fmla of tptp_type |
46844 | 105 |
| THF_typing of tptp_formula * tptp_type (*only THF*) |
106 |
||
107 |
and tptp_let = |
|
53394 | 108 |
Let_fmla of (string * tptp_type option) list * tptp_formula |
109 |
| Let_term of (string * tptp_type option) list * tptp_term |
|
46844 | 110 |
|
111 |
and tptp_type = |
|
112 |
Prod_type of tptp_type * tptp_type |
|
113 |
| Fn_type of tptp_type * tptp_type |
|
57808 | 114 |
| Atom_type of string * tptp_type list |
115 |
| Var_type of string |
|
46844 | 116 |
| Defined_type of tptp_base_type |
117 |
| Sum_type of tptp_type * tptp_type (*only THF*) |
|
47357
15e579392a68
refactored tptp yacc to bring close to official spec;
sultana
parents:
46844
diff
changeset
|
118 |
| Fmla_type of tptp_formula |
46844 | 119 |
| Subtype of symbol * symbol (*only THF*) |
120 |
||
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
121 |
val Term_Func: symbol * tptp_term list -> tptp_term (*for Yacc parser*) |
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
122 |
|
46844 | 123 |
type general_list = general_term list |
124 |
type parent_details = general_list |
|
125 |
type useful_info = general_term list |
|
126 |
type info = useful_info |
|
127 |
||
128 |
type annotation = general_term * general_term list |
|
129 |
||
130 |
exception DEQUOTE of string |
|
131 |
||
132 |
type position = string * int * int |
|
133 |
||
134 |
datatype tptp_line = |
|
47360 | 135 |
Annotated_Formula of position * language * string * role * |
136 |
tptp_formula * annotation option |
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
137 |
| Include of position * string * string list |
46844 | 138 |
|
139 |
type tptp_problem = tptp_line list |
|
140 |
||
141 |
val dequote : single_quoted -> single_quoted |
|
142 |
||
143 |
val role_to_string : role -> string |
|
144 |
||
145 |
val status_to_string : status_value -> string |
|
146 |
||
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
147 |
val pos_of_line : tptp_line -> position |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
148 |
|
46844 | 149 |
(*Returns the list of all files included in a directory and its |
150 |
subdirectories. This is only used for testing the parser/interpreter against |
|
151 |
all THF problems.*) |
|
152 |
val get_file_list : Path.T -> Path.T list |
|
153 |
||
53385 | 154 |
val read_status : string -> status_value |
46844 | 155 |
val string_of_tptp_term : tptp_term -> string |
47692
3d76c81b5ed2
improved non-interpretation of constants and numbers;
sultana
parents:
47569
diff
changeset
|
156 |
val string_of_interpreted_symbol : interpreted_symbol -> string |
46844 | 157 |
val string_of_tptp_formula : tptp_formula -> string |
158 |
||
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
159 |
val latex_of_tptp_formula : tptp_formula -> string |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
160 |
|
46844 | 161 |
end |
162 |
||
163 |
||
164 |
structure TPTP_Syntax : TPTP_SYNTAX = |
|
165 |
struct |
|
166 |
||
167 |
exception TPTP_SYNTAX of string |
|
168 |
||
169 |
datatype number_kind = Int_num | Real_num | Rat_num |
|
170 |
||
171 |
datatype status_value = |
|
172 |
Suc | Unp | Sap | Esa | Sat | Fsa |
|
173 |
| Thm | Eqv | Tac | Wec | Eth | Tau |
|
174 |
| Wtc | Wth | Cax | Sca | Tca | Wca |
|
175 |
| Cup | Csp | Ecs | Csa | Cth | Ceq |
|
176 |
| Unc | Wcc | Ect | Fun | Uns | Wuc |
|
177 |
| Wct | Scc | Uca | Noc |
|
178 |
||
179 |
type name = string |
|
180 |
type atomic_word = string |
|
181 |
type inference_rule = atomic_word |
|
182 |
type file_info = name option |
|
183 |
type single_quoted = string |
|
184 |
type file_name = single_quoted |
|
185 |
type creator_name = atomic_word |
|
186 |
type variable = string |
|
187 |
type upper_word = string |
|
188 |
||
189 |
datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic |
|
190 |
and role = |
|
191 |
Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption | |
|
192 |
Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture | |
|
193 |
Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates | |
|
194 |
Role_Type | Role_Unknown |
|
195 |
and general_data = (*Bind of variable * formula_data*) |
|
196 |
Atomic_Word of string |
|
197 |
| Application of string * (general_term list) |
|
198 |
| V of upper_word (*variable*) |
|
199 |
| Number of number_kind * string |
|
200 |
| Distinct_Object of string |
|
201 |
| (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *) |
|
202 |
| (*formula_data*) Term_Data of tptp_term |
|
203 |
||
204 |
and interpreted_symbol = |
|
205 |
UMinus | Sum | Difference | Product | Quotient | Quotient_E | |
|
206 |
Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F | |
|
207 |
Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real | |
|
208 |
Less | LessEq | Greater | GreaterEq | EvalEq | Is_Int | Is_Rat | |
|
47357
15e579392a68
refactored tptp yacc to bring close to official spec;
sultana
parents:
46844
diff
changeset
|
209 |
Distinct | |
47360 | 210 |
Apply |
46844 | 211 |
|
212 |
and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor | |
|
213 |
Nor | Nand | Not | Op_Forall | Op_Exists | |
|
214 |
True | False |
|
215 |
||
216 |
and quantifier = (*interpreted binders*) |
|
217 |
Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum |
|
218 |
||
219 |
and tptp_base_type = |
|
57808 | 220 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real | Type_Dummy |
46844 | 221 |
|
222 |
and symbol = |
|
223 |
Uninterpreted of string |
|
224 |
| Interpreted_ExtraLogic of interpreted_symbol |
|
225 |
| Interpreted_Logic of logic_symbol |
|
226 |
| TypeSymbol of tptp_base_type |
|
227 |
| System of string |
|
228 |
||
229 |
and general_term = |
|
230 |
General_Data of general_data (*general_data*) |
|
231 |
| General_Term of general_data * general_term (*general_data : general_term*) |
|
232 |
| General_List of general_term list |
|
233 |
||
234 |
and tptp_term = |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
235 |
Term_FuncG of symbol * tptp_type list (*special hack for TPTP_Interpret*) * tptp_term list |
46844 | 236 |
| Term_Var of string |
237 |
| Term_Conditional of tptp_formula * tptp_term * tptp_term |
|
238 |
| Term_Num of number_kind * string |
|
239 |
| Term_Distinct_Object of string |
|
53394 | 240 |
| Term_Let of tptp_let * tptp_term |
46844 | 241 |
|
242 |
and tptp_atom = |
|
243 |
TFF_Typed_Atom of symbol * tptp_type option (*only TFF*) |
|
244 |
| THF_Atom_term of tptp_term (*from here on, only THF*) |
|
245 |
| THF_Atom_conn_term of symbol |
|
246 |
||
247 |
and tptp_formula = |
|
248 |
Pred of symbol * tptp_term list |
|
249 |
| Fmla of symbol * tptp_formula list |
|
250 |
| Sequent of tptp_formula list * tptp_formula list |
|
251 |
| Quant of quantifier * (string * tptp_type option) list * tptp_formula |
|
252 |
| Conditional of tptp_formula * tptp_formula * tptp_formula |
|
53394 | 253 |
| Let of tptp_let * tptp_formula |
46844 | 254 |
| Atom of tptp_atom |
47360 | 255 |
| Type_fmla of tptp_type |
46844 | 256 |
| THF_typing of tptp_formula * tptp_type |
257 |
||
258 |
and tptp_let = |
|
53394 | 259 |
Let_fmla of (string * tptp_type option) list * tptp_formula |
260 |
| Let_term of (string * tptp_type option) list * tptp_term |
|
46844 | 261 |
|
262 |
and tptp_type = |
|
263 |
Prod_type of tptp_type * tptp_type |
|
264 |
| Fn_type of tptp_type * tptp_type |
|
57808 | 265 |
| Atom_type of string * tptp_type list |
266 |
| Var_type of string |
|
46844 | 267 |
| Defined_type of tptp_base_type |
47360 | 268 |
| Sum_type of tptp_type * tptp_type |
269 |
| Fmla_type of tptp_formula |
|
270 |
| Subtype of symbol * symbol |
|
46844 | 271 |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
272 |
fun Term_Func (symb, ts) = Term_FuncG (symb, [], ts) |
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
273 |
|
46844 | 274 |
type general_list = general_term list |
275 |
type parent_details = general_list |
|
276 |
type useful_info = general_term list |
|
277 |
type info = useful_info |
|
278 |
||
279 |
(*type annotation = (source * info option)*) |
|
280 |
type annotation = general_term * general_term list |
|
281 |
||
282 |
exception DEQUOTE of string |
|
283 |
||
284 |
type position = string * int * int |
|
285 |
||
286 |
datatype tptp_line = |
|
287 |
Annotated_Formula of position * language * string * role * tptp_formula * annotation option |
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
288 |
| Include of position * string * string list |
46844 | 289 |
|
290 |
type tptp_problem = tptp_line list |
|
291 |
||
69593 | 292 |
fun debug f x = if Options.default_bool \<^system_option>\<open>ML_exception_trace\<close> then (f x; ()) else () |
46844 | 293 |
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
294 |
fun pos_of_line tptp_line = |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
295 |
case tptp_line of |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
296 |
Annotated_Formula (position, _, _, _, _, _) => position |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
297 |
| Include (position, _, _) => position |
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
298 |
|
46844 | 299 |
(*Used for debugging. Returns all files contained within a directory or its |
53390 | 300 |
subdirectories. Follows symbolic links, filters away directories. |
301 |
Files are ordered by size*) |
|
46844 | 302 |
fun get_file_list path = |
303 |
let |
|
53390 | 304 |
fun get_file_list' acc paths = |
305 |
case paths of |
|
306 |
[] => acc |
|
307 |
| (f :: fs) => |
|
308 |
let |
|
309 |
(*NOTE needed since no File.is_link and File.read_link*) |
|
310 |
val f_str = Path.implode f |
|
311 |
in |
|
312 |
if File.is_dir f then |
|
313 |
let |
|
314 |
val contents = |
|
315 |
File.read_dir f |
|
316 |
|> map |
|
317 |
(Path.explode |
|
318 |
#> Path.append f) |
|
319 |
in |
|
320 |
get_file_list' acc (fs @ contents) |
|
321 |
end |
|
322 |
else if OS.FileSys.isLink f_str then |
|
323 |
(*follow links -- NOTE this breaks if links are relative paths*) |
|
324 |
get_file_list' acc (Path.explode (OS.FileSys.readLink f_str) :: fs) |
|
325 |
else |
|
326 |
get_file_list' ((f, OS.FileSys.fileSize f_str) :: acc) fs |
|
327 |
end |
|
46844 | 328 |
in |
53390 | 329 |
get_file_list' [] [path] |
330 |
|> sort (fn ((_, n1), (_, n2)) => Int.compare (n1, n2)) |
|
331 |
|> map fst |
|
46844 | 332 |
end |
333 |
||
334 |
fun role_to_string role = |
|
335 |
case role of |
|
336 |
Role_Axiom => "axiom" |
|
337 |
| Role_Hypothesis => "hypothesis" |
|
338 |
| Role_Definition => "definition" |
|
339 |
| Role_Assumption => "assumption" |
|
340 |
| Role_Lemma => "lemma" |
|
341 |
| Role_Theorem => "theorem" |
|
342 |
| Role_Conjecture => "conjecture" |
|
343 |
| Role_Negated_Conjecture => "negated_conjecture" |
|
344 |
| Role_Plain => "plain" |
|
345 |
| Role_Fi_Domain => "fi_domain" |
|
346 |
| Role_Fi_Functors => "fi_functors" |
|
347 |
| Role_Fi_Predicates => "fi_predicates" |
|
348 |
| Role_Type => "type" |
|
349 |
| Role_Unknown => "unknown" |
|
350 |
||
351 |
(*accepts a string "'abc'" and returns "abc"*) |
|
352 |
fun dequote str : single_quoted = |
|
353 |
if str = "" then |
|
354 |
raise (DEQUOTE "empty string") |
|
355 |
else |
|
356 |
(unprefix "'" str |
|
357 |
|> unsuffix "'" |
|
358 |
handle (Fail str) => |
|
359 |
if str = "unprefix" then |
|
360 |
raise DEQUOTE ("string doesn't open with quote:" ^ str) |
|
361 |
else if str = "unsuffix" then |
|
362 |
raise DEQUOTE ("string doesn't close with quote:" ^ str) |
|
363 |
else raise Fail str) |
|
364 |
||
53385 | 365 |
exception UNRECOGNISED_STATUS of string |
366 |
fun read_status status = |
|
367 |
case status of |
|
368 |
"suc" => Suc | "unp" => Unp |
|
369 |
| "sap" => Sap | "esa" => Esa |
|
370 |
| "sat" => Sat | "fsa" => Fsa |
|
371 |
| "thm" => Thm | "wuc" => Wuc |
|
372 |
| "eqv" => Eqv | "tac" => Tac |
|
373 |
| "wec" => Wec | "eth" => Eth |
|
374 |
| "tau" => Tau | "wtc" => Wtc |
|
375 |
| "wth" => Wth | "cax" => Cax |
|
376 |
| "sca" => Sca | "tca" => Tca |
|
377 |
| "wca" => Wca | "cup" => Cup |
|
378 |
| "csp" => Csp | "ecs" => Ecs |
|
379 |
| "csa" => Csa | "cth" => Cth |
|
380 |
| "ceq" => Ceq | "unc" => Unc |
|
381 |
| "wcc" => Wcc | "ect" => Ect |
|
382 |
| "fun" => Fun | "uns" => Uns |
|
383 |
| "wct" => Wct | "scc" => Scc |
|
384 |
| "uca" => Uca | "noc" => Noc |
|
385 |
| thing => raise (UNRECOGNISED_STATUS thing) |
|
46844 | 386 |
|
387 |
(* Printing parsed TPTP formulas *) |
|
388 |
(*FIXME this is not pretty-printing, just printing*) |
|
389 |
||
390 |
fun status_to_string status_value = |
|
391 |
case status_value of |
|
47454 | 392 |
Suc => "suc" | Unp => "unp" |
46844 | 393 |
| Sap => "sap" | Esa => "esa" |
394 |
| Sat => "sat" | Fsa => "fsa" |
|
395 |
| Thm => "thm" | Wuc => "wuc" |
|
47454 | 396 |
| Eqv => "eqv" | Tac => "tac" |
397 |
| Wec => "wec" | Eth => "eth" |
|
398 |
| Tau => "tau" | Wtc => "wtc" |
|
399 |
| Wth => "wth" | Cax => "cax" |
|
400 |
| Sca => "sca" | Tca => "tca" |
|
401 |
| Wca => "wca" | Cup => "cup" |
|
402 |
| Csp => "csp" | Ecs => "ecs" |
|
403 |
| Csa => "csa" | Cth => "cth" |
|
404 |
| Ceq => "ceq" | Unc => "unc" |
|
405 |
| Wcc => "wcc" | Ect => "ect" |
|
406 |
| Fun => "fun" | Uns => "uns" |
|
407 |
| Wct => "wct" | Scc => "scc" |
|
408 |
| Uca => "uca" | Noc => "noc" |
|
46844 | 409 |
|
410 |
fun string_of_tptp_term x = |
|
411 |
case x of |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
412 |
Term_FuncG (symbol, tptp_type_list, tptp_term_list) => |
46844 | 413 |
"(" ^ string_of_symbol symbol ^ " " ^ |
80910 | 414 |
implode_space (map string_of_tptp_type tptp_type_list |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
415 |
@ map string_of_tptp_term tptp_term_list) ^ ")" |
46844 | 416 |
| Term_Var str => str |
417 |
| Term_Conditional (tptp_formula, tptp_term1, tptp_term2) => "" (*FIXME*) |
|
418 |
| Term_Num (_, str) => str |
|
419 |
| Term_Distinct_Object str => str |
|
420 |
||
421 |
and string_of_symbol (Uninterpreted str) = str |
|
422 |
| string_of_symbol (Interpreted_ExtraLogic interpreted_symbol) = string_of_interpreted_symbol interpreted_symbol |
|
423 |
| string_of_symbol (Interpreted_Logic logic_symbol) = string_of_logic_symbol logic_symbol |
|
424 |
| string_of_symbol (TypeSymbol tptp_base_type) = string_of_tptp_base_type tptp_base_type |
|
425 |
| string_of_symbol (System str) = str |
|
426 |
||
427 |
and string_of_tptp_base_type Type_Ind = "$i" |
|
428 |
| string_of_tptp_base_type Type_Bool = "$o" |
|
429 |
| string_of_tptp_base_type Type_Type = "$tType" |
|
430 |
| string_of_tptp_base_type Type_Int = "$int" |
|
431 |
| string_of_tptp_base_type Type_Rat = "$rat" |
|
432 |
| string_of_tptp_base_type Type_Real = "$real" |
|
57808 | 433 |
| string_of_tptp_base_type Type_Dummy = "$_" |
46844 | 434 |
|
435 |
and string_of_interpreted_symbol x = |
|
436 |
case x of |
|
437 |
UMinus => "$uminus" |
|
438 |
| Sum => "$sum" |
|
439 |
| Difference => "$difference" |
|
440 |
| Product => "$product" |
|
441 |
| Quotient => "$quotient" |
|
442 |
| Quotient_E => "$quotient_e" |
|
443 |
| Quotient_T => "$quotient_t" |
|
444 |
| Quotient_F => "$quotient_f" |
|
445 |
| Remainder_E => "$remainder_e" |
|
446 |
| Remainder_T => "$remainder_t" |
|
447 |
| Remainder_F => "$remainder_f" |
|
448 |
| Floor => "$floor" |
|
449 |
| Ceiling => "$ceiling" |
|
450 |
| Truncate => "$truncate" |
|
451 |
| Round => "$round" |
|
452 |
| To_Int => "$to_int" |
|
453 |
| To_Rat => "$to_rat" |
|
454 |
| To_Real => "$to_real" |
|
455 |
| Less => "$less" |
|
456 |
| LessEq => "$lesseq" |
|
457 |
| Greater => "$greater" |
|
458 |
| GreaterEq => "$greatereq" |
|
459 |
| EvalEq => "$evaleq" |
|
460 |
| Is_Int => "$is_int" |
|
461 |
| Is_Rat => "$is_rat" |
|
47692
3d76c81b5ed2
improved non-interpretation of constants and numbers;
sultana
parents:
47569
diff
changeset
|
462 |
| Distinct => "$distinct" |
46844 | 463 |
| Apply => "@" |
464 |
||
465 |
and string_of_logic_symbol Equals = "=" |
|
466 |
| string_of_logic_symbol NEquals = "!=" |
|
467 |
| string_of_logic_symbol Or = "|" |
|
468 |
| string_of_logic_symbol And = "&" |
|
469 |
| string_of_logic_symbol Iff = "<=>" |
|
470 |
| string_of_logic_symbol If = "=>" |
|
471 |
| string_of_logic_symbol Fi = "<=" |
|
472 |
| string_of_logic_symbol Xor = "<~>" |
|
473 |
| string_of_logic_symbol Nor = "~|" |
|
474 |
| string_of_logic_symbol Nand = "~&" |
|
475 |
| string_of_logic_symbol Not = "~" |
|
476 |
| string_of_logic_symbol Op_Forall = "!!" |
|
477 |
| string_of_logic_symbol Op_Exists = "??" |
|
478 |
| string_of_logic_symbol True = "$true" |
|
479 |
| string_of_logic_symbol False = "$false" |
|
480 |
||
481 |
and string_of_quantifier Forall = "!" |
|
482 |
| string_of_quantifier Exists = "?" |
|
483 |
| string_of_quantifier Epsilon = "@+" |
|
484 |
| string_of_quantifier Iota = "@-" |
|
485 |
| string_of_quantifier Lambda = "^" |
|
486 |
| string_of_quantifier Dep_Prod = "!>" |
|
487 |
| string_of_quantifier Dep_Sum = "?*" |
|
488 |
||
489 |
and string_of_tptp_atom (TFF_Typed_Atom (symbol, tptp_type_option)) = |
|
490 |
(case tptp_type_option of |
|
491 |
NONE => string_of_symbol symbol |
|
492 |
| SOME tptp_type => |
|
493 |
string_of_symbol symbol ^ " : " ^ string_of_tptp_type tptp_type) |
|
494 |
| string_of_tptp_atom (THF_Atom_term tptp_term) = string_of_tptp_term tptp_term |
|
495 |
| string_of_tptp_atom (THF_Atom_conn_term symbol) = string_of_symbol symbol |
|
496 |
||
497 |
and string_of_tptp_formula (Pred (symbol, tptp_term_list)) = |
|
498 |
"(" ^ string_of_symbol symbol ^ |
|
80910 | 499 |
implode_space (map string_of_tptp_term tptp_term_list) ^ ")" |
46844 | 500 |
| string_of_tptp_formula (Fmla (symbol, tptp_formula_list)) = |
501 |
"(" ^ |
|
502 |
string_of_symbol symbol ^ |
|
80910 | 503 |
implode_space (map string_of_tptp_formula tptp_formula_list) ^ ")" |
46844 | 504 |
| string_of_tptp_formula (Sequent (tptp_formula_list1, tptp_formula_list2)) = "" (*FIXME*) |
505 |
| string_of_tptp_formula (Quant (quantifier, varlist, tptp_formula)) = |
|
506 |
string_of_quantifier quantifier ^ "[" ^ |
|
47426 | 507 |
space_implode ", " (map (fn (n, ty) => |
46844 | 508 |
case ty of |
509 |
NONE => n |
|
510 |
| SOME ty => n ^ " : " ^ string_of_tptp_type ty) varlist) ^ "] : (" ^ |
|
511 |
string_of_tptp_formula tptp_formula ^ ")" |
|
512 |
| string_of_tptp_formula (Conditional _) = "" (*FIXME*) |
|
513 |
| string_of_tptp_formula (Let _) = "" (*FIXME*) |
|
514 |
| string_of_tptp_formula (Atom tptp_atom) = string_of_tptp_atom tptp_atom |
|
47360 | 515 |
| string_of_tptp_formula (Type_fmla tptp_type) = string_of_tptp_type tptp_type |
46844 | 516 |
| string_of_tptp_formula (THF_typing (tptp_formula, tptp_type)) = |
517 |
string_of_tptp_formula tptp_formula ^ " : " ^ string_of_tptp_type tptp_type |
|
518 |
||
519 |
and string_of_tptp_type (Prod_type (tptp_type1, tptp_type2)) = |
|
520 |
string_of_tptp_type tptp_type1 ^ " * " ^ string_of_tptp_type tptp_type2 |
|
521 |
| string_of_tptp_type (Fn_type (tptp_type1, tptp_type2)) = |
|
522 |
string_of_tptp_type tptp_type1 ^ " > " ^ string_of_tptp_type tptp_type2 |
|
57808 | 523 |
| string_of_tptp_type (Atom_type (str, [])) = str |
524 |
| string_of_tptp_type (Atom_type (str, tptp_types)) = |
|
525 |
str ^ "(" ^ commas (map string_of_tptp_type tptp_types) ^ ")" |
|
526 |
| string_of_tptp_type (Var_type str) = str |
|
46844 | 527 |
| string_of_tptp_type (Defined_type tptp_base_type) = |
528 |
string_of_tptp_base_type tptp_base_type |
|
529 |
| string_of_tptp_type (Sum_type (tptp_type1, tptp_type2)) = "" |
|
530 |
| string_of_tptp_type (Fmla_type tptp_formula) = string_of_tptp_formula tptp_formula |
|
531 |
| string_of_tptp_type (Subtype (symbol1, symbol2)) = |
|
532 |
string_of_symbol symbol1 ^ " << " ^ string_of_symbol symbol2 |
|
533 |
||
55594 | 534 |
(*FIXME formatting details haven't been fully worked out -- don't use this function for anything serious in its current form!*) |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
535 |
(*TODO Add subscripting*) |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
536 |
(*infix symbols, including \subset, \cup, \cap*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
537 |
fun latex_of_tptp_term x = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
538 |
case x of |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
539 |
Term_FuncG (Interpreted_Logic Equals, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
540 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " = " ^ latex_of_tptp_term tptp_t2 ^ ")" |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
541 |
| Term_FuncG (Interpreted_Logic NEquals, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
542 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\neq " ^ latex_of_tptp_term tptp_t2 ^ ")" |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
543 |
| Term_FuncG (Interpreted_Logic Or, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
544 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\vee " ^ latex_of_tptp_term tptp_t2 ^ ")" |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
545 |
| Term_FuncG (Interpreted_Logic And, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
546 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\wedge " ^ latex_of_tptp_term tptp_t2 ^ ")" |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
547 |
| Term_FuncG (Interpreted_Logic Iff, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
548 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longleftrightarrow " ^ latex_of_tptp_term tptp_t2 ^ ")" |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
549 |
| Term_FuncG (Interpreted_Logic If, [], [tptp_t1, tptp_t2]) => |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
550 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longrightarrow " ^ latex_of_tptp_term tptp_t2 ^ ")" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
551 |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
552 |
| Term_FuncG (symbol, tptp_type_list, tptp_term_list) => |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
553 |
(*"(" ^*) latex_of_symbol symbol ^ "\\\\, " ^ |
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
554 |
space_implode "\\\\, " (map latex_of_tptp_type tptp_type_list |
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
555 |
@ map latex_of_tptp_term tptp_term_list) (*^ ")"*) |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
556 |
| Term_Var str => "\\\\mathrm{" ^ str ^ "}" |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
557 |
| Term_Conditional (tptp_formula, tptp_term1, tptp_term2) => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
558 |
| Term_Num (_, str) => str |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
559 |
| Term_Distinct_Object str => str (*FIXME*) |
55594 | 560 |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
561 |
and latex_of_symbol (Uninterpreted str) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
562 |
if str = "emptyset" then "\\\\emptyset" |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
563 |
else "\\\\mathrm{" ^ str ^ "}" |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
564 |
| latex_of_symbol (Interpreted_ExtraLogic interpreted_symbol) = latex_of_interpreted_symbol interpreted_symbol |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
565 |
| latex_of_symbol (Interpreted_Logic logic_symbol) = latex_of_logic_symbol logic_symbol |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
566 |
| latex_of_symbol (TypeSymbol tptp_base_type) = latex_of_tptp_base_type tptp_base_type |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
567 |
| latex_of_symbol (System str) = "\\\\mathrm{" ^ str ^ "}" |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
568 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
569 |
and latex_of_tptp_base_type Type_Ind = "\\\\iota " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
570 |
| latex_of_tptp_base_type Type_Bool = "o" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
571 |
| latex_of_tptp_base_type Type_Type = "\\\\mathcal{T} " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
572 |
| latex_of_tptp_base_type Type_Int = "\\\\mathsf{int} " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
573 |
| latex_of_tptp_base_type Type_Rat = "\\\\mathsf{rat} " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
574 |
| latex_of_tptp_base_type Type_Real = "\\\\mathsf{real} " |
57808 | 575 |
| latex_of_tptp_base_type Type_Dummy = "\\\\mathsf{\\\\_} " |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
576 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
577 |
and latex_of_interpreted_symbol x = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
578 |
case x of |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
579 |
UMinus => "-" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
580 |
| Sum => "-" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
581 |
| Difference => "-" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
582 |
| Product => "*" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
583 |
| Quotient => "/" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
584 |
| Quotient_E => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
585 |
| Quotient_T => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
586 |
| Quotient_F => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
587 |
| Remainder_E => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
588 |
| Remainder_T => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
589 |
| Remainder_F => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
590 |
| Floor => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
591 |
| Ceiling => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
592 |
| Truncate => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
593 |
| Round => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
594 |
| To_Int => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
595 |
| To_Rat => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
596 |
| To_Real => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
597 |
| Less => "<" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
598 |
| LessEq => "\\\\leq " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
599 |
| Greater => ">" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
600 |
| GreaterEq => "\\\\geq " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
601 |
| EvalEq => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
602 |
| Is_Int => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
603 |
| Is_Rat => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
604 |
| Distinct => "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
605 |
| Apply => "\\\\;" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
606 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
607 |
and latex_of_logic_symbol Equals = "=" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
608 |
| latex_of_logic_symbol NEquals = "\\\\neq " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
609 |
| latex_of_logic_symbol Or = "\\\\vee " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
610 |
| latex_of_logic_symbol And = "\\\\wedge " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
611 |
| latex_of_logic_symbol Iff = "\\\\longleftrightarrow " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
612 |
| latex_of_logic_symbol If = "\\\\longrightarrow " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
613 |
| latex_of_logic_symbol Fi = "\\\\longleftarrow " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
614 |
| latex_of_logic_symbol Xor = "\\\\oplus " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
615 |
| latex_of_logic_symbol Nor = "\\\\not\\\\vee " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
616 |
| latex_of_logic_symbol Nand = "\\\\not\\\\wedge " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
617 |
| latex_of_logic_symbol Not = "\\\\neg " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
618 |
| latex_of_logic_symbol Op_Forall = "\\\\forall " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
619 |
| latex_of_logic_symbol Op_Exists = "\\\\exists " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
620 |
| latex_of_logic_symbol True = "\\\\mathsf{true} " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
621 |
| latex_of_logic_symbol False = "\\\\mathsf{false} " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
622 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
623 |
and latex_of_quantifier Forall = "\\\\forall " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
624 |
| latex_of_quantifier Exists = "\\\\exists " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
625 |
| latex_of_quantifier Epsilon = "\\\\varepsilon " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
626 |
| latex_of_quantifier Iota = "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
627 |
| latex_of_quantifier Lambda = "\\\\lambda " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
628 |
| latex_of_quantifier Dep_Prod = "\\\\Pi " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
629 |
| latex_of_quantifier Dep_Sum = "\\\\Sigma " |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
630 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
631 |
and latex_of_tptp_atom (TFF_Typed_Atom (symbol, tptp_type_option)) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
632 |
(case tptp_type_option of |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
633 |
NONE => latex_of_symbol symbol |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
634 |
| SOME tptp_type => |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
635 |
latex_of_symbol symbol ^ " : " ^ latex_of_tptp_type tptp_type) |
55594 | 636 |
| latex_of_tptp_atom (THF_Atom_term tptp_term) = latex_of_tptp_term tptp_term |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
637 |
| latex_of_tptp_atom (THF_Atom_conn_term symbol) = latex_of_symbol symbol |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
638 |
|
55594 | 639 |
and latex_of_tptp_formula (Pred (Interpreted_Logic Equals, [tptp_t1, tptp_t2])) = |
640 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " = " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
641 |
| latex_of_tptp_formula (Pred (Interpreted_Logic NEquals, [tptp_t1, tptp_t2])) = |
|
642 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\neq " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
643 |
| latex_of_tptp_formula (Pred (Interpreted_Logic Or, [tptp_t1, tptp_t2])) = |
|
644 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\vee " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
645 |
| latex_of_tptp_formula (Pred (Interpreted_Logic And, [tptp_t1, tptp_t2])) = |
|
646 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\wedge " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
647 |
| latex_of_tptp_formula (Pred (Interpreted_Logic Iff, [tptp_t1, tptp_t2])) = |
|
648 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longleftrightarrow " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
649 |
| latex_of_tptp_formula (Pred (Interpreted_Logic If, [tptp_t1, tptp_t2])) = |
|
650 |
"(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longrightarrow " ^ latex_of_tptp_term tptp_t2 ^ ")" |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
651 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
652 |
| latex_of_tptp_formula (x as (Pred (symbol, tptp_term_list))) = |
55594 | 653 |
latex_of_symbol symbol ^ |
654 |
space_implode "\\\\, " (map latex_of_tptp_term tptp_term_list) |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
655 |
|
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
656 |
| latex_of_tptp_formula (Fmla (Interpreted_ExtraLogic Apply, [Fmla (Interpreted_ExtraLogic Apply, [Atom (THF_Atom_term (Term_FuncG (Uninterpreted "union", [], []))), tptp_f1]), tptp_f2])) = |
55594 | 657 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\cup " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
658 |
||
64560
c48becd96398
support THF1 parsing for 'tptp_...' commands (e.g. 'tptp_isabelle') -- useful for CASC, SystemOnTPTP, ...
blanchet
parents:
57808
diff
changeset
|
659 |
| latex_of_tptp_formula (Fmla (Interpreted_ExtraLogic Apply, [Fmla (Interpreted_ExtraLogic Apply, [Atom (THF_Atom_term (Term_FuncG (Uninterpreted "subset", [], []))), tptp_f1]), tptp_f2])) = |
55594 | 660 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\subset " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
661 |
|
55594 | 662 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic Equals, [tptp_f1, tptp_f2])) = |
663 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " = " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
664 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic NEquals, [tptp_f1, tptp_f2])) = |
|
665 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\neq " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
666 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic Or, [tptp_f1, tptp_f2])) = |
|
667 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\vee " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
668 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic And, [tptp_f1, tptp_f2])) = |
|
669 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\wedge " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
670 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic Iff, [tptp_f1, tptp_f2])) = |
|
671 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\longleftrightarrow " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
672 |
| latex_of_tptp_formula (Fmla (Interpreted_Logic If, [tptp_f1, tptp_f2])) = |
|
673 |
"(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\longrightarrow " ^ latex_of_tptp_formula tptp_f2 ^ ")" |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
674 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
675 |
| latex_of_tptp_formula (x as (Fmla (symbol, tptp_formula_list))) = |
55594 | 676 |
latex_of_symbol symbol ^ |
677 |
space_implode "\\\\, " (map latex_of_tptp_formula tptp_formula_list) |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
678 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
679 |
| latex_of_tptp_formula (Sequent (tptp_formula_list1, tptp_formula_list2)) = "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
680 |
| latex_of_tptp_formula (Quant (quantifier, varlist, tptp_formula)) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
681 |
latex_of_quantifier quantifier ^ |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
682 |
space_implode ", " (map (fn (n, ty) => |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
683 |
case ty of |
55588
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
684 |
NONE => "\\\\mathrm{" ^ n ^ "}" |
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
sultana
parents:
55587
diff
changeset
|
685 |
| SOME ty => "\\\\mathrm{" ^ n ^ "} : " ^ latex_of_tptp_type ty) varlist) ^ ". (" ^ |
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
686 |
latex_of_tptp_formula tptp_formula ^ ")" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
687 |
| latex_of_tptp_formula (Conditional _) = "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
688 |
| latex_of_tptp_formula (Let _) = "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
689 |
| latex_of_tptp_formula (Atom tptp_atom) = latex_of_tptp_atom tptp_atom |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
690 |
| latex_of_tptp_formula (Type_fmla tptp_type) = latex_of_tptp_type tptp_type |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
691 |
| latex_of_tptp_formula (THF_typing (tptp_formula, tptp_type)) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
692 |
latex_of_tptp_formula tptp_formula ^ " : " ^ latex_of_tptp_type tptp_type |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
693 |
|
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
694 |
and latex_of_tptp_type (Prod_type (tptp_type1, tptp_type2)) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
695 |
latex_of_tptp_type tptp_type1 ^ " \\\\times " ^ latex_of_tptp_type tptp_type2 |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
696 |
| latex_of_tptp_type (Fn_type (tptp_type1, tptp_type2)) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
697 |
latex_of_tptp_type tptp_type1 ^ " \\\\to " ^ latex_of_tptp_type tptp_type2 |
57808 | 698 |
| latex_of_tptp_type (Atom_type (str, [])) = "\\\\mathrm{" ^ str ^ "}" |
699 |
| latex_of_tptp_type (Atom_type (str, tptp_types)) = |
|
700 |
"\\\\mathrm{" ^ str ^ "}(" ^ commas (map latex_of_tptp_type tptp_types) ^ ")" |
|
701 |
| latex_of_tptp_type (Var_type str) = "\\\\mathrm{" ^ str ^ "}" |
|
55587
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
702 |
| latex_of_tptp_type (Defined_type tptp_base_type) = |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
703 |
latex_of_tptp_base_type tptp_base_type |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
704 |
| latex_of_tptp_type (Sum_type (tptp_type1, tptp_type2)) = "" |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
705 |
| latex_of_tptp_type (Fmla_type tptp_formula) = latex_of_tptp_formula tptp_formula |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
706 |
| latex_of_tptp_type (Subtype (symbol1, symbol2)) = "" (*FIXME*) |
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
sultana
parents:
53394
diff
changeset
|
707 |
|
46844 | 708 |
end |