src/HOL/TPTP/TPTP_Parser/tptp.yacc
author sultana
Fri, 09 Mar 2012 15:38:55 +0000
changeset 47715 5d9aab0c609c
child 48215 15e579392a68
permissions -rw-r--r--
added tptp parser;
     1 open TPTP_Syntax
     2 
     3 exception UNRECOGNISED_SYMBOL of string * string
     4 
     5 exception UNRECOGNISED_ROLE of string
     6 fun classify_role role =
     7   case role of
     8     "axiom" => Role_Axiom
     9   | "hypothesis" => Role_Hypothesis
    10   | "definition" => Role_Definition
    11   | "assumption" => Role_Assumption
    12   | "lemma" => Role_Lemma
    13   | "theorem" => Role_Theorem
    14   | "conjecture" => Role_Conjecture
    15   | "negated_conjecture" => Role_Negated_Conjecture
    16   | "plain" => Role_Plain
    17   | "fi_domain" => Role_Fi_Domain
    18   | "fi_functors" => Role_Fi_Functors
    19   | "fi_predicates" => Role_Fi_Predicates
    20   | "type" => Role_Type
    21   | "unknown" => Role_Unknown
    22   | thing => raise (UNRECOGNISED_ROLE thing)
    23 
    24 %%
    25 %name TPTP
    26 %term AMPERSAND | AT_SIGN | CARET | COLON | COMMA | EQUALS | EXCLAMATION
    27   | LET | ARROW | IF | IFF | IMPLIES | INCLUDE
    28   | LAMBDA | LBRKT | LPAREN | MAP_TO | MMINUS | NAND
    29   | NEQUALS | XOR | NOR | PERIOD | PPLUS | QUESTION | RBRKT | RPAREN
    30   | TILDE | TOK_FALSE | TOK_I | TOK_O | TOK_INT | TOK_REAL | TOK_RAT | TOK_TRUE
    31   | TOK_TYPE | VLINE | EOF | DTHF | DFOF | DCNF | DFOT | DTFF | REAL of string
    32   | RATIONAL of string | SIGNED_INTEGER of string | UNSIGNED_INTEGER of string
    33   | DOT_DECIMAL of string | SINGLE_QUOTED of string | UPPER_WORD of string
    34   | LOWER_WORD of string | COMMENT of string
    35   | DISTINCT_OBJECT of string
    36   | DUD | INDEF_CHOICE | DEFIN_CHOICE
    37   | OPERATOR_FORALL | OPERATOR_EXISTS
    38   | PLUS | TIMES | GENTZEN_ARROW | DEP_SUM | DEP_PROD
    39   | ATOMIC_DEFINED_WORD of string | ATOMIC_SYSTEM_WORD of string
    40   | SUBTYPE | LET_TERM
    41   | THF | TFF | FOF | CNF
    42   | ITE_F | ITE_T
    43 %nonterm
    44     annotations of annotation option
    45   | name of string
    46   | name_list of string list
    47   | formula_selection of string list
    48   | optional_info of general_term list
    49   | general_list of general_list | general_terms of general_term list
    50   | general_term of general_term
    51 
    52   | atomic_word of string
    53   | general_data of general_data | variable_ of string
    54   | number of number_kind * string | formula_data of general_data
    55   | integer of string
    56   | identifier of string
    57   | general_function of general_data | useful_info of general_list
    58   | file_name of string
    59   | functor_ of symbol
    60   | term of tptp_term
    61   | arguments of tptp_term list
    62   | defined_functor of symbol
    63   | system_functor of symbol
    64   | system_constant of symbol
    65   | system_term of symbol * tptp_term list
    66   | defined_constant of symbol
    67   | defined_plain_term of symbol * tptp_term list
    68   | defined_atomic_term of tptp_term
    69   | defined_atom of tptp_term
    70   | defined_term of tptp_term
    71   | constant of symbol
    72   | plain_term of symbol * tptp_term list
    73   | function_term of tptp_term
    74   | conditional_term of tptp_term
    75   | system_atomic_formula of tptp_formula
    76   | infix_equality of symbol
    77   | infix_inequality of symbol
    78   | defined_infix_pred of symbol
    79   | defined_infix_formula of tptp_formula
    80   | defined_prop of string
    81   | defined_pred of string
    82   | defined_plain_formula of tptp_formula
    83   | defined_atomic_formula of tptp_formula
    84   | plain_atomic_formula of tptp_formula
    85   | atomic_formula of tptp_formula
    86   | unary_connective of symbol
    87 
    88   | defined_type of tptp_base_type
    89   | system_type of string
    90   | assoc_connective of symbol
    91   | binary_connective of symbol
    92   | fol_quantifier of quantifier
    93   | thf_unary_connective of symbol
    94   | thf_pair_connective of symbol
    95   | thf_quantifier of quantifier
    96   | fol_infix_unary of tptp_formula
    97   | thf_conn_term of symbol
    98   | literal of tptp_formula
    99   | disjunction of tptp_formula
   100   | cnf_formula of tptp_formula
   101   | fof_tuple_list of tptp_formula list
   102   | fof_tuple of tptp_formula list
   103   | fof_sequent of tptp_formula
   104   | fof_unary_formula of tptp_formula
   105   | fof_variable_list of string list
   106   | fof_quantified_formula of tptp_formula
   107   | fof_unitary_formula of tptp_formula
   108   | fof_and_formula of tptp_formula
   109   | fof_or_formula of tptp_formula
   110   | fof_binary_assoc of tptp_formula
   111   | fof_binary_nonassoc of tptp_formula
   112   | fof_binary_formula of tptp_formula
   113   | fof_logic_formula of tptp_formula
   114   | fof_formula of tptp_formula
   115   | tff_tuple of tptp_formula list
   116   | tff_tuple_list of tptp_formula list
   117   | tff_sequent of tptp_formula
   118   | tff_conditional of tptp_formula
   119   | tff_defined_var of tptp_let
   120   | tff_let_list of tptp_let list
   121   | tptp_let of tptp_formula
   122   | tff_xprod_type of tptp_type
   123   | tff_mapping_type of tptp_type
   124   | tff_atomic_type of tptp_type
   125   | tff_unitary_type of tptp_type
   126   | tff_top_level_type of tptp_type
   127   | tff_untyped_atom of symbol * tptp_type option
   128   | tff_typed_atom of symbol * tptp_type option
   129   | tff_unary_formula of tptp_formula
   130   | tff_typed_variable of string * tptp_type option
   131   | tff_variable of string * tptp_type option
   132   | tff_variable_list of (string * tptp_type option) list
   133   | tff_quantified_formula of tptp_formula
   134   | tff_unitary_formula of tptp_formula
   135   | tff_and_formula of tptp_formula
   136   | tff_or_formula of tptp_formula
   137   | tff_binary_assoc of tptp_formula
   138   | tff_binary_nonassoc of tptp_formula
   139   | tff_binary_formula of tptp_formula
   140   | tff_logic_formula of tptp_formula
   141   | tff_formula of tptp_formula
   142 
   143   | thf_tuple of tptp_formula list
   144   | thf_tuple_list of tptp_formula list
   145   | thf_sequent of tptp_formula
   146   | thf_conditional of tptp_formula
   147   | thf_defined_var of tptp_let
   148   | thf_let_list of tptp_let list
   149   | thf_let of tptp_formula
   150   | thf_atom of tptp_formula
   151   | thf_union_type of tptp_type
   152   | thf_xprod_type of tptp_type
   153   | thf_mapping_type of tptp_type
   154   | thf_binary_type of tptp_type
   155   | thf_unitary_type of tptp_type
   156   | thf_top_level_type of tptp_type
   157   | thf_subtype of tptp_type
   158   | thf_typeable_formula of tptp_formula
   159   | thf_type_formula of tptp_formula * tptp_type
   160   | thf_unary_formula of tptp_formula
   161   | thf_typed_variable of string * tptp_type option
   162   | thf_variable of string * tptp_type option
   163   | thf_variable_list of (string * tptp_type option) list
   164   | thf_quantified_formula of tptp_formula
   165   | thf_unitary_formula of tptp_formula
   166   | thf_apply_formula of tptp_formula
   167   | thf_and_formula of tptp_formula
   168   | thf_or_formula of tptp_formula
   169   | thf_binary_tuple of tptp_formula
   170   | thf_binary_pair of tptp_formula
   171   | thf_binary_formula of tptp_formula
   172   | thf_logic_formula of tptp_formula
   173   | thf_formula of tptp_formula
   174   | formula_role of role
   175 
   176   | cnf_annotated of tptp_line
   177   | fof_annotated of tptp_line
   178   | tff_annotated of tptp_line
   179   | thf_annotated of tptp_line
   180   | annotated_formula of tptp_line
   181   | include_ of tptp_line
   182   | tptp_input of tptp_line
   183   | tptp_file of tptp_problem
   184   | tptp of tptp_problem
   185 
   186 %pos int
   187 %eop EOF
   188 %noshift EOF
   189 %arg (file_name) : string
   190 
   191 %nonassoc LET
   192 %nonassoc RPAREN
   193 %nonassoc DUD
   194 %right COMMA
   195 %left COLON
   196 
   197 %left AT_SIGN
   198 %nonassoc IFF XOR
   199 %right IMPLIES IF
   200 %nonassoc EQUALS NEQUALS
   201 %right VLINE NOR
   202 %left AMPERSAND NAND
   203 %right ARROW
   204 %left PLUS
   205 %left TIMES
   206 
   207 %right OPERATOR_FORALL OPERATOR_EXISTS
   208 
   209 %nonassoc EXCLAMATION QUESTION LAMBDA CARET
   210 %nonassoc TILDE
   211 %pure
   212 %start tptp
   213 %verbose
   214 %%
   215 
   216 (*  Title:      HOL/TPTP/TPTP_Parser/tptp.yacc
   217     Author:     Nik Sultana, Cambridge University Computer Laboratory
   218 
   219  Parser for TPTP languages. Latest version of the language spec can
   220  be obtained from http://www.cs.miami.edu/~tptp/TPTP/SyntaxBNF.html
   221 *)
   222 
   223 annotations : COMMA general_term optional_info (( SOME (general_term, optional_info) ))
   224             |                                  (( NONE ))
   225 
   226 optional_info : COMMA useful_info (( useful_info ))
   227               |                   (( [] ))
   228 
   229 useful_info : general_list (( general_list ))
   230 
   231 general_list : LBRKT general_terms RBRKT (( general_terms ))
   232              | LBRKT RBRKT               (( [] ))
   233 
   234 general_terms : general_term COMMA general_terms (( general_term :: general_terms ))
   235               | general_term                     (( [general_term] ))
   236 
   237 general_term : general_data                    (( General_Data general_data ))
   238              | general_data COLON general_term (( General_Term (general_data, general_term) ))
   239              | general_list                    (( General_List general_list ))
   240 
   241 atomic_word : LOWER_WORD    (( LOWER_WORD ))
   242             | SINGLE_QUOTED (( SINGLE_QUOTED ))
   243             | THF           (( "thf" ))
   244             | TFF           (( "tff" ))
   245             | FOF           (( "fof" ))
   246             | CNF           (( "cnf" ))
   247             | INCLUDE       (( "include" ))
   248 
   249 variable_ : UPPER_WORD  (( UPPER_WORD ))
   250 
   251 general_function: atomic_word LPAREN general_terms RPAREN (( Application (atomic_word, general_terms) ))
   252 
   253 general_data : atomic_word       (( Atomic_Word atomic_word ))
   254              | general_function  (( general_function ))
   255              | variable_         (( V variable_ ))
   256              | number            (( Number number ))
   257              | DISTINCT_OBJECT   (( Distinct_Object DISTINCT_OBJECT ))
   258              | formula_data      (( formula_data ))
   259 
   260 number : integer          (( (Int_num, integer) ))
   261        | REAL             (( (Real_num, REAL) ))
   262        | RATIONAL         (( (Rat_num, RATIONAL) ))
   263 
   264 integer: UNSIGNED_INTEGER (( UNSIGNED_INTEGER ))
   265        | SIGNED_INTEGER   (( SIGNED_INTEGER ))
   266 
   267 file_name : SINGLE_QUOTED (( SINGLE_QUOTED ))
   268 
   269 formula_data : DTHF LPAREN thf_formula RPAREN (( Formula_Data (THF, thf_formula) ))
   270              | DTFF LPAREN tff_formula RPAREN (( Formula_Data (TFF, tff_formula) ))
   271              | DFOF LPAREN fof_formula RPAREN (( Formula_Data (FOF, fof_formula) ))
   272              | DCNF LPAREN cnf_formula RPAREN (( Formula_Data (CNF, cnf_formula) ))
   273              | DFOT LPAREN term RPAREN (( Term_Data term ))
   274 
   275 system_type : ATOMIC_SYSTEM_WORD (( ATOMIC_SYSTEM_WORD ))
   276 
   277 defined_type : ATOMIC_DEFINED_WORD ((
   278   case ATOMIC_DEFINED_WORD of
   279     "$i" => Type_Ind
   280   | "$o" => Type_Bool
   281   | "$iType" => Type_Ind
   282   | "$oType" => Type_Bool
   283   | "$int" => Type_Int
   284   | "$real" => Type_Real
   285   | "$rat" => Type_Rat
   286   | "$tType" => Type_Type
   287   | thing => raise UNRECOGNISED_SYMBOL ("defined_type", thing)
   288 ))
   289 
   290 functor_ : atomic_word (( Uninterpreted atomic_word ))
   291 
   292 arguments : term                  (( [term] ))
   293           | term COMMA arguments  (( term :: arguments ))
   294 
   295 system_functor : ATOMIC_SYSTEM_WORD (( System ATOMIC_SYSTEM_WORD ))
   296 system_constant : system_functor (( system_functor ))
   297 system_term : system_constant                         (( (system_constant, []) ))
   298             | system_functor LPAREN arguments RPAREN  (( (system_functor, arguments) ))
   299 
   300 defined_functor : ATOMIC_DEFINED_WORD ((
   301   case ATOMIC_DEFINED_WORD of
   302     "$sum" => Interpreted_ExtraLogic Sum
   303   | "$difference" => Interpreted_ExtraLogic Difference
   304   | "$product" => Interpreted_ExtraLogic Product
   305   | "$quotient" => Interpreted_ExtraLogic Quotient
   306   | "$quotient_e" => Interpreted_ExtraLogic Quotient_E
   307   | "$quotient_t" => Interpreted_ExtraLogic Quotient_T
   308   | "$quotient_f" => Interpreted_ExtraLogic Quotient_F
   309   | "$remainder_e" => Interpreted_ExtraLogic Remainder_E
   310   | "$remainder_t" => Interpreted_ExtraLogic Remainder_T
   311   | "$remainder_f" => Interpreted_ExtraLogic Remainder_F
   312   | "$floor" => Interpreted_ExtraLogic Floor
   313   | "$ceiling" => Interpreted_ExtraLogic Ceiling
   314   | "$truncate" => Interpreted_ExtraLogic Truncate
   315   | "$round" => Interpreted_ExtraLogic Round
   316   | "$to_int" => Interpreted_ExtraLogic To_Int
   317   | "$to_rat" => Interpreted_ExtraLogic To_Rat
   318   | "$to_real" => Interpreted_ExtraLogic To_Real
   319   | "$uminus" => Interpreted_ExtraLogic UMinus
   320 
   321   | "$i" => TypeSymbol Type_Ind
   322   | "$o" => TypeSymbol Type_Bool
   323   | "$iType" => TypeSymbol Type_Ind
   324   | "$oType" => TypeSymbol Type_Bool
   325   | "$int" => TypeSymbol Type_Int
   326   | "$real" => TypeSymbol Type_Real
   327   | "$rat" => TypeSymbol Type_Rat
   328   | "$tType" => TypeSymbol Type_Type
   329 
   330   | "$true" => Interpreted_Logic True
   331   | "$false" => Interpreted_Logic False
   332 
   333   | "$less" => Interpreted_ExtraLogic Less
   334   | "$lesseq" => Interpreted_ExtraLogic LessEq
   335   | "$greatereq" => Interpreted_ExtraLogic GreaterEq
   336   | "$greater" => Interpreted_ExtraLogic Greater
   337   | "$evaleq" => Interpreted_ExtraLogic EvalEq
   338 
   339   | "$is_int" => Interpreted_ExtraLogic Is_Int
   340   | "$is_rat" => Interpreted_ExtraLogic Is_Rat
   341 
   342   | thing => raise UNRECOGNISED_SYMBOL ("defined_functor", thing)
   343 ))
   344 
   345 defined_constant : defined_functor (( defined_functor ))
   346 
   347 defined_plain_term : defined_constant                        (( (defined_constant, []) ))
   348                    | defined_functor LPAREN arguments RPAREN (( (defined_functor, arguments) ))
   349 defined_atomic_term : defined_plain_term (( Term_Func defined_plain_term ))
   350 defined_atom : number          (( Term_Num number ))
   351              | DISTINCT_OBJECT (( Term_Distinct_Object DISTINCT_OBJECT ))
   352 defined_term : defined_atom        (( defined_atom ))
   353              | defined_atomic_term (( defined_atomic_term ))
   354 constant : functor_ (( functor_ ))
   355 plain_term : constant                          (( (constant, []) ))
   356            | functor_ LPAREN arguments RPAREN  (( (functor_, arguments) ))
   357 function_term : plain_term    (( Term_Func plain_term ))
   358               | defined_term  (( defined_term ))
   359               | system_term   (( Term_Func system_term ))
   360 
   361 conditional_term : ITE_T LPAREN tff_logic_formula COMMA term COMMA term RPAREN ((
   362   Term_Conditional (tff_logic_formula, term1, term2)
   363 ))
   364 
   365 term : function_term     (( function_term ))
   366      | variable_         (( Term_Var variable_ ))
   367      | conditional_term  (( conditional_term ))
   368 
   369 system_atomic_formula : system_term  (( Pred system_term ))
   370 infix_equality : EQUALS    (( Interpreted_Logic Equals ))
   371 infix_inequality : NEQUALS (( Interpreted_Logic NEquals ))
   372 defined_infix_pred : infix_equality  (( infix_equality ))
   373 defined_infix_formula : term defined_infix_pred term ((Pred (defined_infix_pred, [term1, term2])))
   374 defined_prop : ATOMIC_DEFINED_WORD ((
   375   case ATOMIC_DEFINED_WORD of
   376     "$true"  => "$true"
   377   | "$false" => "$false"
   378   | thing => raise UNRECOGNISED_SYMBOL ("defined_prop", thing)
   379 ))
   380 defined_pred : ATOMIC_DEFINED_WORD ((
   381   case ATOMIC_DEFINED_WORD of
   382     "$distinct"  => "$distinct"
   383   | "$ite_f" => "$ite_f"
   384   | "$less" => "$less"
   385   | "$lesseq" => "$lesseq"
   386   | "$greater" => "$greater"
   387   | "$greatereq" => "$greatereq"
   388   | "$is_int" => "$is_int"
   389   | "$is_rat" => "$is_rat"
   390   | thing => raise UNRECOGNISED_SYMBOL ("defined_pred", thing)
   391 ))
   392 defined_plain_formula : defined_plain_term (( Pred defined_plain_term ))
   393 defined_atomic_formula : defined_plain_formula (( defined_plain_formula ))
   394                        | defined_infix_formula (( defined_infix_formula ))
   395 plain_atomic_formula : plain_term (( Pred plain_term ))
   396 atomic_formula : plain_atomic_formula   (( plain_atomic_formula ))
   397                | defined_atomic_formula (( defined_atomic_formula ))
   398                | system_atomic_formula  (( system_atomic_formula ))
   399 
   400 assoc_connective : VLINE      (( Interpreted_Logic Or ))
   401                  | AMPERSAND  (( Interpreted_Logic And ))
   402 binary_connective : IFF       (( Interpreted_Logic Iff ))
   403                   | IMPLIES   (( Interpreted_Logic If ))
   404                   | IF        (( Interpreted_Logic Fi ))
   405                   | XOR       (( Interpreted_Logic Xor ))
   406                   | NOR       (( Interpreted_Logic Nor ))
   407                   | NAND      (( Interpreted_Logic Nand ))
   408 
   409 fol_quantifier : EXCLAMATION  (( Forall ))
   410                | QUESTION     (( Exists ))
   411 thf_unary_connective : unary_connective (( unary_connective ))
   412                      | OPERATOR_FORALL  (( Interpreted_Logic Op_Forall ))
   413                      | OPERATOR_EXISTS  (( Interpreted_Logic Op_Exists ))
   414 thf_pair_connective : infix_equality    (( infix_equality ))
   415                     | infix_inequality  (( infix_inequality ))
   416                     | binary_connective (( binary_connective ))
   417 thf_quantifier : fol_quantifier (( fol_quantifier ))
   418                | CARET          (( Lambda ))
   419                | DEP_PROD       (( Dep_Prod ))
   420                | DEP_SUM        (( Dep_Sum ))
   421                | INDEF_CHOICE   (( Epsilon ))
   422                | DEFIN_CHOICE   (( Iota ))
   423 fol_infix_unary : term infix_inequality term (( Pred (infix_inequality, [term1, term2]) ))
   424 thf_conn_term : thf_pair_connective   (( thf_pair_connective ))
   425               | assoc_connective      (( assoc_connective ))
   426               | thf_unary_connective  (( thf_unary_connective ))
   427 literal : atomic_formula        (( atomic_formula ))
   428         | TILDE atomic_formula  (( Fmla (Interpreted_Logic Not, [atomic_formula]) ))
   429         | fol_infix_unary       (( fol_infix_unary ))
   430 disjunction : literal                    (( literal ))
   431             | disjunction VLINE literal  (( Fmla (Interpreted_Logic Or, [disjunction, literal]) ))
   432 cnf_formula : LPAREN disjunction RPAREN  (( disjunction ))
   433             | disjunction                (( disjunction ))
   434 fof_tuple_list : fof_logic_formula                      (( [fof_logic_formula] ))
   435                | fof_logic_formula COMMA fof_tuple_list (( fof_logic_formula :: fof_tuple_list ))
   436 fof_tuple : LBRKT RBRKT                 (( [] ))
   437           | LBRKT fof_tuple_list RBRKT  (( fof_tuple_list ))
   438 fof_sequent : fof_tuple GENTZEN_ARROW fof_tuple (( Sequent (fof_tuple1, fof_tuple2) ))
   439             | LPAREN fof_sequent RPAREN         (( fof_sequent ))
   440 unary_connective : TILDE (( Interpreted_Logic Not ))
   441 fof_unary_formula : unary_connective fof_unitary_formula (( Fmla (unary_connective, [fof_unitary_formula]) ))
   442                   | fol_infix_unary                      (( fol_infix_unary ))
   443 fof_variable_list : variable_                          (( [variable_] ))
   444                   | variable_ COMMA fof_variable_list  (( variable_ :: fof_variable_list ))
   445 fof_quantified_formula : fol_quantifier LBRKT fof_variable_list RBRKT COLON fof_unitary_formula ((
   446   Quant (fol_quantifier, map (fn v => (v, NONE)) fof_variable_list, fof_unitary_formula)
   447 ))
   448 fof_unitary_formula : fof_quantified_formula (( fof_quantified_formula ))
   449                     | fof_unary_formula      (( fof_unary_formula ))
   450                     | atomic_formula         (( atomic_formula ))
   451                     | LPAREN fof_logic_formula RPAREN (( fof_logic_formula ))
   452 fof_and_formula : fof_unitary_formula AMPERSAND fof_unitary_formula (( Fmla (Interpreted_Logic And, [fof_unitary_formula1, fof_unitary_formula2]) ))
   453                 | fof_and_formula AMPERSAND fof_unitary_formula     (( Fmla (Interpreted_Logic And, [fof_and_formula, fof_unitary_formula]) ))
   454 fof_or_formula : fof_unitary_formula VLINE fof_unitary_formula  (( Fmla (Interpreted_Logic Or, [fof_unitary_formula1, fof_unitary_formula2]) ))
   455                | fof_or_formula VLINE fof_unitary_formula       (( Fmla (Interpreted_Logic Or, [fof_or_formula, fof_unitary_formula]) ))
   456 fof_binary_assoc : fof_or_formula  (( fof_or_formula ))
   457                  | fof_and_formula (( fof_and_formula ))
   458 fof_binary_nonassoc : fof_unitary_formula binary_connective fof_unitary_formula ((
   459   Fmla (binary_connective, [fof_unitary_formula1, fof_unitary_formula2] )
   460 ))
   461 fof_binary_formula : fof_binary_nonassoc (( fof_binary_nonassoc ))
   462                    | fof_binary_assoc    (( fof_binary_assoc ))
   463 fof_logic_formula : fof_binary_formula   (( fof_binary_formula ))
   464                   | fof_unitary_formula  (( fof_unitary_formula ))
   465 fof_formula : fof_logic_formula  (( fof_logic_formula ))
   466             | fof_sequent        (( fof_sequent ))
   467 
   468 
   469 tff_tuple : LBRKT RBRKT    (( [] ))
   470           | LBRKT tff_tuple_list RBRKT (( tff_tuple_list ))
   471 tff_tuple_list : tff_logic_formula COMMA tff_tuple_list (( tff_logic_formula :: tff_tuple_list ))
   472                | tff_logic_formula                      (( [tff_logic_formula] ))
   473 tff_sequent : tff_tuple GENTZEN_ARROW tff_tuple (( Sequent (tff_tuple1, tff_tuple2) ))
   474             | LPAREN tff_sequent RPAREN         (( tff_sequent ))
   475 tff_conditional : ITE_F LPAREN tff_logic_formula COMMA tff_logic_formula COMMA tff_logic_formula RPAREN ((
   476   Conditional (tff_logic_formula1, tff_logic_formula2, tff_logic_formula3)
   477 ))
   478 tff_defined_var : variable_ LET tff_logic_formula (( Let_fmla ((variable_, NONE), tff_logic_formula) ))
   479                 | variable_ LET_TERM term (( Let_term ((variable_, NONE), term) ))
   480                 | LPAREN tff_defined_var RPAREN (( tff_defined_var ))
   481 tff_let_list : tff_defined_var                    (( [tff_defined_var] ))
   482              | tff_defined_var COMMA tff_let_list (( tff_defined_var :: tff_let_list ))
   483 tptp_let : LET LBRKT tff_let_list RBRKT COLON tff_unitary_formula ((
   484   Let (tff_let_list, tff_unitary_formula)
   485 ))
   486 tff_xprod_type : tff_atomic_type TIMES tff_atomic_type (( Prod_type(tff_atomic_type1, tff_atomic_type2) ))
   487                | tff_xprod_type TIMES tff_atomic_type  (( Prod_type(tff_xprod_type, tff_atomic_type) ))
   488                | LPAREN tff_xprod_type RPAREN          (( tff_xprod_type ))
   489 tff_mapping_type : tff_unitary_type ARROW tff_atomic_type (( Fn_type(tff_unitary_type, tff_atomic_type) ))
   490                  | LPAREN tff_mapping_type RPAREN         (( tff_mapping_type ))
   491 tff_atomic_type : atomic_word   (( Atom_type atomic_word ))
   492                 | defined_type  (( Defined_type defined_type ))
   493 tff_unitary_type : tff_atomic_type               (( tff_atomic_type ))
   494                  | LPAREN tff_xprod_type RPAREN  (( tff_xprod_type ))
   495 tff_top_level_type : tff_atomic_type   (( tff_atomic_type ))
   496                    | tff_mapping_type  (( tff_mapping_type ))
   497 tff_untyped_atom : functor_       (( (functor_, NONE) ))
   498                  | system_functor (( (system_functor, NONE) ))
   499 tff_typed_atom : tff_untyped_atom COLON tff_top_level_type (( (fst tff_untyped_atom, SOME tff_top_level_type) ))
   500                | LPAREN tff_typed_atom RPAREN              (( tff_typed_atom ))
   501 
   502 tff_unary_formula : unary_connective tff_unitary_formula (( Fmla (unary_connective, [tff_unitary_formula]) ))
   503                   | fol_infix_unary                      (( fol_infix_unary ))
   504 tff_typed_variable : variable_ COLON tff_atomic_type (( (variable_, SOME tff_atomic_type) ))
   505 tff_variable : tff_typed_variable (( tff_typed_variable ))
   506              | variable_          (( (variable_, NONE) ))
   507 tff_variable_list : tff_variable                         (( [tff_variable] ))
   508                   | tff_variable COMMA tff_variable_list (( tff_variable :: tff_variable_list ))
   509 tff_quantified_formula : fol_quantifier LBRKT tff_variable_list RBRKT COLON tff_unitary_formula ((
   510   Quant (fol_quantifier, tff_variable_list, tff_unitary_formula)
   511 ))
   512 tff_unitary_formula : tff_quantified_formula           (( tff_quantified_formula ))
   513                     | tff_unary_formula                (( tff_unary_formula ))
   514                     | atomic_formula                   (( atomic_formula ))
   515                     | tptp_let                         (( tptp_let ))
   516                     | variable_                        (( Pred (Uninterpreted variable_, []) ))
   517                     | tff_conditional                  (( tff_conditional ))
   518                     | LPAREN tff_logic_formula RPAREN  (( tff_logic_formula ))
   519 tff_and_formula : tff_unitary_formula AMPERSAND tff_unitary_formula (( Fmla (Interpreted_Logic And, [tff_unitary_formula1, tff_unitary_formula2]) ))
   520                 | tff_and_formula AMPERSAND tff_unitary_formula     (( Fmla (Interpreted_Logic And, [tff_and_formula, tff_unitary_formula]) ))
   521 tff_or_formula : tff_unitary_formula VLINE tff_unitary_formula      (( Fmla (Interpreted_Logic Or, [tff_unitary_formula1, tff_unitary_formula2]) ))
   522                | tff_or_formula VLINE tff_unitary_formula           (( Fmla (Interpreted_Logic Or, [tff_or_formula, tff_unitary_formula]) ))
   523 tff_binary_assoc : tff_or_formula  (( tff_or_formula ))
   524                  | tff_and_formula (( tff_and_formula ))
   525 tff_binary_nonassoc : tff_unitary_formula binary_connective tff_unitary_formula (( Fmla (binary_connective, [tff_unitary_formula1, tff_unitary_formula2]) ))
   526 tff_binary_formula : tff_binary_nonassoc (( tff_binary_nonassoc ))
   527                    | tff_binary_assoc    (( tff_binary_assoc ))
   528 tff_logic_formula : tff_binary_formula   (( tff_binary_formula ))
   529                   | tff_unitary_formula  (( tff_unitary_formula ))
   530 tff_formula : tff_logic_formula  (( tff_logic_formula ))
   531             | tff_typed_atom     (( Atom (TFF_Typed_Atom tff_typed_atom) ))
   532             | tff_sequent        (( tff_sequent ))
   533 
   534 thf_tuple : LBRKT RBRKT                (( [] ))
   535           | LBRKT thf_tuple_list RBRKT (( thf_tuple_list ))
   536 thf_tuple_list : thf_logic_formula                      (( [thf_logic_formula] ))
   537                | thf_logic_formula COMMA thf_tuple_list (( thf_logic_formula :: thf_tuple_list ))
   538 thf_sequent : thf_tuple GENTZEN_ARROW thf_tuple  (( Sequent(thf_tuple1, thf_tuple2) ))
   539             | LPAREN thf_sequent RPAREN          (( thf_sequent ))
   540 thf_conditional : ITE_F LPAREN thf_logic_formula COMMA thf_logic_formula COMMA thf_logic_formula RPAREN ((
   541   Conditional (thf_logic_formula1, thf_logic_formula2, thf_logic_formula3)
   542 ))
   543 thf_defined_var : thf_variable LET thf_logic_formula (( Let_fmla (thf_variable, thf_logic_formula) ))
   544                 | LPAREN thf_defined_var RPAREN      (( thf_defined_var ))
   545 thf_let_list : thf_defined_var                    (( [thf_defined_var] ))
   546              | thf_defined_var COMMA thf_let_list (( thf_defined_var :: thf_let_list ))
   547 thf_let : LET LBRKT thf_let_list RBRKT COLON thf_unitary_formula ((
   548   Let (thf_let_list, thf_unitary_formula)
   549 ))
   550 thf_atom : term          (( Atom (THF_Atom_term term) ))
   551          | thf_conn_term (( Atom (THF_Atom_conn_term thf_conn_term) ))
   552 thf_union_type : thf_unitary_type PLUS thf_unitary_type    (( Sum_type(thf_unitary_type1, thf_unitary_type2) ))
   553                | thf_union_type PLUS thf_unitary_type      (( Sum_type(thf_union_type, thf_unitary_type) ))
   554 thf_xprod_type : thf_unitary_type TIMES thf_unitary_type   (( Prod_type(thf_unitary_type1, thf_unitary_type2) ))
   555                | thf_xprod_type TIMES thf_unitary_type     (( Prod_type(thf_xprod_type, thf_unitary_type) ))
   556 thf_mapping_type : thf_unitary_type ARROW thf_unitary_type (( Fn_type(thf_unitary_type1, thf_unitary_type2) ))
   557                  | thf_unitary_type ARROW thf_mapping_type (( Fn_type(thf_unitary_type, thf_mapping_type) ))
   558 thf_binary_type : thf_mapping_type (( thf_mapping_type ))
   559                 | thf_xprod_type   (( thf_xprod_type ))
   560                 | thf_union_type   (( thf_union_type ))
   561 thf_unitary_type : thf_unitary_formula (( Fmla_type thf_unitary_formula ))
   562 thf_top_level_type : thf_logic_formula (( Fmla_type thf_logic_formula ))
   563 thf_subtype : constant SUBTYPE constant (( Subtype(constant1, constant2) ))
   564 thf_typeable_formula : thf_atom                         (( thf_atom ))
   565                      | LPAREN thf_logic_formula RPAREN  (( thf_logic_formula ))
   566 thf_type_formula : thf_typeable_formula COLON thf_top_level_type (( (thf_typeable_formula, thf_top_level_type) ))
   567 thf_unary_formula : thf_unary_connective LPAREN thf_logic_formula RPAREN ((
   568   Fmla (thf_unary_connective, [thf_logic_formula])
   569 ))
   570 thf_typed_variable : variable_ COLON thf_top_level_type (( (variable_, SOME thf_top_level_type) ))
   571 thf_variable : thf_typed_variable (( thf_typed_variable ))
   572              | variable_          (( (variable_, NONE) ))
   573 thf_variable_list : thf_variable                          (( [thf_variable] ))
   574                   | thf_variable COMMA thf_variable_list  (( thf_variable :: thf_variable_list ))
   575 thf_quantified_formula : thf_quantifier LBRKT thf_variable_list RBRKT COLON thf_unitary_formula ((
   576   Quant (thf_quantifier, thf_variable_list, thf_unitary_formula)
   577 ))
   578 thf_unitary_formula : thf_quantified_formula (( thf_quantified_formula ))
   579                     | thf_unary_formula      (( thf_unary_formula ))
   580                     | thf_atom               (( thf_atom ))
   581                     | thf_let                (( thf_let ))
   582                     | thf_conditional        (( thf_conditional ))
   583                     | LPAREN thf_logic_formula RPAREN  (( thf_logic_formula ))
   584 thf_apply_formula : thf_unitary_formula AT_SIGN thf_unitary_formula (( Fmla (Interpreted_ExtraLogic Apply, [thf_unitary_formula1, thf_unitary_formula2]) ))
   585                   | thf_apply_formula AT_SIGN thf_unitary_formula   (( Fmla (Interpreted_ExtraLogic Apply, [thf_apply_formula, thf_unitary_formula]) ))
   586 thf_and_formula : thf_unitary_formula AMPERSAND thf_unitary_formula (( Fmla (Interpreted_Logic And, [thf_unitary_formula1, thf_unitary_formula2]) ))
   587                 | thf_and_formula AMPERSAND thf_unitary_formula     (( Fmla (Interpreted_Logic And, [thf_and_formula, thf_unitary_formula]) ))
   588 thf_or_formula : thf_unitary_formula VLINE thf_unitary_formula (( Fmla (Interpreted_Logic Or, [thf_unitary_formula1, thf_unitary_formula2]) ))
   589                | thf_or_formula VLINE thf_unitary_formula      (( Fmla (Interpreted_Logic Or, [thf_or_formula, thf_unitary_formula]) ))
   590 thf_binary_tuple : thf_or_formula    (( thf_or_formula ))
   591                  | thf_and_formula   (( thf_and_formula ))
   592                  | thf_apply_formula (( thf_apply_formula ))
   593 thf_binary_pair : thf_unitary_formula thf_pair_connective thf_unitary_formula ((
   594   Fmla (thf_pair_connective, [thf_unitary_formula1, thf_unitary_formula2])
   595 ))
   596 thf_binary_formula : thf_binary_pair   (( thf_binary_pair ))
   597                    | thf_binary_tuple  (( thf_binary_tuple ))
   598                    | thf_binary_type   (( THF_type thf_binary_type ))
   599 thf_logic_formula : thf_binary_formula   (( thf_binary_formula ))
   600                   | thf_unitary_formula  (( thf_unitary_formula ))
   601                   | thf_type_formula     (( THF_typing thf_type_formula ))
   602                   | thf_subtype          (( THF_type thf_subtype ))
   603 thf_formula : thf_logic_formula (( thf_logic_formula ))
   604             | thf_sequent       (( thf_sequent ))
   605 
   606 formula_role : LOWER_WORD (( classify_role LOWER_WORD ))
   607 
   608 thf_annotated : THF LPAREN name COMMA formula_role COMMA thf_formula annotations RPAREN PERIOD ((
   609   Annotated_Formula ((file_name, THFleft + 1, THFright + 1),
   610    THF, name, formula_role, thf_formula, annotations)
   611 ))
   612 
   613 tff_annotated : TFF LPAREN name COMMA formula_role COMMA tff_formula annotations RPAREN PERIOD ((
   614   Annotated_Formula ((file_name, TFFleft + 1, TFFright + 1),
   615    TFF, name, formula_role, tff_formula, annotations)
   616 ))
   617 
   618 fof_annotated : FOF LPAREN name COMMA formula_role COMMA fof_formula annotations RPAREN PERIOD ((
   619   Annotated_Formula ((file_name, FOFleft + 1, FOFright + 1),
   620    FOF, name, formula_role, fof_formula, annotations)
   621 ))
   622 
   623 cnf_annotated : CNF LPAREN name COMMA formula_role COMMA cnf_formula annotations RPAREN PERIOD ((
   624   Annotated_Formula ((file_name, CNFleft + 1, CNFright + 1),
   625    CNF, name, formula_role, cnf_formula, annotations)
   626 ))
   627 
   628 annotated_formula : cnf_annotated (( cnf_annotated ))
   629                   | fof_annotated (( fof_annotated ))
   630                   | tff_annotated (( tff_annotated ))
   631                   | thf_annotated (( thf_annotated ))
   632 
   633 include_ : INCLUDE LPAREN file_name formula_selection RPAREN PERIOD ((
   634   Include (file_name, formula_selection)
   635 ))
   636 
   637 formula_selection : COMMA LBRKT name_list RBRKT   (( name_list  ))
   638                   |                               (( [] ))
   639 
   640 name_list : name COMMA name_list   (( name :: name_list ))
   641           | name                   (( [name] ))
   642 
   643 name : atomic_word (( atomic_word ))
   644      | integer     (( integer ))
   645 
   646 tptp_input : annotated_formula (( annotated_formula ))
   647            | include_           (( include_ ))
   648 
   649 tptp_file : tptp_input tptp_file (( tptp_input :: tptp_file ))
   650           | COMMENT tptp_file    (( tptp_file ))
   651           |                      (( [] ))
   652 
   653 tptp : tptp_file (( tptp_file ))