| author | blanchet |
| Wed, 12 Feb 2014 08:35:56 +0100 | |
| changeset 55411 | 27de2c976d90 |
| parent 53394 | f26f00cbd573 |
| child 55587 | 5d3db2c626e3 |
| 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 = |
|
69 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real |
|
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 = |
|
84 |
Term_Func of symbol * tptp_term list |
|
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 |
|
114 |
| Atom_type of string |
|
115 |
| Defined_type of tptp_base_type |
|
116 |
| 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
|
117 |
| Fmla_type of tptp_formula |
| 46844 | 118 |
| Subtype of symbol * symbol (*only THF*) |
119 |
||
120 |
type general_list = general_term list |
|
121 |
type parent_details = general_list |
|
122 |
type useful_info = general_term list |
|
123 |
type info = useful_info |
|
124 |
||
125 |
type annotation = general_term * general_term list |
|
126 |
||
127 |
exception DEQUOTE of string |
|
128 |
||
129 |
type position = string * int * int |
|
130 |
||
131 |
datatype tptp_line = |
|
| 47360 | 132 |
Annotated_Formula of position * language * string * role * |
133 |
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
|
134 |
| Include of position * string * string list |
| 46844 | 135 |
|
136 |
type tptp_problem = tptp_line list |
|
137 |
||
138 |
val dequote : single_quoted -> single_quoted |
|
139 |
||
140 |
val role_to_string : role -> string |
|
141 |
||
142 |
val status_to_string : status_value -> string |
|
143 |
||
144 |
val nameof_tff_atom_type : tptp_type -> string |
|
145 |
||
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
146 |
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
|
147 |
|
| 46844 | 148 |
(*Returns the list of all files included in a directory and its |
149 |
subdirectories. This is only used for testing the parser/interpreter against |
|
150 |
all THF problems.*) |
|
151 |
val get_file_list : Path.T -> Path.T list |
|
152 |
||
| 53385 | 153 |
val read_status : string -> status_value |
| 46844 | 154 |
val string_of_tptp_term : tptp_term -> string |
|
47692
3d76c81b5ed2
improved non-interpretation of constants and numbers;
sultana
parents:
47569
diff
changeset
|
155 |
val string_of_interpreted_symbol : interpreted_symbol -> string |
| 46844 | 156 |
val string_of_tptp_formula : tptp_formula -> string |
157 |
||
158 |
end |
|
159 |
||
160 |
||
161 |
structure TPTP_Syntax : TPTP_SYNTAX = |
|
162 |
struct |
|
163 |
||
164 |
exception TPTP_SYNTAX of string |
|
165 |
||
166 |
datatype number_kind = Int_num | Real_num | Rat_num |
|
167 |
||
168 |
datatype status_value = |
|
169 |
Suc | Unp | Sap | Esa | Sat | Fsa |
|
170 |
| Thm | Eqv | Tac | Wec | Eth | Tau |
|
171 |
| Wtc | Wth | Cax | Sca | Tca | Wca |
|
172 |
| Cup | Csp | Ecs | Csa | Cth | Ceq |
|
173 |
| Unc | Wcc | Ect | Fun | Uns | Wuc |
|
174 |
| Wct | Scc | Uca | Noc |
|
175 |
||
176 |
type name = string |
|
177 |
type atomic_word = string |
|
178 |
type inference_rule = atomic_word |
|
179 |
type file_info = name option |
|
180 |
type single_quoted = string |
|
181 |
type file_name = single_quoted |
|
182 |
type creator_name = atomic_word |
|
183 |
type variable = string |
|
184 |
type upper_word = string |
|
185 |
||
186 |
datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic |
|
187 |
and role = |
|
188 |
Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption | |
|
189 |
Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture | |
|
190 |
Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates | |
|
191 |
Role_Type | Role_Unknown |
|
192 |
and general_data = (*Bind of variable * formula_data*) |
|
193 |
Atomic_Word of string |
|
194 |
| Application of string * (general_term list) |
|
195 |
| V of upper_word (*variable*) |
|
196 |
| Number of number_kind * string |
|
197 |
| Distinct_Object of string |
|
198 |
| (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *) |
|
199 |
| (*formula_data*) Term_Data of tptp_term |
|
200 |
||
201 |
and interpreted_symbol = |
|
202 |
UMinus | Sum | Difference | Product | Quotient | Quotient_E | |
|
203 |
Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F | |
|
204 |
Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real | |
|
205 |
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
|
206 |
Distinct | |
| 47360 | 207 |
Apply |
| 46844 | 208 |
|
209 |
and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor | |
|
210 |
Nor | Nand | Not | Op_Forall | Op_Exists | |
|
211 |
True | False |
|
212 |
||
213 |
and quantifier = (*interpreted binders*) |
|
214 |
Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum |
|
215 |
||
216 |
and tptp_base_type = |
|
217 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real |
|
218 |
||
219 |
and symbol = |
|
220 |
Uninterpreted of string |
|
221 |
| Interpreted_ExtraLogic of interpreted_symbol |
|
222 |
| Interpreted_Logic of logic_symbol |
|
223 |
| TypeSymbol of tptp_base_type |
|
224 |
| System of string |
|
225 |
||
226 |
and general_term = |
|
227 |
General_Data of general_data (*general_data*) |
|
228 |
| General_Term of general_data * general_term (*general_data : general_term*) |
|
229 |
| General_List of general_term list |
|
230 |
||
231 |
and tptp_term = |
|
232 |
Term_Func of symbol * tptp_term list |
|
233 |
| Term_Var of string |
|
234 |
| Term_Conditional of tptp_formula * tptp_term * tptp_term |
|
235 |
| Term_Num of number_kind * string |
|
236 |
| Term_Distinct_Object of string |
|
| 53394 | 237 |
| Term_Let of tptp_let * tptp_term |
| 46844 | 238 |
|
239 |
and tptp_atom = |
|
240 |
TFF_Typed_Atom of symbol * tptp_type option (*only TFF*) |
|
241 |
| THF_Atom_term of tptp_term (*from here on, only THF*) |
|
242 |
| THF_Atom_conn_term of symbol |
|
243 |
||
244 |
and tptp_formula = |
|
245 |
Pred of symbol * tptp_term list |
|
246 |
| Fmla of symbol * tptp_formula list |
|
247 |
| Sequent of tptp_formula list * tptp_formula list |
|
248 |
| Quant of quantifier * (string * tptp_type option) list * tptp_formula |
|
249 |
| Conditional of tptp_formula * tptp_formula * tptp_formula |
|
| 53394 | 250 |
| Let of tptp_let * tptp_formula |
| 46844 | 251 |
| Atom of tptp_atom |
| 47360 | 252 |
| Type_fmla of tptp_type |
| 46844 | 253 |
| THF_typing of tptp_formula * tptp_type |
254 |
||
255 |
and tptp_let = |
|
| 53394 | 256 |
Let_fmla of (string * tptp_type option) list * tptp_formula |
257 |
| Let_term of (string * tptp_type option) list * tptp_term |
|
| 46844 | 258 |
|
259 |
and tptp_type = |
|
260 |
Prod_type of tptp_type * tptp_type |
|
261 |
| Fn_type of tptp_type * tptp_type |
|
262 |
| Atom_type of string |
|
263 |
| Defined_type of tptp_base_type |
|
| 47360 | 264 |
| Sum_type of tptp_type * tptp_type |
265 |
| Fmla_type of tptp_formula |
|
266 |
| Subtype of symbol * symbol |
|
| 46844 | 267 |
|
268 |
type general_list = general_term list |
|
269 |
type parent_details = general_list |
|
270 |
type useful_info = general_term list |
|
271 |
type info = useful_info |
|
272 |
||
273 |
(*type annotation = (source * info option)*) |
|
274 |
type annotation = general_term * general_term list |
|
275 |
||
276 |
exception DEQUOTE of string |
|
277 |
||
278 |
type position = string * int * int |
|
279 |
||
280 |
datatype tptp_line = |
|
281 |
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
|
282 |
| Include of position * string * string list |
| 46844 | 283 |
|
284 |
type tptp_problem = tptp_line list |
|
285 |
||
286 |
fun debug f x = if !Runtime.debug then (f x; ()) else () |
|
287 |
||
288 |
fun nameof_tff_atom_type (Atom_type str) = str |
|
289 |
| nameof_tff_atom_type _ = raise TPTP_SYNTAX "nameof_tff_atom_type called on non-atom type" |
|
290 |
||
|
47569
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
| Include (position, _, _) => position |
|
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
sultana
parents:
47454
diff
changeset
|
295 |
|
| 46844 | 296 |
(*Used for debugging. Returns all files contained within a directory or its |
| 53390 | 297 |
subdirectories. Follows symbolic links, filters away directories. |
298 |
Files are ordered by size*) |
|
| 46844 | 299 |
fun get_file_list path = |
300 |
let |
|
| 53390 | 301 |
fun get_file_list' acc paths = |
302 |
case paths of |
|
303 |
[] => acc |
|
304 |
| (f :: fs) => |
|
305 |
let |
|
306 |
(*NOTE needed since no File.is_link and File.read_link*) |
|
307 |
val f_str = Path.implode f |
|
308 |
in |
|
309 |
if File.is_dir f then |
|
310 |
let |
|
311 |
val contents = |
|
312 |
File.read_dir f |
|
313 |
|> map |
|
314 |
(Path.explode |
|
315 |
#> Path.append f) |
|
316 |
in |
|
317 |
get_file_list' acc (fs @ contents) |
|
318 |
end |
|
319 |
else if OS.FileSys.isLink f_str then |
|
320 |
(*follow links -- NOTE this breaks if links are relative paths*) |
|
321 |
get_file_list' acc (Path.explode (OS.FileSys.readLink f_str) :: fs) |
|
322 |
else |
|
323 |
get_file_list' ((f, OS.FileSys.fileSize f_str) :: acc) fs |
|
324 |
end |
|
| 46844 | 325 |
in |
| 53390 | 326 |
get_file_list' [] [path] |
327 |
|> sort (fn ((_, n1), (_, n2)) => Int.compare (n1, n2)) |
|
328 |
|> map fst |
|
| 46844 | 329 |
end |
330 |
||
331 |
fun role_to_string role = |
|
332 |
case role of |
|
333 |
Role_Axiom => "axiom" |
|
334 |
| Role_Hypothesis => "hypothesis" |
|
335 |
| Role_Definition => "definition" |
|
336 |
| Role_Assumption => "assumption" |
|
337 |
| Role_Lemma => "lemma" |
|
338 |
| Role_Theorem => "theorem" |
|
339 |
| Role_Conjecture => "conjecture" |
|
340 |
| Role_Negated_Conjecture => "negated_conjecture" |
|
341 |
| Role_Plain => "plain" |
|
342 |
| Role_Fi_Domain => "fi_domain" |
|
343 |
| Role_Fi_Functors => "fi_functors" |
|
344 |
| Role_Fi_Predicates => "fi_predicates" |
|
345 |
| Role_Type => "type" |
|
346 |
| Role_Unknown => "unknown" |
|
347 |
||
348 |
(*accepts a string "'abc'" and returns "abc"*) |
|
349 |
fun dequote str : single_quoted = |
|
350 |
if str = "" then |
|
351 |
raise (DEQUOTE "empty string") |
|
352 |
else |
|
353 |
(unprefix "'" str |
|
354 |
|> unsuffix "'" |
|
355 |
handle (Fail str) => |
|
356 |
if str = "unprefix" then |
|
357 |
raise DEQUOTE ("string doesn't open with quote:" ^ str)
|
|
358 |
else if str = "unsuffix" then |
|
359 |
raise DEQUOTE ("string doesn't close with quote:" ^ str)
|
|
360 |
else raise Fail str) |
|
361 |
||
| 53385 | 362 |
exception UNRECOGNISED_STATUS of string |
363 |
fun read_status status = |
|
364 |
case status of |
|
365 |
"suc" => Suc | "unp" => Unp |
|
366 |
| "sap" => Sap | "esa" => Esa |
|
367 |
| "sat" => Sat | "fsa" => Fsa |
|
368 |
| "thm" => Thm | "wuc" => Wuc |
|
369 |
| "eqv" => Eqv | "tac" => Tac |
|
370 |
| "wec" => Wec | "eth" => Eth |
|
371 |
| "tau" => Tau | "wtc" => Wtc |
|
372 |
| "wth" => Wth | "cax" => Cax |
|
373 |
| "sca" => Sca | "tca" => Tca |
|
374 |
| "wca" => Wca | "cup" => Cup |
|
375 |
| "csp" => Csp | "ecs" => Ecs |
|
376 |
| "csa" => Csa | "cth" => Cth |
|
377 |
| "ceq" => Ceq | "unc" => Unc |
|
378 |
| "wcc" => Wcc | "ect" => Ect |
|
379 |
| "fun" => Fun | "uns" => Uns |
|
380 |
| "wct" => Wct | "scc" => Scc |
|
381 |
| "uca" => Uca | "noc" => Noc |
|
382 |
| thing => raise (UNRECOGNISED_STATUS thing) |
|
| 46844 | 383 |
|
384 |
(* Printing parsed TPTP formulas *) |
|
385 |
(*FIXME this is not pretty-printing, just printing*) |
|
386 |
||
387 |
fun status_to_string status_value = |
|
388 |
case status_value of |
|
| 47454 | 389 |
Suc => "suc" | Unp => "unp" |
| 46844 | 390 |
| Sap => "sap" | Esa => "esa" |
391 |
| Sat => "sat" | Fsa => "fsa" |
|
392 |
| Thm => "thm" | Wuc => "wuc" |
|
| 47454 | 393 |
| Eqv => "eqv" | Tac => "tac" |
394 |
| Wec => "wec" | Eth => "eth" |
|
395 |
| Tau => "tau" | Wtc => "wtc" |
|
396 |
| Wth => "wth" | Cax => "cax" |
|
397 |
| Sca => "sca" | Tca => "tca" |
|
398 |
| Wca => "wca" | Cup => "cup" |
|
399 |
| Csp => "csp" | Ecs => "ecs" |
|
400 |
| Csa => "csa" | Cth => "cth" |
|
401 |
| Ceq => "ceq" | Unc => "unc" |
|
402 |
| Wcc => "wcc" | Ect => "ect" |
|
403 |
| Fun => "fun" | Uns => "uns" |
|
404 |
| Wct => "wct" | Scc => "scc" |
|
405 |
| Uca => "uca" | Noc => "noc" |
|
| 46844 | 406 |
|
407 |
fun string_of_tptp_term x = |
|
408 |
case x of |
|
409 |
Term_Func (symbol, tptp_term_list) => |
|
410 |
"(" ^ string_of_symbol symbol ^ " " ^
|
|
| 47426 | 411 |
space_implode " " (map string_of_tptp_term tptp_term_list) ^ ")" |
| 46844 | 412 |
| Term_Var str => str |
413 |
| Term_Conditional (tptp_formula, tptp_term1, tptp_term2) => "" (*FIXME*) |
|
414 |
| Term_Num (_, str) => str |
|
415 |
| Term_Distinct_Object str => str |
|
416 |
||
417 |
and string_of_symbol (Uninterpreted str) = str |
|
418 |
| string_of_symbol (Interpreted_ExtraLogic interpreted_symbol) = string_of_interpreted_symbol interpreted_symbol |
|
419 |
| string_of_symbol (Interpreted_Logic logic_symbol) = string_of_logic_symbol logic_symbol |
|
420 |
| string_of_symbol (TypeSymbol tptp_base_type) = string_of_tptp_base_type tptp_base_type |
|
421 |
| string_of_symbol (System str) = str |
|
422 |
||
423 |
and string_of_tptp_base_type Type_Ind = "$i" |
|
424 |
| string_of_tptp_base_type Type_Bool = "$o" |
|
425 |
| string_of_tptp_base_type Type_Type = "$tType" |
|
426 |
| string_of_tptp_base_type Type_Int = "$int" |
|
427 |
| string_of_tptp_base_type Type_Rat = "$rat" |
|
428 |
| string_of_tptp_base_type Type_Real = "$real" |
|
429 |
||
430 |
and string_of_interpreted_symbol x = |
|
431 |
case x of |
|
432 |
UMinus => "$uminus" |
|
433 |
| Sum => "$sum" |
|
434 |
| Difference => "$difference" |
|
435 |
| Product => "$product" |
|
436 |
| Quotient => "$quotient" |
|
437 |
| Quotient_E => "$quotient_e" |
|
438 |
| Quotient_T => "$quotient_t" |
|
439 |
| Quotient_F => "$quotient_f" |
|
440 |
| Remainder_E => "$remainder_e" |
|
441 |
| Remainder_T => "$remainder_t" |
|
442 |
| Remainder_F => "$remainder_f" |
|
443 |
| Floor => "$floor" |
|
444 |
| Ceiling => "$ceiling" |
|
445 |
| Truncate => "$truncate" |
|
446 |
| Round => "$round" |
|
447 |
| To_Int => "$to_int" |
|
448 |
| To_Rat => "$to_rat" |
|
449 |
| To_Real => "$to_real" |
|
450 |
| Less => "$less" |
|
451 |
| LessEq => "$lesseq" |
|
452 |
| Greater => "$greater" |
|
453 |
| GreaterEq => "$greatereq" |
|
454 |
| EvalEq => "$evaleq" |
|
455 |
| Is_Int => "$is_int" |
|
456 |
| Is_Rat => "$is_rat" |
|
|
47692
3d76c81b5ed2
improved non-interpretation of constants and numbers;
sultana
parents:
47569
diff
changeset
|
457 |
| Distinct => "$distinct" |
| 46844 | 458 |
| Apply => "@" |
459 |
||
460 |
and string_of_logic_symbol Equals = "=" |
|
461 |
| string_of_logic_symbol NEquals = "!=" |
|
462 |
| string_of_logic_symbol Or = "|" |
|
463 |
| string_of_logic_symbol And = "&" |
|
464 |
| string_of_logic_symbol Iff = "<=>" |
|
465 |
| string_of_logic_symbol If = "=>" |
|
466 |
| string_of_logic_symbol Fi = "<=" |
|
467 |
| string_of_logic_symbol Xor = "<~>" |
|
468 |
| string_of_logic_symbol Nor = "~|" |
|
469 |
| string_of_logic_symbol Nand = "~&" |
|
470 |
| string_of_logic_symbol Not = "~" |
|
471 |
| string_of_logic_symbol Op_Forall = "!!" |
|
472 |
| string_of_logic_symbol Op_Exists = "??" |
|
473 |
| string_of_logic_symbol True = "$true" |
|
474 |
| string_of_logic_symbol False = "$false" |
|
475 |
||
476 |
and string_of_quantifier Forall = "!" |
|
477 |
| string_of_quantifier Exists = "?" |
|
478 |
| string_of_quantifier Epsilon = "@+" |
|
479 |
| string_of_quantifier Iota = "@-" |
|
480 |
| string_of_quantifier Lambda = "^" |
|
481 |
| string_of_quantifier Dep_Prod = "!>" |
|
482 |
| string_of_quantifier Dep_Sum = "?*" |
|
483 |
||
484 |
and string_of_tptp_atom (TFF_Typed_Atom (symbol, tptp_type_option)) = |
|
485 |
(case tptp_type_option of |
|
486 |
NONE => string_of_symbol symbol |
|
487 |
| SOME tptp_type => |
|
488 |
string_of_symbol symbol ^ " : " ^ string_of_tptp_type tptp_type) |
|
489 |
| string_of_tptp_atom (THF_Atom_term tptp_term) = string_of_tptp_term tptp_term |
|
490 |
| string_of_tptp_atom (THF_Atom_conn_term symbol) = string_of_symbol symbol |
|
491 |
||
492 |
and string_of_tptp_formula (Pred (symbol, tptp_term_list)) = |
|
493 |
"(" ^ string_of_symbol symbol ^
|
|
| 47426 | 494 |
space_implode " " (map string_of_tptp_term tptp_term_list) ^ ")" |
| 46844 | 495 |
| string_of_tptp_formula (Fmla (symbol, tptp_formula_list)) = |
496 |
"(" ^
|
|
497 |
string_of_symbol symbol ^ |
|
| 47426 | 498 |
space_implode " " (map string_of_tptp_formula tptp_formula_list) ^ ")" |
| 46844 | 499 |
| string_of_tptp_formula (Sequent (tptp_formula_list1, tptp_formula_list2)) = "" (*FIXME*) |
500 |
| string_of_tptp_formula (Quant (quantifier, varlist, tptp_formula)) = |
|
501 |
string_of_quantifier quantifier ^ "[" ^ |
|
| 47426 | 502 |
space_implode ", " (map (fn (n, ty) => |
| 46844 | 503 |
case ty of |
504 |
NONE => n |
|
505 |
| SOME ty => n ^ " : " ^ string_of_tptp_type ty) varlist) ^ "] : (" ^
|
|
506 |
string_of_tptp_formula tptp_formula ^ ")" |
|
507 |
| string_of_tptp_formula (Conditional _) = "" (*FIXME*) |
|
508 |
| string_of_tptp_formula (Let _) = "" (*FIXME*) |
|
509 |
| string_of_tptp_formula (Atom tptp_atom) = string_of_tptp_atom tptp_atom |
|
| 47360 | 510 |
| string_of_tptp_formula (Type_fmla tptp_type) = string_of_tptp_type tptp_type |
| 46844 | 511 |
| string_of_tptp_formula (THF_typing (tptp_formula, tptp_type)) = |
512 |
string_of_tptp_formula tptp_formula ^ " : " ^ string_of_tptp_type tptp_type |
|
513 |
||
514 |
and string_of_tptp_type (Prod_type (tptp_type1, tptp_type2)) = |
|
515 |
string_of_tptp_type tptp_type1 ^ " * " ^ string_of_tptp_type tptp_type2 |
|
516 |
| string_of_tptp_type (Fn_type (tptp_type1, tptp_type2)) = |
|
517 |
string_of_tptp_type tptp_type1 ^ " > " ^ string_of_tptp_type tptp_type2 |
|
518 |
| string_of_tptp_type (Atom_type str) = str |
|
519 |
| string_of_tptp_type (Defined_type tptp_base_type) = |
|
520 |
string_of_tptp_base_type tptp_base_type |
|
521 |
| string_of_tptp_type (Sum_type (tptp_type1, tptp_type2)) = "" |
|
522 |
| string_of_tptp_type (Fmla_type tptp_formula) = string_of_tptp_formula tptp_formula |
|
523 |
| string_of_tptp_type (Subtype (symbol1, symbol2)) = |
|
524 |
string_of_symbol symbol1 ^ " << " ^ string_of_symbol symbol2 |
|
525 |
||
526 |
end |