| author | wenzelm | 
| Mon, 12 Oct 2015 20:58:58 +0200 | |
| changeset 61416 | b9a3324e4e62 | 
| parent 57808 | cf72aed038c8 | 
| child 64560 | c48becd96398 | 
| 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 = | |
| 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 | |
| 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: 
46844diff
changeset | 118 | | Fmla_type of tptp_formula | 
| 46844 | 119 | | Subtype of symbol * symbol (*only THF*) | 
| 120 | ||
| 121 | type general_list = general_term list | |
| 122 | type parent_details = general_list | |
| 123 | type useful_info = general_term list | |
| 124 | type info = useful_info | |
| 125 | ||
| 126 | type annotation = general_term * general_term list | |
| 127 | ||
| 128 | exception DEQUOTE of string | |
| 129 | ||
| 130 | type position = string * int * int | |
| 131 | ||
| 132 | datatype tptp_line = | |
| 47360 | 133 | Annotated_Formula of position * language * string * role * | 
| 134 | tptp_formula * annotation option | |
| 47569 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
changeset | 135 | | Include of position * string * string list | 
| 46844 | 136 | |
| 137 | type tptp_problem = tptp_line list | |
| 138 | ||
| 139 | val dequote : single_quoted -> single_quoted | |
| 140 | ||
| 141 | val role_to_string : role -> string | |
| 142 | ||
| 143 | val status_to_string : status_value -> string | |
| 144 | ||
| 47569 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
changeset | 145 | 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: 
47454diff
changeset | 146 | |
| 46844 | 147 | (*Returns the list of all files included in a directory and its | 
| 148 | subdirectories. This is only used for testing the parser/interpreter against | |
| 149 | all THF problems.*) | |
| 150 | val get_file_list : Path.T -> Path.T list | |
| 151 | ||
| 53385 | 152 | val read_status : string -> status_value | 
| 46844 | 153 | val string_of_tptp_term : tptp_term -> string | 
| 47692 
3d76c81b5ed2
improved non-interpretation of constants and numbers;
 sultana parents: 
47569diff
changeset | 154 | val string_of_interpreted_symbol : interpreted_symbol -> string | 
| 46844 | 155 | val string_of_tptp_formula : tptp_formula -> string | 
| 156 | ||
| 55587 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 157 | 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: 
53394diff
changeset | 158 | |
| 46844 | 159 | end | 
| 160 | ||
| 161 | ||
| 162 | structure TPTP_Syntax : TPTP_SYNTAX = | |
| 163 | struct | |
| 164 | ||
| 165 | exception TPTP_SYNTAX of string | |
| 166 | ||
| 167 | datatype number_kind = Int_num | Real_num | Rat_num | |
| 168 | ||
| 169 | datatype status_value = | |
| 170 | Suc | Unp | Sap | Esa | Sat | Fsa | |
| 171 | | Thm | Eqv | Tac | Wec | Eth | Tau | |
| 172 | | Wtc | Wth | Cax | Sca | Tca | Wca | |
| 173 | | Cup | Csp | Ecs | Csa | Cth | Ceq | |
| 174 | | Unc | Wcc | Ect | Fun | Uns | Wuc | |
| 175 | | Wct | Scc | Uca | Noc | |
| 176 | ||
| 177 | type name = string | |
| 178 | type atomic_word = string | |
| 179 | type inference_rule = atomic_word | |
| 180 | type file_info = name option | |
| 181 | type single_quoted = string | |
| 182 | type file_name = single_quoted | |
| 183 | type creator_name = atomic_word | |
| 184 | type variable = string | |
| 185 | type upper_word = string | |
| 186 | ||
| 187 | datatype language = FOF | CNF | TFF | THF | FOT | TFF_with_arithmetic | |
| 188 | and role = | |
| 189 | Role_Axiom | Role_Hypothesis | Role_Definition | Role_Assumption | | |
| 190 | Role_Lemma | Role_Theorem | Role_Conjecture | Role_Negated_Conjecture | | |
| 191 | Role_Plain | Role_Fi_Domain | Role_Fi_Functors | Role_Fi_Predicates | | |
| 192 | Role_Type | Role_Unknown | |
| 193 | and general_data = (*Bind of variable * formula_data*) | |
| 194 | Atomic_Word of string | |
| 195 | | Application of string * (general_term list) | |
| 196 | | V of upper_word (*variable*) | |
| 197 | | Number of number_kind * string | |
| 198 | | Distinct_Object of string | |
| 199 | | (*formula_data*) Formula_Data of language * tptp_formula (* $thf(<thf_formula>) *) | |
| 200 | | (*formula_data*) Term_Data of tptp_term | |
| 201 | ||
| 202 | and interpreted_symbol = | |
| 203 | UMinus | Sum | Difference | Product | Quotient | Quotient_E | | |
| 204 | Quotient_T | Quotient_F | Remainder_E | Remainder_T | Remainder_F | | |
| 205 | Floor | Ceiling | Truncate | Round | To_Int | To_Rat | To_Real | | |
| 206 | Less | LessEq | Greater | GreaterEq | EvalEq | Is_Int | Is_Rat | | |
| 47357 
15e579392a68
refactored tptp yacc to bring close to official spec;
 sultana parents: 
46844diff
changeset | 207 | Distinct | | 
| 47360 | 208 | Apply | 
| 46844 | 209 | |
| 210 | and logic_symbol = Equals | NEquals | Or | And | Iff | If | Fi | Xor | | |
| 211 | Nor | Nand | Not | Op_Forall | Op_Exists | | |
| 212 | True | False | |
| 213 | ||
| 214 | and quantifier = (*interpreted binders*) | |
| 215 | Forall | Exists | Epsilon | Iota | Lambda | Dep_Prod | Dep_Sum | |
| 216 | ||
| 217 | and tptp_base_type = | |
| 57808 | 218 | Type_Ind | Type_Bool | Type_Type | Type_Int | Type_Rat | Type_Real | Type_Dummy | 
| 46844 | 219 | |
| 220 | and symbol = | |
| 221 | Uninterpreted of string | |
| 222 | | Interpreted_ExtraLogic of interpreted_symbol | |
| 223 | | Interpreted_Logic of logic_symbol | |
| 224 | | TypeSymbol of tptp_base_type | |
| 225 | | System of string | |
| 226 | ||
| 227 | and general_term = | |
| 228 | General_Data of general_data (*general_data*) | |
| 229 | | General_Term of general_data * general_term (*general_data : general_term*) | |
| 230 | | General_List of general_term list | |
| 231 | ||
| 232 | and tptp_term = | |
| 233 | Term_Func of symbol * tptp_term list | |
| 234 | | Term_Var of string | |
| 235 | | Term_Conditional of tptp_formula * tptp_term * tptp_term | |
| 236 | | Term_Num of number_kind * string | |
| 237 | | Term_Distinct_Object of string | |
| 53394 | 238 | | Term_Let of tptp_let * tptp_term | 
| 46844 | 239 | |
| 240 | and tptp_atom = | |
| 241 | TFF_Typed_Atom of symbol * tptp_type option (*only TFF*) | |
| 242 | | THF_Atom_term of tptp_term (*from here on, only THF*) | |
| 243 | | THF_Atom_conn_term of symbol | |
| 244 | ||
| 245 | and tptp_formula = | |
| 246 | Pred of symbol * tptp_term list | |
| 247 | | Fmla of symbol * tptp_formula list | |
| 248 | | Sequent of tptp_formula list * tptp_formula list | |
| 249 | | Quant of quantifier * (string * tptp_type option) list * tptp_formula | |
| 250 | | Conditional of tptp_formula * tptp_formula * tptp_formula | |
| 53394 | 251 | | Let of tptp_let * tptp_formula | 
| 46844 | 252 | | Atom of tptp_atom | 
| 47360 | 253 | | Type_fmla of tptp_type | 
| 46844 | 254 | | THF_typing of tptp_formula * tptp_type | 
| 255 | ||
| 256 | and tptp_let = | |
| 53394 | 257 | Let_fmla of (string * tptp_type option) list * tptp_formula | 
| 258 | | Let_term of (string * tptp_type option) list * tptp_term | |
| 46844 | 259 | |
| 260 | and tptp_type = | |
| 261 | Prod_type of tptp_type * tptp_type | |
| 262 | | Fn_type of tptp_type * tptp_type | |
| 57808 | 263 | | Atom_type of string * tptp_type list | 
| 264 | | Var_type of string | |
| 46844 | 265 | | Defined_type of tptp_base_type | 
| 47360 | 266 | | Sum_type of tptp_type * tptp_type | 
| 267 | | Fmla_type of tptp_formula | |
| 268 | | Subtype of symbol * symbol | |
| 46844 | 269 | |
| 270 | type general_list = general_term list | |
| 271 | type parent_details = general_list | |
| 272 | type useful_info = general_term list | |
| 273 | type info = useful_info | |
| 274 | ||
| 275 | (*type annotation = (source * info option)*) | |
| 276 | type annotation = general_term * general_term list | |
| 277 | ||
| 278 | exception DEQUOTE of string | |
| 279 | ||
| 280 | type position = string * int * int | |
| 281 | ||
| 282 | datatype tptp_line = | |
| 283 | 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: 
47454diff
changeset | 284 | | Include of position * string * string list | 
| 46844 | 285 | |
| 286 | type tptp_problem = tptp_line list | |
| 287 | ||
| 56467 | 288 | fun debug f x = if Options.default_bool @{system_option ML_exception_trace} then (f x; ()) else ()
 | 
| 46844 | 289 | |
| 47569 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
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: 
47454diff
changeset | 291 | case tptp_line of | 
| 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
changeset | 292 | Annotated_Formula (position, _, _, _, _, _) => position | 
| 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
changeset | 293 | | Include (position, _, _) => position | 
| 
fce9d97a3258
exceptions related to interpreting tptp problems now mention the relevant position in the tptp file;
 sultana parents: 
47454diff
changeset | 294 | |
| 46844 | 295 | (*Used for debugging. Returns all files contained within a directory or its | 
| 53390 | 296 | subdirectories. Follows symbolic links, filters away directories. | 
| 297 | Files are ordered by size*) | |
| 46844 | 298 | fun get_file_list path = | 
| 299 | let | |
| 53390 | 300 | fun get_file_list' acc paths = | 
| 301 | case paths of | |
| 302 | [] => acc | |
| 303 | | (f :: fs) => | |
| 304 | let | |
| 305 | (*NOTE needed since no File.is_link and File.read_link*) | |
| 306 | val f_str = Path.implode f | |
| 307 | in | |
| 308 | if File.is_dir f then | |
| 309 | let | |
| 310 | val contents = | |
| 311 | File.read_dir f | |
| 312 | |> map | |
| 313 | (Path.explode | |
| 314 | #> Path.append f) | |
| 315 | in | |
| 316 | get_file_list' acc (fs @ contents) | |
| 317 | end | |
| 318 | else if OS.FileSys.isLink f_str then | |
| 319 | (*follow links -- NOTE this breaks if links are relative paths*) | |
| 320 | get_file_list' acc (Path.explode (OS.FileSys.readLink f_str) :: fs) | |
| 321 | else | |
| 322 | get_file_list' ((f, OS.FileSys.fileSize f_str) :: acc) fs | |
| 323 | end | |
| 46844 | 324 | in | 
| 53390 | 325 | get_file_list' [] [path] | 
| 326 | |> sort (fn ((_, n1), (_, n2)) => Int.compare (n1, n2)) | |
| 327 | |> map fst | |
| 46844 | 328 | end | 
| 329 | ||
| 330 | fun role_to_string role = | |
| 331 | case role of | |
| 332 | Role_Axiom => "axiom" | |
| 333 | | Role_Hypothesis => "hypothesis" | |
| 334 | | Role_Definition => "definition" | |
| 335 | | Role_Assumption => "assumption" | |
| 336 | | Role_Lemma => "lemma" | |
| 337 | | Role_Theorem => "theorem" | |
| 338 | | Role_Conjecture => "conjecture" | |
| 339 | | Role_Negated_Conjecture => "negated_conjecture" | |
| 340 | | Role_Plain => "plain" | |
| 341 | | Role_Fi_Domain => "fi_domain" | |
| 342 | | Role_Fi_Functors => "fi_functors" | |
| 343 | | Role_Fi_Predicates => "fi_predicates" | |
| 344 | | Role_Type => "type" | |
| 345 | | Role_Unknown => "unknown" | |
| 346 | ||
| 347 | (*accepts a string "'abc'" and returns "abc"*) | |
| 348 | fun dequote str : single_quoted = | |
| 349 | if str = "" then | |
| 350 | raise (DEQUOTE "empty string") | |
| 351 | else | |
| 352 | (unprefix "'" str | |
| 353 | |> unsuffix "'" | |
| 354 | handle (Fail str) => | |
| 355 | if str = "unprefix" then | |
| 356 |         raise DEQUOTE ("string doesn't open with quote:" ^ str)
 | |
| 357 | else if str = "unsuffix" then | |
| 358 |         raise DEQUOTE ("string doesn't close with quote:" ^ str)
 | |
| 359 | else raise Fail str) | |
| 360 | ||
| 53385 | 361 | exception UNRECOGNISED_STATUS of string | 
| 362 | fun read_status status = | |
| 363 | case status of | |
| 364 | "suc" => Suc | "unp" => Unp | |
| 365 | | "sap" => Sap | "esa" => Esa | |
| 366 | | "sat" => Sat | "fsa" => Fsa | |
| 367 | | "thm" => Thm | "wuc" => Wuc | |
| 368 | | "eqv" => Eqv | "tac" => Tac | |
| 369 | | "wec" => Wec | "eth" => Eth | |
| 370 | | "tau" => Tau | "wtc" => Wtc | |
| 371 | | "wth" => Wth | "cax" => Cax | |
| 372 | | "sca" => Sca | "tca" => Tca | |
| 373 | | "wca" => Wca | "cup" => Cup | |
| 374 | | "csp" => Csp | "ecs" => Ecs | |
| 375 | | "csa" => Csa | "cth" => Cth | |
| 376 | | "ceq" => Ceq | "unc" => Unc | |
| 377 | | "wcc" => Wcc | "ect" => Ect | |
| 378 | | "fun" => Fun | "uns" => Uns | |
| 379 | | "wct" => Wct | "scc" => Scc | |
| 380 | | "uca" => Uca | "noc" => Noc | |
| 381 | | thing => raise (UNRECOGNISED_STATUS thing) | |
| 46844 | 382 | |
| 383 | (* Printing parsed TPTP formulas *) | |
| 384 | (*FIXME this is not pretty-printing, just printing*) | |
| 385 | ||
| 386 | fun status_to_string status_value = | |
| 387 | case status_value of | |
| 47454 | 388 | Suc => "suc" | Unp => "unp" | 
| 46844 | 389 | | Sap => "sap" | Esa => "esa" | 
| 390 | | Sat => "sat" | Fsa => "fsa" | |
| 391 | | Thm => "thm" | Wuc => "wuc" | |
| 47454 | 392 | | Eqv => "eqv" | Tac => "tac" | 
| 393 | | Wec => "wec" | Eth => "eth" | |
| 394 | | Tau => "tau" | Wtc => "wtc" | |
| 395 | | Wth => "wth" | Cax => "cax" | |
| 396 | | Sca => "sca" | Tca => "tca" | |
| 397 | | Wca => "wca" | Cup => "cup" | |
| 398 | | Csp => "csp" | Ecs => "ecs" | |
| 399 | | Csa => "csa" | Cth => "cth" | |
| 400 | | Ceq => "ceq" | Unc => "unc" | |
| 401 | | Wcc => "wcc" | Ect => "ect" | |
| 402 | | Fun => "fun" | Uns => "uns" | |
| 403 | | Wct => "wct" | Scc => "scc" | |
| 404 | | Uca => "uca" | Noc => "noc" | |
| 46844 | 405 | |
| 406 | fun string_of_tptp_term x = | |
| 407 | case x of | |
| 408 | Term_Func (symbol, tptp_term_list) => | |
| 409 |         "(" ^ string_of_symbol symbol ^ " " ^
 | |
| 47426 | 410 | space_implode " " (map string_of_tptp_term tptp_term_list) ^ ")" | 
| 46844 | 411 | | Term_Var str => str | 
| 412 | | Term_Conditional (tptp_formula, tptp_term1, tptp_term2) => "" (*FIXME*) | |
| 413 | | Term_Num (_, str) => str | |
| 414 | | Term_Distinct_Object str => str | |
| 415 | ||
| 416 | and string_of_symbol (Uninterpreted str) = str | |
| 417 | | string_of_symbol (Interpreted_ExtraLogic interpreted_symbol) = string_of_interpreted_symbol interpreted_symbol | |
| 418 | | string_of_symbol (Interpreted_Logic logic_symbol) = string_of_logic_symbol logic_symbol | |
| 419 | | string_of_symbol (TypeSymbol tptp_base_type) = string_of_tptp_base_type tptp_base_type | |
| 420 | | string_of_symbol (System str) = str | |
| 421 | ||
| 422 | and string_of_tptp_base_type Type_Ind = "$i" | |
| 423 | | string_of_tptp_base_type Type_Bool = "$o" | |
| 424 | | string_of_tptp_base_type Type_Type = "$tType" | |
| 425 | | string_of_tptp_base_type Type_Int = "$int" | |
| 426 | | string_of_tptp_base_type Type_Rat = "$rat" | |
| 427 | | string_of_tptp_base_type Type_Real = "$real" | |
| 57808 | 428 | | string_of_tptp_base_type Type_Dummy = "$_" | 
| 46844 | 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: 
47569diff
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 | |
| 57808 | 518 | | string_of_tptp_type (Atom_type (str, [])) = str | 
| 519 | | string_of_tptp_type (Atom_type (str, tptp_types)) = | |
| 520 |       str ^ "(" ^ commas (map string_of_tptp_type tptp_types) ^ ")"
 | |
| 521 | | string_of_tptp_type (Var_type str) = str | |
| 46844 | 522 | | string_of_tptp_type (Defined_type tptp_base_type) = | 
| 523 | string_of_tptp_base_type tptp_base_type | |
| 524 | | string_of_tptp_type (Sum_type (tptp_type1, tptp_type2)) = "" | |
| 525 | | string_of_tptp_type (Fmla_type tptp_formula) = string_of_tptp_formula tptp_formula | |
| 526 | | string_of_tptp_type (Subtype (symbol1, symbol2)) = | |
| 527 | string_of_symbol symbol1 ^ " << " ^ string_of_symbol symbol2 | |
| 528 | ||
| 55594 | 529 | (*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: 
55587diff
changeset | 530 | (*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: 
53394diff
changeset | 531 | (*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: 
53394diff
changeset | 532 | 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: 
53394diff
changeset | 533 | case x of | 
| 55594 | 534 | Term_Func (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: 
53394diff
changeset | 535 |         "(" ^ latex_of_tptp_term tptp_t1 ^ " = " ^ 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: 
53394diff
changeset | 536 | | Term_Func (Interpreted_Logic NEquals, [tptp_t1, tptp_t2]) => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 537 |         "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\neq " ^ 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: 
53394diff
changeset | 538 | | Term_Func (Interpreted_Logic Or, [tptp_t1, tptp_t2]) => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 539 |         "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\vee " ^ 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: 
53394diff
changeset | 540 | | Term_Func (Interpreted_Logic And, [tptp_t1, tptp_t2]) => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 541 |         "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\wedge " ^ 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: 
53394diff
changeset | 542 | | Term_Func (Interpreted_Logic Iff, [tptp_t1, tptp_t2]) => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 543 |         "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longleftrightarrow " ^ 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: 
53394diff
changeset | 544 | | Term_Func (Interpreted_Logic If, [tptp_t1, tptp_t2]) => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 545 |         "(" ^ 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: 
53394diff
changeset | 546 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 547 | | Term_Func (symbol, tptp_term_list) => | 
| 55588 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 548 |         (*"(" ^*) latex_of_symbol symbol ^ "\\\\, " ^
 | 
| 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 549 | space_implode "\\\\, " (map latex_of_tptp_term tptp_term_list) (*^ ")"*) | 
| 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 550 |     | 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: 
53394diff
changeset | 551 | | 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: 
53394diff
changeset | 552 | | Term_Num (_, str) => str | 
| 55588 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 553 | | Term_Distinct_Object str => str (*FIXME*) | 
| 55594 | 554 | |
| 55587 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 555 | 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: 
53394diff
changeset | 556 | if str = "emptyset" then "\\\\emptyset" | 
| 55588 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 557 |     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: 
53394diff
changeset | 558 | | 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: 
53394diff
changeset | 559 | | 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: 
53394diff
changeset | 560 | | 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: 
55587diff
changeset | 561 |   | 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: 
53394diff
changeset | 562 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 563 | 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: 
53394diff
changeset | 564 | | 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: 
53394diff
changeset | 565 |   | 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: 
53394diff
changeset | 566 |   | 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: 
53394diff
changeset | 567 |   | 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: 
53394diff
changeset | 568 |   | latex_of_tptp_base_type Type_Real = "\\\\mathsf{real} "
 | 
| 57808 | 569 |   | 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: 
53394diff
changeset | 570 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 571 | 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: 
53394diff
changeset | 572 | case x of | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 573 | UMinus => "-" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 574 | | Sum => "-" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 575 | | Difference => "-" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 576 | | Product => "*" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 577 | | Quotient => "/" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 578 | | Quotient_E => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 579 | | Quotient_T => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 580 | | Quotient_F => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 581 | | Remainder_E => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 582 | | Remainder_T => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 583 | | Remainder_F => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 584 | | Floor => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 585 | | Ceiling => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 586 | | Truncate => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 587 | | Round => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 588 | | To_Int => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 589 | | To_Rat => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 590 | | To_Real => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 591 | | Less => "<" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 592 | | LessEq => "\\\\leq " | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 593 | | Greater => ">" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 594 | | GreaterEq => "\\\\geq " | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 595 | | EvalEq => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 596 | | Is_Int => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 597 | | Is_Rat => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 598 | | Distinct => "" (*FIXME*) | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 599 | | Apply => "\\\\;" | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 600 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 601 | 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: 
53394diff
changeset | 602 | | 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: 
53394diff
changeset | 603 | | 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: 
53394diff
changeset | 604 | | 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: 
53394diff
changeset | 605 | | 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: 
53394diff
changeset | 606 | | 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: 
53394diff
changeset | 607 | | 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: 
53394diff
changeset | 608 | | 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: 
53394diff
changeset | 609 | | 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: 
53394diff
changeset | 610 | | 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: 
53394diff
changeset | 611 | | 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: 
53394diff
changeset | 612 | | 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: 
53394diff
changeset | 613 | | 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: 
53394diff
changeset | 614 |   | 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: 
53394diff
changeset | 615 |   | 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: 
53394diff
changeset | 616 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 617 | 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: 
53394diff
changeset | 618 | | 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: 
53394diff
changeset | 619 | | 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: 
53394diff
changeset | 620 | | 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: 
53394diff
changeset | 621 | | 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: 
53394diff
changeset | 622 | | 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: 
53394diff
changeset | 623 | | 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: 
53394diff
changeset | 624 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 625 | 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: 
53394diff
changeset | 626 | (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: 
53394diff
changeset | 627 | 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: 
53394diff
changeset | 628 | | SOME tptp_type => | 
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 629 | latex_of_symbol symbol ^ " : " ^ latex_of_tptp_type tptp_type) | 
| 55594 | 630 | | 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: 
53394diff
changeset | 631 | | 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: 
53394diff
changeset | 632 | |
| 55594 | 633 | and latex_of_tptp_formula (Pred (Interpreted_Logic Equals, [tptp_t1, tptp_t2])) = | 
| 634 |       "(" ^ latex_of_tptp_term tptp_t1 ^ " = " ^ latex_of_tptp_term tptp_t2 ^ ")"
 | |
| 635 | | latex_of_tptp_formula (Pred (Interpreted_Logic NEquals, [tptp_t1, tptp_t2])) = | |
| 636 |       "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\neq " ^ latex_of_tptp_term tptp_t2 ^ ")"
 | |
| 637 | | latex_of_tptp_formula (Pred (Interpreted_Logic Or, [tptp_t1, tptp_t2])) = | |
| 638 |       "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\vee " ^ latex_of_tptp_term tptp_t2 ^ ")"
 | |
| 639 | | latex_of_tptp_formula (Pred (Interpreted_Logic And, [tptp_t1, tptp_t2])) = | |
| 640 |       "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\wedge " ^ latex_of_tptp_term tptp_t2 ^ ")"
 | |
| 641 | | latex_of_tptp_formula (Pred (Interpreted_Logic Iff, [tptp_t1, tptp_t2])) = | |
| 642 |       "(" ^ latex_of_tptp_term tptp_t1 ^ " \\\\longleftrightarrow " ^ latex_of_tptp_term tptp_t2 ^ ")"
 | |
| 643 | | latex_of_tptp_formula (Pred (Interpreted_Logic If, [tptp_t1, tptp_t2])) = | |
| 644 |       "(" ^ 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: 
53394diff
changeset | 645 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 646 | | latex_of_tptp_formula (x as (Pred (symbol, tptp_term_list))) = | 
| 55594 | 647 | latex_of_symbol symbol ^ | 
| 648 | 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: 
53394diff
changeset | 649 | |
| 55594 | 650 | | latex_of_tptp_formula (Fmla (Interpreted_ExtraLogic Apply, [Fmla (Interpreted_ExtraLogic Apply, [Atom (THF_Atom_term (Term_Func (Uninterpreted "union", []))), tptp_f1]), tptp_f2])) = | 
| 651 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\cup " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 652 | ||
| 653 | | latex_of_tptp_formula (Fmla (Interpreted_ExtraLogic Apply, [Fmla (Interpreted_ExtraLogic Apply, [Atom (THF_Atom_term (Term_Func (Uninterpreted "subset", []))), tptp_f1]), tptp_f2])) = | |
| 654 |       "(" ^ 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: 
53394diff
changeset | 655 | |
| 55594 | 656 | | latex_of_tptp_formula (Fmla (Interpreted_Logic Equals, [tptp_f1, tptp_f2])) = | 
| 657 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " = " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 658 | | latex_of_tptp_formula (Fmla (Interpreted_Logic NEquals, [tptp_f1, tptp_f2])) = | |
| 659 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\neq " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 660 | | latex_of_tptp_formula (Fmla (Interpreted_Logic Or, [tptp_f1, tptp_f2])) = | |
| 661 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\vee " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 662 | | latex_of_tptp_formula (Fmla (Interpreted_Logic And, [tptp_f1, tptp_f2])) = | |
| 663 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\wedge " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 664 | | latex_of_tptp_formula (Fmla (Interpreted_Logic Iff, [tptp_f1, tptp_f2])) = | |
| 665 |       "(" ^ latex_of_tptp_formula tptp_f1 ^ " \\\\longleftrightarrow " ^ latex_of_tptp_formula tptp_f2 ^ ")"
 | |
| 666 | | latex_of_tptp_formula (Fmla (Interpreted_Logic If, [tptp_f1, tptp_f2])) = | |
| 667 |       "(" ^ 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: 
53394diff
changeset | 668 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 669 | | latex_of_tptp_formula (x as (Fmla (symbol, tptp_formula_list))) = | 
| 55594 | 670 | latex_of_symbol symbol ^ | 
| 671 | 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: 
53394diff
changeset | 672 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 673 | | 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: 
53394diff
changeset | 674 | | 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: 
53394diff
changeset | 675 | 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: 
53394diff
changeset | 676 | 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: 
53394diff
changeset | 677 | case ty of | 
| 55588 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 678 |           NONE => "\\\\mathrm{" ^ n ^ "}"
 | 
| 
3740fb5ec307
improved latex output: spacing between terms, and encoding terms in mathrm;
 sultana parents: 
55587diff
changeset | 679 |         | 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: 
53394diff
changeset | 680 | 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: 
53394diff
changeset | 681 | | 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: 
53394diff
changeset | 682 | | 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: 
53394diff
changeset | 683 | | 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: 
53394diff
changeset | 684 | | 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: 
53394diff
changeset | 685 | | 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: 
53394diff
changeset | 686 | 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: 
53394diff
changeset | 687 | |
| 
5d3db2c626e3
experimenting with improving DOT output, and embedding LaTeX code for formulas (rather than only giving the clause number);
 sultana parents: 
53394diff
changeset | 688 | 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: 
53394diff
changeset | 689 | 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: 
53394diff
changeset | 690 | | 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: 
53394diff
changeset | 691 | latex_of_tptp_type tptp_type1 ^ " \\\\to " ^ latex_of_tptp_type tptp_type2 | 
| 57808 | 692 |   | latex_of_tptp_type (Atom_type (str, [])) = "\\\\mathrm{" ^ str ^ "}"
 | 
| 693 | | latex_of_tptp_type (Atom_type (str, tptp_types)) = | |
| 694 |     "\\\\mathrm{" ^ str ^ "}(" ^ commas (map latex_of_tptp_type tptp_types) ^ ")"
 | |
| 695 |   | 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: 
53394diff
changeset | 696 | | 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: 
53394diff
changeset | 697 | 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: 
53394diff
changeset | 698 | | 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: 
53394diff
changeset | 699 | | 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: 
53394diff
changeset | 700 | | 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: 
53394diff
changeset | 701 | |
| 46844 | 702 | end |