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