sultana@47715
|
1 |
(* Title: HOL/TPTP/TPTP_Parser/tptp_syntax.ML
|
sultana@47715
|
2 |
Author: Nik Sultana, Cambridge University Computer Laboratory
|
sultana@47715
|
3 |
|
sultana@47715
|
4 |
TPTP abstract syntax and parser-related definitions.
|
sultana@47715
|
5 |
*)
|
sultana@47715
|
6 |
|
sultana@47715
|
7 |
signature TPTP_SYNTAX =
|
sultana@47715
|
8 |
sig
|
sultana@47715
|
9 |
exception TPTP_SYNTAX of string
|
sultana@47715
|
10 |
val debug: ('a -> unit) -> 'a -> unit
|
sultana@47715
|
11 |
|
sultana@47715
|
12 |
(*Note that in THF "^ [X] : ^ [Y] : f @ g" should parse
|
sultana@47715
|
13 |
as "(^ [X] : (^ [Y] : f)) @ g"
|
sultana@47715
|
14 |
*)
|
sultana@47715
|
15 |
|
sultana@47715
|
16 |
datatype number_kind = Int_num | Real_num | Rat_num
|
sultana@47715
|
17 |
|
sultana@47715
|
18 |
datatype status_value =
|
sultana@47715
|
19 |
Suc | Unp | Sap | Esa | Sat | Fsa
|
sultana@47715
|
20 |
| Thm | Eqv | Tac | Wec | Eth | Tau
|
sultana@47715
|
21 |
| Wtc | Wth | Cax | Sca | Tca | Wca
|
sultana@47715
|
22 |
| Cup | Csp | Ecs | Csa | Cth | Ceq
|
sultana@47715
|
23 |
| Unc | Wcc | Ect | Fun | Uns | Wuc
|
sultana@47715
|
24 |
| Wct | Scc | Uca | Noc
|
sultana@47715
|
25 |
|
sultana@47715
|
26 |
type name = string
|
sultana@47715
|
27 |
type atomic_word = string
|
sultana@47715
|
28 |
type inference_rule = atomic_word
|
sultana@47715
|
29 |
type file_info = name option
|
sultana@47715
|
30 |
type single_quoted = string
|
sultana@47715
|
31 |
type file_name = single_quoted
|
sultana@47715
|
32 |
type creator_name = atomic_word
|
sultana@47715
|
33 |
type variable = string
|
sultana@47715
|
34 |
type upper_word = string
|
sultana@47715
|
35 |
|
sultana@47715
|
36 |
datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic
|
sultana@47715
|
37 |
and role =
|
sultana@47715
|
38 |
Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption |
|
sultana@47715
|
39 |
Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture |
|
sultana@47715
|
40 |
Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates |
|
sultana@47715
|
41 |
Role_Type | Role_Unknown
|
sultana@47715
|
42 |
|
sultana@47715
|
43 |
and general_data = (*Bind of variable * formula_data*)
|
sultana@47715
|
44 |
Atomic_Word of string
|
sultana@47715
|
45 |
| Application of string * general_term list (*general_function*)
|
sultana@47715
|
46 |
| V of upper_word (*variable*)
|
sultana@47715
|
47 |
| Number of number_kind * string
|
sultana@47715
|
48 |
| Distinct_Object of string
|
sultana@47715
|
49 |
| (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *)
|
sultana@47715
|
50 |
| (*formula_data*) Term_Data of tptp_term
|
sultana@47715
|
51 |
|
sultana@47715
|
52 |
and interpreted_symbol =
|
sultana@47715
|
53 |
UMinus | Sum | Difference | Product | Quotient | Quotient_E |
|
sultana@47715
|
54 |
Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F |
|
sultana@47715
|
55 |
Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real |
|
sultana@48218
|
56 |
(*FIXME these should be in defined_pred, but that's not being used in TPTP*)
|
sultana@47715
|
57 |
Less | LessEq | Greater | GreaterEq | EvalEq | Is_Int | Is_Rat |
|
sultana@48218
|
58 |
Distinct | Apply
|
sultana@47715
|
59 |
|
sultana@47715
|
60 |
and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor |
|
sultana@47715
|
61 |
Nor | Nand | Not | Op_Forall | Op_Exists |
|
sultana@48218
|
62 |
(*FIXME these should be in defined_pred, but that's not being used in TPTP*)
|
sultana@47715
|
63 |
True | False
|
sultana@47715
|
64 |
|
sultana@47715
|
65 |
and quantifier = (*interpreted binders*)
|
sultana@47715
|
66 |
Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum
|
sultana@47715
|
67 |
|
sultana@47715
|
68 |
and tptp_base_type =
|
sultana@47715
|
69 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real
|
sultana@47715
|
70 |
|
sultana@47715
|
71 |
and symbol =
|
sultana@47715
|
72 |
Uninterpreted of string
|
sultana@47715
|
73 |
| Interpreted_ExtraLogic of interpreted_symbol
|
sultana@47715
|
74 |
| Interpreted_Logic of logic_symbol
|
sultana@47715
|
75 |
| TypeSymbol of tptp_base_type
|
sultana@47715
|
76 |
| System of string
|
sultana@47715
|
77 |
|
sultana@47715
|
78 |
and general_term =
|
sultana@47715
|
79 |
General_Data of general_data (*general_data*)
|
sultana@47715
|
80 |
| General_Term of general_data * general_term (*general_data : general_term*)
|
sultana@47715
|
81 |
| General_List of general_term list
|
sultana@47715
|
82 |
|
sultana@47715
|
83 |
and tptp_term =
|
sultana@47715
|
84 |
Term_Func of symbol * tptp_term list
|
sultana@47715
|
85 |
| Term_Var of string
|
sultana@47715
|
86 |
| Term_Conditional of tptp_formula * tptp_term * tptp_term
|
sultana@47715
|
87 |
| Term_Num of number_kind * string
|
sultana@47715
|
88 |
| Term_Distinct_Object of string
|
sultana@48215
|
89 |
| Term_Let of tptp_let list * tptp_term (*FIXME remove list?*)
|
sultana@47715
|
90 |
|
sultana@47715
|
91 |
and tptp_atom =
|
sultana@47715
|
92 |
TFF_Typed_Atom of symbol * tptp_type option (*only TFF*)
|
sultana@47715
|
93 |
| THF_Atom_term of tptp_term (*from here on, only THF*)
|
sultana@47715
|
94 |
| THF_Atom_conn_term of symbol
|
sultana@47715
|
95 |
|
sultana@47715
|
96 |
and tptp_formula =
|
sultana@47715
|
97 |
Pred of symbol * tptp_term list
|
sultana@47715
|
98 |
| Fmla of symbol * tptp_formula list
|
sultana@47715
|
99 |
| Sequent of tptp_formula list * tptp_formula list
|
sultana@47715
|
100 |
| Quant of quantifier * (string * tptp_type option) list * tptp_formula
|
sultana@47715
|
101 |
| Conditional of tptp_formula * tptp_formula * tptp_formula
|
sultana@48215
|
102 |
| Let of tptp_let list * tptp_formula (*FIXME remove list?*)
|
sultana@47715
|
103 |
| Atom of tptp_atom
|
sultana@48218
|
104 |
| Type_fmla of tptp_type
|
sultana@47715
|
105 |
| THF_typing of tptp_formula * tptp_type (*only THF*)
|
sultana@47715
|
106 |
|
sultana@47715
|
107 |
and tptp_let =
|
sultana@47715
|
108 |
Let_fmla of (string * tptp_type option) * tptp_formula
|
sultana@48215
|
109 |
| Let_term of (string * tptp_type option) * tptp_term (*only TFF*)
|
sultana@47715
|
110 |
|
sultana@47715
|
111 |
and tptp_type =
|
sultana@47715
|
112 |
Prod_type of tptp_type * tptp_type
|
sultana@47715
|
113 |
| Fn_type of tptp_type * tptp_type
|
sultana@47715
|
114 |
| Atom_type of string
|
sultana@47715
|
115 |
| Defined_type of tptp_base_type
|
sultana@47715
|
116 |
| Sum_type of tptp_type * tptp_type (*only THF*)
|
sultana@48215
|
117 |
| Fmla_type of tptp_formula
|
sultana@47715
|
118 |
| Subtype of symbol * symbol (*only THF*)
|
sultana@47715
|
119 |
|
sultana@47715
|
120 |
type general_list = general_term list
|
sultana@47715
|
121 |
type parent_details = general_list
|
sultana@47715
|
122 |
type useful_info = general_term list
|
sultana@47715
|
123 |
type info = useful_info
|
sultana@47715
|
124 |
|
sultana@47715
|
125 |
type annotation = general_term * general_term list
|
sultana@47715
|
126 |
|
sultana@47715
|
127 |
exception DEQUOTE of string
|
sultana@47715
|
128 |
|
sultana@47715
|
129 |
type position = string * int * int
|
sultana@47715
|
130 |
|
sultana@47715
|
131 |
datatype tptp_line =
|
sultana@48218
|
132 |
Annotated_Formula of position * language * string * role *
|
sultana@48218
|
133 |
tptp_formula * annotation option
|
sultana@47715
|
134 |
| Include of string * string list
|
sultana@47715
|
135 |
|
sultana@47715
|
136 |
type tptp_problem = tptp_line list
|
sultana@47715
|
137 |
|
sultana@47715
|
138 |
val dequote : single_quoted -> single_quoted
|
sultana@47715
|
139 |
|
sultana@47715
|
140 |
val role_to_string : role -> string
|
sultana@47715
|
141 |
|
sultana@47715
|
142 |
val status_to_string : status_value -> string
|
sultana@47715
|
143 |
|
sultana@47715
|
144 |
val nameof_tff_atom_type : tptp_type -> string
|
sultana@47715
|
145 |
|
sultana@47715
|
146 |
(*Returns the list of all files included in a directory and its
|
sultana@47715
|
147 |
subdirectories. This is only used for testing the parser/interpreter against
|
sultana@47715
|
148 |
all THF problems.*)
|
sultana@47715
|
149 |
val get_file_list : Path.T -> Path.T list
|
sultana@47715
|
150 |
|
sultana@47715
|
151 |
val string_of_tptp_term : tptp_term -> string
|
sultana@47715
|
152 |
val string_of_tptp_formula : tptp_formula -> string
|
sultana@47715
|
153 |
|
sultana@47715
|
154 |
end
|
sultana@47715
|
155 |
|
sultana@47715
|
156 |
|
sultana@47715
|
157 |
structure TPTP_Syntax : TPTP_SYNTAX =
|
sultana@47715
|
158 |
struct
|
sultana@47715
|
159 |
|
sultana@47715
|
160 |
exception TPTP_SYNTAX of string
|
sultana@47715
|
161 |
|
sultana@47715
|
162 |
datatype number_kind = Int_num | Real_num | Rat_num
|
sultana@47715
|
163 |
|
sultana@47715
|
164 |
datatype status_value =
|
sultana@47715
|
165 |
Suc | Unp | Sap | Esa | Sat | Fsa
|
sultana@47715
|
166 |
| Thm | Eqv | Tac | Wec | Eth | Tau
|
sultana@47715
|
167 |
| Wtc | Wth | Cax | Sca | Tca | Wca
|
sultana@47715
|
168 |
| Cup | Csp | Ecs | Csa | Cth | Ceq
|
sultana@47715
|
169 |
| Unc | Wcc | Ect | Fun | Uns | Wuc
|
sultana@47715
|
170 |
| Wct | Scc | Uca | Noc
|
sultana@47715
|
171 |
|
sultana@47715
|
172 |
type name = string
|
sultana@47715
|
173 |
type atomic_word = string
|
sultana@47715
|
174 |
type inference_rule = atomic_word
|
sultana@47715
|
175 |
type file_info = name option
|
sultana@47715
|
176 |
type single_quoted = string
|
sultana@47715
|
177 |
type file_name = single_quoted
|
sultana@47715
|
178 |
type creator_name = atomic_word
|
sultana@47715
|
179 |
type variable = string
|
sultana@47715
|
180 |
type upper_word = string
|
sultana@47715
|
181 |
|
sultana@47715
|
182 |
datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic
|
sultana@47715
|
183 |
and role =
|
sultana@47715
|
184 |
Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption |
|
sultana@47715
|
185 |
Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture |
|
sultana@47715
|
186 |
Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates |
|
sultana@47715
|
187 |
Role_Type | Role_Unknown
|
sultana@47715
|
188 |
and general_data = (*Bind of variable * formula_data*)
|
sultana@47715
|
189 |
Atomic_Word of string
|
sultana@47715
|
190 |
| Application of string * (general_term list)
|
sultana@47715
|
191 |
| V of upper_word (*variable*)
|
sultana@47715
|
192 |
| Number of number_kind * string
|
sultana@47715
|
193 |
| Distinct_Object of string
|
sultana@47715
|
194 |
| (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *)
|
sultana@47715
|
195 |
| (*formula_data*) Term_Data of tptp_term
|
sultana@47715
|
196 |
|
sultana@47715
|
197 |
and interpreted_symbol =
|
sultana@47715
|
198 |
UMinus | Sum | Difference | Product | Quotient | Quotient_E |
|
sultana@47715
|
199 |
Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F |
|
sultana@47715
|
200 |
Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real |
|
sultana@47715
|
201 |
Less | LessEq | Greater | GreaterEq | EvalEq | Is_Int | Is_Rat |
|
sultana@48215
|
202 |
Distinct |
|
sultana@48218
|
203 |
Apply
|
sultana@47715
|
204 |
|
sultana@47715
|
205 |
and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor |
|
sultana@47715
|
206 |
Nor | Nand | Not | Op_Forall | Op_Exists |
|
sultana@47715
|
207 |
True | False
|
sultana@47715
|
208 |
|
sultana@47715
|
209 |
and quantifier = (*interpreted binders*)
|
sultana@47715
|
210 |
Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum
|
sultana@47715
|
211 |
|
sultana@47715
|
212 |
and tptp_base_type =
|
sultana@47715
|
213 |
Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real
|
sultana@47715
|
214 |
|
sultana@47715
|
215 |
and symbol =
|
sultana@47715
|
216 |
Uninterpreted of string
|
sultana@47715
|
217 |
| Interpreted_ExtraLogic of interpreted_symbol
|
sultana@47715
|
218 |
| Interpreted_Logic of logic_symbol
|
sultana@47715
|
219 |
| TypeSymbol of tptp_base_type
|
sultana@47715
|
220 |
| System of string
|
sultana@47715
|
221 |
|
sultana@47715
|
222 |
and general_term =
|
sultana@47715
|
223 |
General_Data of general_data (*general_data*)
|
sultana@47715
|
224 |
| General_Term of general_data * general_term (*general_data : general_term*)
|
sultana@47715
|
225 |
| General_List of general_term list
|
sultana@47715
|
226 |
|
sultana@47715
|
227 |
and tptp_term =
|
sultana@47715
|
228 |
Term_Func of symbol * tptp_term list
|
sultana@47715
|
229 |
| Term_Var of string
|
sultana@47715
|
230 |
| Term_Conditional of tptp_formula * tptp_term * tptp_term
|
sultana@47715
|
231 |
| Term_Num of number_kind * string
|
sultana@47715
|
232 |
| Term_Distinct_Object of string
|
sultana@48215
|
233 |
| Term_Let of tptp_let list * tptp_term (*FIXME remove list?*)
|
sultana@47715
|
234 |
|
sultana@47715
|
235 |
and tptp_atom =
|
sultana@47715
|
236 |
TFF_Typed_Atom of symbol * tptp_type option (*only TFF*)
|
sultana@47715
|
237 |
| THF_Atom_term of tptp_term (*from here on, only THF*)
|
sultana@47715
|
238 |
| THF_Atom_conn_term of symbol
|
sultana@47715
|
239 |
|
sultana@47715
|
240 |
and tptp_formula =
|
sultana@47715
|
241 |
Pred of symbol * tptp_term list
|
sultana@47715
|
242 |
| Fmla of symbol * tptp_formula list
|
sultana@47715
|
243 |
| Sequent of tptp_formula list * tptp_formula list
|
sultana@47715
|
244 |
| Quant of quantifier * (string * tptp_type option) list * tptp_formula
|
sultana@47715
|
245 |
| Conditional of tptp_formula * tptp_formula * tptp_formula
|
sultana@47715
|
246 |
| Let of tptp_let list * tptp_formula
|
sultana@47715
|
247 |
| Atom of tptp_atom
|
sultana@48218
|
248 |
| Type_fmla of tptp_type
|
sultana@47715
|
249 |
| THF_typing of tptp_formula * tptp_type
|
sultana@47715
|
250 |
|
sultana@47715
|
251 |
and tptp_let =
|
sultana@48218
|
252 |
Let_fmla of (string * tptp_type option) * tptp_formula
|
sultana@48218
|
253 |
| Let_term of (string * tptp_type option) * tptp_term
|
sultana@47715
|
254 |
|
sultana@47715
|
255 |
and tptp_type =
|
sultana@47715
|
256 |
Prod_type of tptp_type * tptp_type
|
sultana@47715
|
257 |
| Fn_type of tptp_type * tptp_type
|
sultana@47715
|
258 |
| Atom_type of string
|
sultana@47715
|
259 |
| Defined_type of tptp_base_type
|
sultana@48218
|
260 |
| Sum_type of tptp_type * tptp_type
|
sultana@48218
|
261 |
| Fmla_type of tptp_formula
|
sultana@48218
|
262 |
| Subtype of symbol * symbol
|
sultana@47715
|
263 |
|
sultana@47715
|
264 |
type general_list = general_term list
|
sultana@47715
|
265 |
type parent_details = general_list
|
sultana@47715
|
266 |
type useful_info = general_term list
|
sultana@47715
|
267 |
type info = useful_info
|
sultana@47715
|
268 |
|
sultana@47715
|
269 |
(*type annotation = (source * info option)*)
|
sultana@47715
|
270 |
type annotation = general_term * general_term list
|
sultana@47715
|
271 |
|
sultana@47715
|
272 |
exception DEQUOTE of string
|
sultana@47715
|
273 |
|
sultana@47715
|
274 |
type position = string * int * int
|
sultana@47715
|
275 |
|
sultana@47715
|
276 |
datatype tptp_line =
|
sultana@47715
|
277 |
Annotated_Formula of position * language * string * role * tptp_formula * annotation option
|
sultana@47715
|
278 |
| Include of string * string list
|
sultana@47715
|
279 |
|
sultana@47715
|
280 |
type tptp_problem = tptp_line list
|
sultana@47715
|
281 |
|
sultana@47715
|
282 |
fun debug f x = if !Runtime.debug then (f x; ()) else ()
|
sultana@47715
|
283 |
|
sultana@47715
|
284 |
fun nameof_tff_atom_type (Atom_type str) = str
|
sultana@47715
|
285 |
| nameof_tff_atom_type _ = raise TPTP_SYNTAX "nameof_tff_atom_type called on non-atom type"
|
sultana@47715
|
286 |
|
sultana@47715
|
287 |
(*Used for debugging. Returns all files contained within a directory or its
|
sultana@47715
|
288 |
subdirectories. Follows symbolic links, filters away directories.*)
|
sultana@47715
|
289 |
fun get_file_list path =
|
sultana@47715
|
290 |
let
|
sultana@47715
|
291 |
fun check_file_entry f rest =
|
sultana@47715
|
292 |
let
|
sultana@47715
|
293 |
(*NOTE needed since no File.is_link and File.read_link*)
|
sultana@47715
|
294 |
val f_str = Path.implode f
|
sultana@47715
|
295 |
in
|
sultana@47715
|
296 |
if File.is_dir f then
|
sultana@47715
|
297 |
rest @ get_file_list f
|
sultana@47715
|
298 |
else if OS.FileSys.isLink f_str then
|
sultana@47715
|
299 |
(*follow links -- NOTE this breaks if links are relative paths*)
|
sultana@47715
|
300 |
check_file_entry (Path.explode (OS.FileSys.readLink f_str)) rest
|
sultana@47715
|
301 |
else f :: rest
|
sultana@47715
|
302 |
end
|
sultana@47715
|
303 |
in
|
sultana@47715
|
304 |
File.read_dir path
|
sultana@47715
|
305 |
|> map
|
sultana@47715
|
306 |
(Path.explode
|
sultana@47715
|
307 |
#> Path.append path)
|
sultana@47715
|
308 |
|> (fn l => fold check_file_entry l [])
|
sultana@47715
|
309 |
end
|
sultana@47715
|
310 |
|
sultana@47715
|
311 |
fun role_to_string role =
|
sultana@47715
|
312 |
case role of
|
sultana@47715
|
313 |
Role_Axiom => "axiom"
|
sultana@47715
|
314 |
| Role_Hypothesis => "hypothesis"
|
sultana@47715
|
315 |
| Role_Definition => "definition"
|
sultana@47715
|
316 |
| Role_Assumption => "assumption"
|
sultana@47715
|
317 |
| Role_Lemma => "lemma"
|
sultana@47715
|
318 |
| Role_Theorem => "theorem"
|
sultana@47715
|
319 |
| Role_Conjecture => "conjecture"
|
sultana@47715
|
320 |
| Role_Negated_Conjecture => "negated_conjecture"
|
sultana@47715
|
321 |
| Role_Plain => "plain"
|
sultana@47715
|
322 |
| Role_Fi_Domain => "fi_domain"
|
sultana@47715
|
323 |
| Role_Fi_Functors => "fi_functors"
|
sultana@47715
|
324 |
| Role_Fi_Predicates => "fi_predicates"
|
sultana@47715
|
325 |
| Role_Type => "type"
|
sultana@47715
|
326 |
| Role_Unknown => "unknown"
|
sultana@47715
|
327 |
|
sultana@47715
|
328 |
(*accepts a string "'abc'" and returns "abc"*)
|
sultana@47715
|
329 |
fun dequote str : single_quoted =
|
sultana@47715
|
330 |
if str = "" then
|
sultana@47715
|
331 |
raise (DEQUOTE "empty string")
|
sultana@47715
|
332 |
else
|
sultana@47715
|
333 |
(unprefix "'" str
|
sultana@47715
|
334 |
|> unsuffix "'"
|
sultana@47715
|
335 |
handle (Fail str) =>
|
sultana@47715
|
336 |
if str = "unprefix" then
|
sultana@47715
|
337 |
raise DEQUOTE ("string doesn't open with quote:" ^ str)
|
sultana@47715
|
338 |
else if str = "unsuffix" then
|
sultana@47715
|
339 |
raise DEQUOTE ("string doesn't close with quote:" ^ str)
|
sultana@47715
|
340 |
else raise Fail str)
|
sultana@47715
|
341 |
|
sultana@47715
|
342 |
|
sultana@47715
|
343 |
(* Printing parsed TPTP formulas *)
|
sultana@47715
|
344 |
(*FIXME this is not pretty-printing, just printing*)
|
sultana@47715
|
345 |
|
sultana@47715
|
346 |
fun status_to_string status_value =
|
sultana@47715
|
347 |
case status_value of
|
sultana@47715
|
348 |
Suc => "suc" | Unp => "unp"
|
sultana@47715
|
349 |
| Sap => "sap" | Esa => "esa"
|
sultana@47715
|
350 |
| Sat => "sat" | Fsa => "fsa"
|
sultana@47715
|
351 |
| Thm => "thm" | Wuc => "wuc"
|
sultana@47715
|
352 |
| Eqv => "eqv" | Tac => "tac"
|
sultana@47715
|
353 |
| Wec => "wec" | Eth => "eth"
|
sultana@47715
|
354 |
| Tau => "tau" | Wtc => "wtc"
|
sultana@47715
|
355 |
| Wth => "wth" | Cax => "cax"
|
sultana@47715
|
356 |
| Sca => "sca" | Tca => "tca"
|
sultana@47715
|
357 |
| Wca => "wca" | Cup => "cup"
|
sultana@47715
|
358 |
| Csp => "csp" | Ecs => "ecs"
|
sultana@47715
|
359 |
| Csa => "csa" | Cth => "cth"
|
sultana@47715
|
360 |
| Ceq => "ceq" | Unc => "unc"
|
sultana@47715
|
361 |
| Wcc => "wcc" | Ect => "ect"
|
sultana@47715
|
362 |
| Fun => "fun" | Uns => "uns"
|
sultana@47715
|
363 |
| Wct => "wct" | Scc => "scc"
|
sultana@47715
|
364 |
| Uca => "uca" | Noc => "noc"
|
sultana@47715
|
365 |
|
sultana@47715
|
366 |
fun string_of_tptp_term x =
|
sultana@47715
|
367 |
case x of
|
sultana@47715
|
368 |
Term_Func (symbol, tptp_term_list) =>
|
sultana@47715
|
369 |
"(" ^ string_of_symbol symbol ^ " " ^
|
wenzelm@48297
|
370 |
space_implode " " (map string_of_tptp_term tptp_term_list) ^ ")"
|
sultana@47715
|
371 |
| Term_Var str => str
|
sultana@47715
|
372 |
| Term_Conditional (tptp_formula, tptp_term1, tptp_term2) => "" (*FIXME*)
|
sultana@47715
|
373 |
| Term_Num (_, str) => str
|
sultana@47715
|
374 |
| Term_Distinct_Object str => str
|
sultana@47715
|
375 |
|
sultana@47715
|
376 |
and string_of_symbol (Uninterpreted str) = str
|
sultana@47715
|
377 |
| string_of_symbol (Interpreted_ExtraLogic interpreted_symbol) = string_of_interpreted_symbol interpreted_symbol
|
sultana@47715
|
378 |
| string_of_symbol (Interpreted_Logic logic_symbol) = string_of_logic_symbol logic_symbol
|
sultana@47715
|
379 |
| string_of_symbol (TypeSymbol tptp_base_type) = string_of_tptp_base_type tptp_base_type
|
sultana@47715
|
380 |
| string_of_symbol (System str) = str
|
sultana@47715
|
381 |
|
sultana@47715
|
382 |
and string_of_tptp_base_type Type_Ind = "$i"
|
sultana@47715
|
383 |
| string_of_tptp_base_type Type_Bool = "$o"
|
sultana@47715
|
384 |
| string_of_tptp_base_type Type_Type = "$tType"
|
sultana@47715
|
385 |
| string_of_tptp_base_type Type_Int = "$int"
|
sultana@47715
|
386 |
| string_of_tptp_base_type Type_Rat = "$rat"
|
sultana@47715
|
387 |
| string_of_tptp_base_type Type_Real = "$real"
|
sultana@47715
|
388 |
|
sultana@47715
|
389 |
and string_of_interpreted_symbol x =
|
sultana@47715
|
390 |
case x of
|
sultana@47715
|
391 |
UMinus => "$uminus"
|
sultana@47715
|
392 |
| Sum => "$sum"
|
sultana@47715
|
393 |
| Difference => "$difference"
|
sultana@47715
|
394 |
| Product => "$product"
|
sultana@47715
|
395 |
| Quotient => "$quotient"
|
sultana@47715
|
396 |
| Quotient_E => "$quotient_e"
|
sultana@47715
|
397 |
| Quotient_T => "$quotient_t"
|
sultana@47715
|
398 |
| Quotient_F => "$quotient_f"
|
sultana@47715
|
399 |
| Remainder_E => "$remainder_e"
|
sultana@47715
|
400 |
| Remainder_T => "$remainder_t"
|
sultana@47715
|
401 |
| Remainder_F => "$remainder_f"
|
sultana@47715
|
402 |
| Floor => "$floor"
|
sultana@47715
|
403 |
| Ceiling => "$ceiling"
|
sultana@47715
|
404 |
| Truncate => "$truncate"
|
sultana@47715
|
405 |
| Round => "$round"
|
sultana@47715
|
406 |
| To_Int => "$to_int"
|
sultana@47715
|
407 |
| To_Rat => "$to_rat"
|
sultana@47715
|
408 |
| To_Real => "$to_real"
|
sultana@47715
|
409 |
| Less => "$less"
|
sultana@47715
|
410 |
| LessEq => "$lesseq"
|
sultana@47715
|
411 |
| Greater => "$greater"
|
sultana@47715
|
412 |
| GreaterEq => "$greatereq"
|
sultana@47715
|
413 |
| EvalEq => "$evaleq"
|
sultana@47715
|
414 |
| Is_Int => "$is_int"
|
sultana@47715
|
415 |
| Is_Rat => "$is_rat"
|
sultana@47715
|
416 |
| Apply => "@"
|
sultana@47715
|
417 |
|
sultana@47715
|
418 |
and string_of_logic_symbol Equals = "="
|
sultana@47715
|
419 |
| string_of_logic_symbol NEquals = "!="
|
sultana@47715
|
420 |
| string_of_logic_symbol Or = "|"
|
sultana@47715
|
421 |
| string_of_logic_symbol And = "&"
|
sultana@47715
|
422 |
| string_of_logic_symbol Iff = "<=>"
|
sultana@47715
|
423 |
| string_of_logic_symbol If = "=>"
|
sultana@47715
|
424 |
| string_of_logic_symbol Fi = "<="
|
sultana@47715
|
425 |
| string_of_logic_symbol Xor = "<~>"
|
sultana@47715
|
426 |
| string_of_logic_symbol Nor = "~|"
|
sultana@47715
|
427 |
| string_of_logic_symbol Nand = "~&"
|
sultana@47715
|
428 |
| string_of_logic_symbol Not = "~"
|
sultana@47715
|
429 |
| string_of_logic_symbol Op_Forall = "!!"
|
sultana@47715
|
430 |
| string_of_logic_symbol Op_Exists = "??"
|
sultana@47715
|
431 |
| string_of_logic_symbol True = "$true"
|
sultana@47715
|
432 |
| string_of_logic_symbol False = "$false"
|
sultana@47715
|
433 |
|
sultana@47715
|
434 |
and string_of_quantifier Forall = "!"
|
sultana@47715
|
435 |
| string_of_quantifier Exists = "?"
|
sultana@47715
|
436 |
| string_of_quantifier Epsilon = "@+"
|
sultana@47715
|
437 |
| string_of_quantifier Iota = "@-"
|
sultana@47715
|
438 |
| string_of_quantifier Lambda = "^"
|
sultana@47715
|
439 |
| string_of_quantifier Dep_Prod = "!>"
|
sultana@47715
|
440 |
| string_of_quantifier Dep_Sum = "?*"
|
sultana@47715
|
441 |
|
sultana@47715
|
442 |
and string_of_tptp_atom (TFF_Typed_Atom (symbol, tptp_type_option)) =
|
sultana@47715
|
443 |
(case tptp_type_option of
|
sultana@47715
|
444 |
NONE => string_of_symbol symbol
|
sultana@47715
|
445 |
| SOME tptp_type =>
|
sultana@47715
|
446 |
string_of_symbol symbol ^ " : " ^ string_of_tptp_type tptp_type)
|
sultana@47715
|
447 |
| string_of_tptp_atom (THF_Atom_term tptp_term) = string_of_tptp_term tptp_term
|
sultana@47715
|
448 |
| string_of_tptp_atom (THF_Atom_conn_term symbol) = string_of_symbol symbol
|
sultana@47715
|
449 |
|
sultana@47715
|
450 |
and string_of_tptp_formula (Pred (symbol, tptp_term_list)) =
|
sultana@47715
|
451 |
"(" ^ string_of_symbol symbol ^
|
wenzelm@48297
|
452 |
space_implode " " (map string_of_tptp_term tptp_term_list) ^ ")"
|
sultana@47715
|
453 |
| string_of_tptp_formula (Fmla (symbol, tptp_formula_list)) =
|
sultana@47715
|
454 |
"(" ^
|
sultana@47715
|
455 |
string_of_symbol symbol ^
|
wenzelm@48297
|
456 |
space_implode " " (map string_of_tptp_formula tptp_formula_list) ^ ")"
|
sultana@47715
|
457 |
| string_of_tptp_formula (Sequent (tptp_formula_list1, tptp_formula_list2)) = "" (*FIXME*)
|
sultana@47715
|
458 |
| string_of_tptp_formula (Quant (quantifier, varlist, tptp_formula)) =
|
sultana@47715
|
459 |
string_of_quantifier quantifier ^ "[" ^
|
wenzelm@48297
|
460 |
space_implode ", " (map (fn (n, ty) =>
|
sultana@47715
|
461 |
case ty of
|
sultana@47715
|
462 |
NONE => n
|
sultana@47715
|
463 |
| SOME ty => n ^ " : " ^ string_of_tptp_type ty) varlist) ^ "] : (" ^
|
sultana@47715
|
464 |
string_of_tptp_formula tptp_formula ^ ")"
|
sultana@47715
|
465 |
| string_of_tptp_formula (Conditional _) = "" (*FIXME*)
|
sultana@47715
|
466 |
| string_of_tptp_formula (Let _) = "" (*FIXME*)
|
sultana@47715
|
467 |
| string_of_tptp_formula (Atom tptp_atom) = string_of_tptp_atom tptp_atom
|
sultana@48218
|
468 |
| string_of_tptp_formula (Type_fmla tptp_type) = string_of_tptp_type tptp_type
|
sultana@47715
|
469 |
| string_of_tptp_formula (THF_typing (tptp_formula, tptp_type)) =
|
sultana@47715
|
470 |
string_of_tptp_formula tptp_formula ^ " : " ^ string_of_tptp_type tptp_type
|
sultana@47715
|
471 |
|
sultana@47715
|
472 |
and string_of_tptp_type (Prod_type (tptp_type1, tptp_type2)) =
|
sultana@47715
|
473 |
string_of_tptp_type tptp_type1 ^ " * " ^ string_of_tptp_type tptp_type2
|
sultana@47715
|
474 |
| string_of_tptp_type (Fn_type (tptp_type1, tptp_type2)) =
|
sultana@47715
|
475 |
string_of_tptp_type tptp_type1 ^ " > " ^ string_of_tptp_type tptp_type2
|
sultana@47715
|
476 |
| string_of_tptp_type (Atom_type str) = str
|
sultana@47715
|
477 |
| string_of_tptp_type (Defined_type tptp_base_type) =
|
sultana@47715
|
478 |
string_of_tptp_base_type tptp_base_type
|
sultana@47715
|
479 |
| string_of_tptp_type (Sum_type (tptp_type1, tptp_type2)) = ""
|
sultana@47715
|
480 |
| string_of_tptp_type (Fmla_type tptp_formula) = string_of_tptp_formula tptp_formula
|
sultana@47715
|
481 |
| string_of_tptp_type (Subtype (symbol1, symbol2)) =
|
sultana@47715
|
482 |
string_of_symbol symbol1 ^ " << " ^ string_of_symbol symbol2
|
sultana@47715
|
483 |
|
sultana@47715
|
484 |
end
|