%{ /* Compile with -DP_VERBOSE=1 for verbose output. */ /* Compile with -DP_USERPROC=1 to #include p_user_proc.c. */ /* p_user_proc.c should #define P_ACT, P_BUILD, P_TOKEN, P_PRINT to*/ /* different procedures from those below, and supply code. */ /* *_strict rules are documentation; unreachable; hand-code semantic actions.*/ #include #include #include #ifndef P_VERBOSE # define P_VERBOSE 0 #endif #ifdef P_USERPROC # include "p_user_proc.c" #else # define P_ACT(ss) if(verbose)printf("%7d %s\n",yylineno,ss); # define P_BUILD(sym,A,B,C,D,E,F,G,H,I,J) pBuildTree(sym,A,B,C,D,E,F,G,H,I,J) # define P_TOKEN(tok,sym) pToken(tok,sym) # define P_PRINT(ss) if(verbose){printf("\n\n");pPrintTree(ss,0);} #endif #define MAX_CH 10 extern int yylineno; /* tptp_ff is just an example of lex-er interface; setting to 0 is no-op. */ extern int tptp_ff; int verbose = P_VERBOSE; char pTokenBuf[512]; typedef struct pTreeNode * pTree; struct pTreeNode {char* sym; pTree ch[MAX_CH+1];}; pTree pBuildTree(char* sym, pTree A, pTree B, pTree C, pTree D, pTree E, pTree F, pTree G, pTree H, pTree I, pTree J); pTree pBuildTree(char* sym, pTree A, pTree B, pTree C, pTree D, pTree E, pTree F, pTree G, pTree H, pTree I, pTree J) { pTree ss = (pTree)calloc(1,sizeof(struct pTreeNode)); ss->sym = sym; ss->ch[0] = A; ss->ch[1] = B; ss->ch[2] = C; ss->ch[3] = D; ss->ch[4] = E; ss->ch[5] = F; ss->ch[6] = G; ss->ch[7] = H; ss->ch[8] = I; ss->ch[9] = J; ss->ch[10] = 0; return ss; } pTree pToken(char* tok, char* sym); pTree pToken(char* tok, char* sym) { pTree ss; char* safeSym; strcpy(pTokenBuf, tok); strcat(pTokenBuf, sym); safeSym = strdup(pTokenBuf); ss = pBuildTree(safeSym,0,0,0,0,0,0,0,0,0,0); return ss; } void pPrintTree(pTree ss, int depth); void pPrintTree(pTree ss, int depth) { int i, d; for (d = 0; d < depth; d++) printf(" "); if (ss->ch[0] == 0) printf("%s\n", ss->sym); else printf("<%s>\n", ss->sym); i = 0; while(ss->ch[i] != 0) {pPrintTree(ss->ch[i], depth+1); i++;} return; } %} %union {int ival; double dval; char* sval; void* pval;} %start TPTP_file %token AMPERSAND %token CNF %token COLON %token COMMA %token CREATOR %token DDOLLAR %token DESCRIPTION %token EQUALS %token EXCLAMATION %token FOF %token IF %token IFF %token IMPLIES %token INCLUDE %token INFERENCE %token INTRODUCED %token IQUOTE %token LBRKT %token LPAREN %token MINUS %token NAMPERSAND %token NEQUALS %token NIFF %token NVLINE %token PERIOD %token PLUS %token QUESTION %token RBRKT %token REFUTATION %token RPAREN %token STAR %token STATUS %token THEORY %token TILDE %token TOK_FALSE %token TOK_FILE %token TOK_TRUE %token VLINE %token atomic_system_word %token comment %token distinct_object %token lower_word %token real %token signed_integer %token single_quoted %token system_comment %token unrecognized %token unsigned_integer %token upper_word %token AC %token AXIOM %token AXIOM_OF_CHOICE %token CAX %token CEQ %token CONJECTURE %token CSA %token CSB %token CSM %token CSP %token CSR %token CTH %token DEFINITION %token EQUALITY %token EQV %token HYPOTHESIS %token LEMMA %token LEMMA_CONJECTURE %token NEGATED_CONJECTURE %token NOC %token PLAIN %token SAB %token SAM %token SAP %token SAR %token SAT %token TAC %token TAU %token TAUTOLOGY %token THEOREM %token THM %token UNC %token UNKNOWN %token UNS %% /*----Version 3.1.1.13b (TPTP version.internal development number) */ /*----Intended uses of the various parts of the TPTP syntax are explained */ /*----in the TPTP technical manual, linked from www.tptp.org. */ /*----See the comment entries regarding text that can be discarded before */ /*----tokenizing for this syntax. */ /*----White space is almost irrelevant, but, for the Prolog people, all tokens */ /*----consisting of non-alphanumeric characters shuold be followed bya space. */ /*----Files. Empty file is OK. */ TPTP_file : null {} | TPTP_file TPTP_input {} ; TPTP_input : annotated_formula {P_PRINT($$);} | include {P_PRINT($$);} | comment {P_PRINT(P_TOKEN("comment ", $1));} | system_comment {P_PRINT(P_TOKEN("system_comment ", $1));} ; /*----Formula records */ annotated_formula : fof_annotated {$$ = P_BUILD("annotated_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | cnf_annotated {$$ = P_BUILD("annotated_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Future languages may include ... english | efof | tfof | mathml | ... */ fof_annotated : FOF LPAREN name COMMA formula_role COMMA fof_formula annotations RPAREN PERIOD {$$ = P_BUILD("fof_annotated", P_TOKEN("FOF ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("COMMA ", $4), $5, P_TOKEN("COMMA ", $6), $7, $8, P_TOKEN("RPAREN ", $9), P_TOKEN("PERIOD ", $10));} ; cnf_annotated : CNF LPAREN name COMMA formula_role COMMA cnf_formula annotations RPAREN PERIOD {$$ = P_BUILD("cnf_annotated", P_TOKEN("CNF ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("COMMA ", $4), $5, P_TOKEN("COMMA ", $6), $7, $8, P_TOKEN("RPAREN ", $9), P_TOKEN("PERIOD ", $10));} ; annotations : null {$$ = P_BUILD("annotations", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | COMMA source {$$ = P_BUILD("annotations", P_TOKEN("COMMA ", $1), $2, 0, 0, 0, 0, 0, 0, 0, 0);} | COMMA source COMMA useful_info {$$ = P_BUILD("annotations", P_TOKEN("COMMA ", $1), $2, P_TOKEN("COMMA ", $3), $4, 0, 0, 0, 0, 0, 0);} ; /*----Types for problems. */ /*----Note: The previous source_type from ... */ /*---- formula_role ::= user_role - source */ /*----... is now gone. Parsers may choose to be tolerant of it for backwards */ /*----compatibility. */ formula_role : lower_word {$$ = P_BUILD("formula_role", P_TOKEN("lower_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; formula_role_strict : AXIOM {$$ = P_BUILD("formula_role_strict", P_TOKEN("AXIOM ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | HYPOTHESIS {$$ = P_BUILD("formula_role_strict", P_TOKEN("HYPOTHESIS ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | DEFINITION {$$ = P_BUILD("formula_role_strict", P_TOKEN("DEFINITION ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | LEMMA {$$ = P_BUILD("formula_role_strict", P_TOKEN("LEMMA ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | THEOREM {$$ = P_BUILD("formula_role_strict", P_TOKEN("THEOREM ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CONJECTURE {$$ = P_BUILD("formula_role_strict", P_TOKEN("CONJECTURE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | LEMMA_CONJECTURE {$$ = P_BUILD("formula_role_strict", P_TOKEN("LEMMA_CONJECTURE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | NEGATED_CONJECTURE {$$ = P_BUILD("formula_role_strict", P_TOKEN("NEGATED_CONJECTURE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | PLAIN {$$ = P_BUILD("formula_role_strict", P_TOKEN("PLAIN ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | UNKNOWN {$$ = P_BUILD("formula_role_strict", P_TOKEN("UNKNOWN ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----"axiom"s are accepted, without proof, as a basis for proving "conjecture"s */ /*----and "lemma_conjecture"s in FOF problems. In CNF problems "axiom"s are */ /*----accepted as part of the set whose satisfiability has to be established. */ /*----There is no guarantee that the axioms of a problem are consistent. */ /*----"hypothesis"s are assumed to be true for a particular problem, and are */ /*----used like "axiom"s. */ /*----"definition"s are used to define symbols, and are used like "axiom"s. */ /*----"lemma"s and "theorem"s have been proven from the "axiom"s, can be used */ /*----like "axiom"s, but are redundant wrt the "axiom"s. "lemma" is used as the */ /*----role of proven "lemma_conjecture"s, and "theorem" is used as the role of */ /*----proven "conjecture"s, in output. A problem containing a "lemma" or */ /*----"theorem" that is not redundant wrt the "axiom"s is ill-formed. "theorem"s */ /*----are more important than "lemma"s from the user perspective. */ /*----"conjecture"s occur in only FOF problems, and are to all be proven from */ /*----the "axiom"(-like) formulae. A problem is solved only when all */ /*----"conjecture"s are proven. */ /*----"lemma_conjecture"s are expected to be provable, and may be useful to */ /*----prove, while proving "conjecture"s. */ /*----"negated_conjecture"s ocuur in only CNF problems, and are formed from */ /*----negation of a "conjecture" in a FOF to CNF conversion. */ /*----"plain"s have no special user semantics, and can be used like "axiom"s. */ /*----"unknown"s have unknown role, and this is an error situation. */ /*----FOF formulae. All formulae must be closed. */ fof_formula : binary_formula {$$ = P_BUILD("fof_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0); tptp_ff = 0;} | unitary_formula {$$ = P_BUILD("fof_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0); tptp_ff = 0;} ; binary_formula : nonassoc_binary {$$ = P_BUILD("binary_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | assoc_binary {$$ = P_BUILD("binary_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Only some binary connectives are associative */ /*----There's no precedence amoung binary connectives */ nonassoc_binary : unitary_formula binary_connective unitary_formula {$$ = P_BUILD("nonassoc_binary", $1, $2, $3, 0, 0, 0, 0, 0, 0, 0);} ; binary_connective : IFF {$$ = P_BUILD("binary_connective", P_TOKEN("IFF ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | IMPLIES {$$ = P_BUILD("binary_connective", P_TOKEN("IMPLIES ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | IF {$$ = P_BUILD("binary_connective", P_TOKEN("IF ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | NIFF {$$ = P_BUILD("binary_connective", P_TOKEN("NIFF ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | NVLINE {$$ = P_BUILD("binary_connective", P_TOKEN("NVLINE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | NAMPERSAND {$$ = P_BUILD("binary_connective", P_TOKEN("NAMPERSAND ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Associative connectives & and | are in assoc_binary */ assoc_binary : or_formula {$$ = P_BUILD("assoc_binary", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | and_formula {$$ = P_BUILD("assoc_binary", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; or_formula : unitary_formula VLINE unitary_formula {$$ = P_BUILD("or_formula", $1, P_TOKEN("VLINE ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} | unitary_formula VLINE or_formula {$$ = P_BUILD("or_formula", $1, P_TOKEN("VLINE ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; and_formula : unitary_formula AMPERSAND unitary_formula {$$ = P_BUILD("and_formula", $1, P_TOKEN("AMPERSAND ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} | unitary_formula AMPERSAND and_formula {$$ = P_BUILD("and_formula", $1, P_TOKEN("AMPERSAND ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; /*---- unitary_formula are in ()s or do not have a binary_connective at the */ /*----top level. */ unitary_formula : quantified_formula {$$ = P_BUILD("unitary_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | unary_formula {$$ = P_BUILD("unitary_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | LPAREN fof_formula RPAREN {$$ = P_BUILD("unitary_formula", P_TOKEN("LPAREN ", $1), $2, P_TOKEN("RPAREN ", $3), 0, 0, 0, 0, 0, 0, 0);} | atomic_formula {$$ = P_BUILD("unitary_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; quantified_formula : quantifier LBRKT variable_list RBRKT COLON unitary_formula {$$ = P_BUILD("quantified_formula", $1, P_TOKEN("LBRKT ", $2), $3, P_TOKEN("RBRKT ", $4), P_TOKEN("COLON ", $5), $6, 0, 0, 0, 0);} ; quantifier : EXCLAMATION {$$ = P_BUILD("quantifier", P_TOKEN("EXCLAMATION ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | QUESTION {$$ = P_BUILD("quantifier", P_TOKEN("QUESTION ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----! is universal quantification and ? is existential. Syntactically, the */ /*----quantification is the left operand of :, and the unitary_formula is */ /*----the right operand. Although : is a binary operator syntactically, it is */ /*----not a binary_connective , and thus a quantified_formula is a */ /*---- unitary_formula . */ /*----Universal example: ! [X,Y] : ((p(X) & p(Y)) => q(X,Y)). */ /*----Existential example: ? [X,Y] : (p(X) & p(Y)) & ~ q(X,Y). */ /*----Quantifiers have higher precedence than binary connectives, so in */ /*----the existential example the quantifier applies to only (p(X) & p(Y)). */ variable_list : variable {$$ = P_BUILD("variable_list", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | variable COMMA variable_list {$$ = P_BUILD("variable_list", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; /*----Future variables may have sorts and existential counting */ /*----Unary connectives bind more tightly than binary */ unary_formula : unary_connective unitary_formula {$$ = P_BUILD("unary_formula", $1, $2, 0, 0, 0, 0, 0, 0, 0, 0);} ; unary_connective : TILDE {$$ = P_BUILD("unary_connective", P_TOKEN("TILDE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----CNF formulae (variables implicitly universally quantified) */ cnf_formula : LPAREN disjunction RPAREN {$$ = P_BUILD("cnf_formula", P_TOKEN("LPAREN ", $1), $2, P_TOKEN("RPAREN ", $3), 0, 0, 0, 0, 0, 0, 0); tptp_ff = 0;} | disjunction {$$ = P_BUILD("cnf_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0); tptp_ff = 0;} ; disjunction : literal {$$ = P_BUILD("disjunction", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | literal VLINE disjunction {$$ = P_BUILD("disjunction", $1, P_TOKEN("VLINE ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; literal : atomic_formula {$$ = P_BUILD("literal", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | TILDE atomic_formula {$$ = P_BUILD("literal", P_TOKEN("TILDE ", $1), $2, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Atoms ( predicate is not used currently) */ atomic_formula : plain_atom {$$ = P_BUILD("atomic_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | defined_atom {$$ = P_BUILD("atomic_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | system_atom {$$ = P_BUILD("atomic_formula", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; plain_atom : plain_term {$$ = P_BUILD("plain_atom", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----A plain_atom looks like a plain_term , but really we mean */ /*---- plain_atom ::= proposition | predicate ( arguments ) */ /*---- proposition ::= atomic_word */ /*---- predicate ::= atomic_word */ /*----Using plain_term removes a reduce/reduce ambiguity in lex/yacc. */ arguments : term {$$ = P_BUILD("arguments", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | term COMMA arguments {$$ = P_BUILD("arguments", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; defined_atom : TOK_TRUE {$$ = P_BUILD("defined_atom", P_TOKEN("TOK_TRUE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | TOK_FALSE {$$ = P_BUILD("defined_atom", P_TOKEN("TOK_FALSE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | term EQUALS term {$$ = P_BUILD("defined_atom", $1, P_TOKEN("EQUALS ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} | term NEQUALS term {$$ = P_BUILD("defined_atom", $1, P_TOKEN("NEQUALS ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; /*----Some systems still interprete equal/2 as equality. The use of equal/2 */ /*----for other purposes is therefore discouraged. Please refrain from either */ /*----use. Use infix '=' for equality. Note: term != term is equivalent */ /*----to ~ term = term */ /*----More defined atoms may be added in the future. */ system_atom : system_term {$$ = P_BUILD("system_atom", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*---- system_atom s are used for evaluable predicates that are available */ /*----in particular tools. The predicate names are not controlled by the */ /*----TPTP syntax, so use with due care. The same is true for system_term s. */ /*----Terms */ term : function_term {$$ = P_BUILD("term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | variable {$$ = P_BUILD("term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; function_term : plain_term {$$ = P_BUILD("function_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | defined_term {$$ = P_BUILD("function_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | system_term {$$ = P_BUILD("function_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; plain_term : constant {$$ = P_BUILD("plain_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | functor LPAREN arguments RPAREN {$$ = P_BUILD("plain_term", $1, P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; constant : atomic_word {$$ = P_BUILD("constant", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; functor : atomic_word {$$ = P_BUILD("functor", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*---- numbers s and distinct_object s are always interpreted as themselves */ defined_term : number {$$ = P_BUILD("defined_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | distinct_object {$$ = P_BUILD("defined_term", P_TOKEN("distinct_object ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; system_term : system_constant {$$ = P_BUILD("system_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | system_functor LPAREN arguments RPAREN {$$ = P_BUILD("system_term", $1, P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; system_functor : atomic_system_word {$$ = P_BUILD("system_functor", P_TOKEN("atomic_system_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; system_constant : atomic_system_word {$$ = P_BUILD("system_constant", P_TOKEN("atomic_system_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; variable : upper_word {$$ = P_BUILD("variable", P_TOKEN("upper_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Formula sources */ source : general_term {$$ = P_BUILD("source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; source_strict : dag_source {$$ = P_BUILD("source_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | internal_source {$$ = P_BUILD("source_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | external_source {$$ = P_BUILD("source_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Only a dag_source can be a name , i.e., derived formulae can be */ /*----identified by a name or an inference_record */ dag_source : name {$$ = P_BUILD("dag_source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | inference_record {$$ = P_BUILD("dag_source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; inference_record : INFERENCE LPAREN inference_rule COMMA useful_info COMMA LBRKT parent_info_list RBRKT RPAREN {$$ = P_BUILD("inference_record", P_TOKEN("INFERENCE ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("COMMA ", $4), $5, P_TOKEN("COMMA ", $6), P_TOKEN("LBRKT ", $7), $8, P_TOKEN("RBRKT ", $9), P_TOKEN("RPAREN ", $10));} ; inference_rule : atomic_word {$$ = P_BUILD("inference_rule", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Examples are deduction | modus_tollens | modus_ponens | rewrite | */ /* resolution | paramodulation | factorization | */ /* cnf_conversion | cnf_refutation | ... */ parent_info_list : parent_info {$$ = P_BUILD("parent_info_list", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | parent_info COMMA parent_info_list {$$ = P_BUILD("parent_info_list", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; parent_info : source parent_details {$$ = P_BUILD("parent_info", $1, $2, 0, 0, 0, 0, 0, 0, 0, 0);} ; theory : THEORY LPAREN theory_name RPAREN {$$ = P_BUILD("theory", P_TOKEN("THEORY ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; theory_name : lower_word {$$ = P_BUILD("theory_name", P_TOKEN("lower_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; theory_name_strict : EQUALITY {$$ = P_BUILD("theory_name_strict", P_TOKEN("EQUALITY ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | AC {$$ = P_BUILD("theory_name_strict", P_TOKEN("AC ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----More theory names may be added in the future. */ parent_details : COLON atomic_word {$$ = P_BUILD("parent_details", P_TOKEN("COLON ", $1), $2, 0, 0, 0, 0, 0, 0, 0, 0);} | null {$$ = P_BUILD("parent_details", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; internal_source : INTRODUCED LPAREN intro_type intro_info RPAREN {$$ = P_BUILD("internal_source", P_TOKEN("INTRODUCED ", $1), P_TOKEN("LPAREN ", $2), $3, $4, P_TOKEN("RPAREN ", $5), 0, 0, 0, 0, 0);} ; intro_type : lower_word {$$ = P_BUILD("intro_type", P_TOKEN("lower_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; intro_type_strict : DEFINITION {$$ = P_BUILD("intro_type_strict", P_TOKEN("DEFINITION ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | AXIOM_OF_CHOICE {$$ = P_BUILD("intro_type_strict", P_TOKEN("AXIOM_OF_CHOICE ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | TAUTOLOGY {$$ = P_BUILD("intro_type_strict", P_TOKEN("TAUTOLOGY ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----This should be used to record the symbol being defined, or the function */ /*----for the axiom of choice */ intro_info : COMMA useful_info {$$ = P_BUILD("intro_info", P_TOKEN("COMMA ", $1), $2, 0, 0, 0, 0, 0, 0, 0, 0);} | null {$$ = P_BUILD("intro_info", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; external_source : file_source {$$ = P_BUILD("external_source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | creator_source {$$ = P_BUILD("external_source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | theory {$$ = P_BUILD("external_source", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; file_source : TOK_FILE LPAREN file_name COMMA file_node_name RPAREN {$$ = P_BUILD("file_source", P_TOKEN("TOK_FILE ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("COMMA ", $4), $5, P_TOKEN("RPAREN ", $6), 0, 0, 0, 0);} ; file_name : atomic_word {$$ = P_BUILD("file_name", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; file_node_name : name {$$ = P_BUILD("file_node_name", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; creator_source : CREATOR LPAREN creator_name creator_info RPAREN {$$ = P_BUILD("creator_source", P_TOKEN("CREATOR ", $1), P_TOKEN("LPAREN ", $2), $3, $4, P_TOKEN("RPAREN ", $5), 0, 0, 0, 0, 0);} ; creator_name : atomic_word {$$ = P_BUILD("creator_name", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; creator_info : COMMA useful_info {$$ = P_BUILD("creator_info", P_TOKEN("COMMA ", $1), $2, 0, 0, 0, 0, 0, 0, 0, 0);} | null {$$ = P_BUILD("creator_info", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Useful info fields */ useful_info : LBRKT RBRKT {$$ = P_BUILD("useful_info", P_TOKEN("LBRKT ", $1), P_TOKEN("RBRKT ", $2), 0, 0, 0, 0, 0, 0, 0, 0);} | LBRKT info_items RBRKT {$$ = P_BUILD("useful_info", P_TOKEN("LBRKT ", $1), $2, P_TOKEN("RBRKT ", $3), 0, 0, 0, 0, 0, 0, 0);} ; info_items : info_item {$$ = P_BUILD("info_items", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | info_item COMMA info_items {$$ = P_BUILD("info_items", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; info_item : general_term {$$ = P_BUILD("info_item", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; info_item_strict : formula_item {$$ = P_BUILD("info_item_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | inference_item {$$ = P_BUILD("info_item_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | general_function {$$ = P_BUILD("info_item_strict", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----Useful info for formula records */ formula_item : description_item {$$ = P_BUILD("formula_item", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | iquote_item {$$ = P_BUILD("formula_item", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; description_item : DESCRIPTION LPAREN atomic_word RPAREN {$$ = P_BUILD("description_item", P_TOKEN("DESCRIPTION ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; iquote_item : IQUOTE LPAREN atomic_word RPAREN {$$ = P_BUILD("iquote_item", P_TOKEN("IQUOTE ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; /*----Useful info for inference records */ inference_item : inference_status {$$ = P_BUILD("inference_item", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | refutation {$$ = P_BUILD("inference_item", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; inference_status : STATUS LPAREN status_value RPAREN {$$ = P_BUILD("inference_status", P_TOKEN("STATUS ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; /*----These are the status values from the SZS ontology */ status_value : lower_word {$$ = P_BUILD("status_value", P_TOKEN("lower_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; status_value_strict : TAU {$$ = P_BUILD("status_value_strict", P_TOKEN("TAU ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | TAC {$$ = P_BUILD("status_value_strict", P_TOKEN("TAC ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | EQV {$$ = P_BUILD("status_value_strict", P_TOKEN("EQV ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | THM {$$ = P_BUILD("status_value_strict", P_TOKEN("THM ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | SAT {$$ = P_BUILD("status_value_strict", P_TOKEN("SAT ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CAX {$$ = P_BUILD("status_value_strict", P_TOKEN("CAX ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | NOC {$$ = P_BUILD("status_value_strict", P_TOKEN("NOC ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CSA {$$ = P_BUILD("status_value_strict", P_TOKEN("CSA ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CTH {$$ = P_BUILD("status_value_strict", P_TOKEN("CTH ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CEQ {$$ = P_BUILD("status_value_strict", P_TOKEN("CEQ ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | UNC {$$ = P_BUILD("status_value_strict", P_TOKEN("UNC ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | UNS {$$ = P_BUILD("status_value_strict", P_TOKEN("UNS ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | SAB {$$ = P_BUILD("status_value_strict", P_TOKEN("SAB ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | SAM {$$ = P_BUILD("status_value_strict", P_TOKEN("SAM ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | SAR {$$ = P_BUILD("status_value_strict", P_TOKEN("SAR ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | SAP {$$ = P_BUILD("status_value_strict", P_TOKEN("SAP ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CSP {$$ = P_BUILD("status_value_strict", P_TOKEN("CSP ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CSR {$$ = P_BUILD("status_value_strict", P_TOKEN("CSR ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CSM {$$ = P_BUILD("status_value_strict", P_TOKEN("CSM ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | CSB {$$ = P_BUILD("status_value_strict", P_TOKEN("CSB ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; inference_info : inference_rule LPAREN atomic_word COMMA general_list RPAREN {$$ = P_BUILD("inference_info", $1, P_TOKEN("LPAREN ", $2), $3, P_TOKEN("COMMA ", $4), $5, P_TOKEN("RPAREN ", $6), 0, 0, 0, 0);} ; refutation : REFUTATION LPAREN file_source RPAREN {$$ = P_BUILD("refutation", P_TOKEN("REFUTATION ", $1), P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; /*----Useful info for creators is just general_function */ /*----Include directives */ include : INCLUDE LPAREN file_name formula_selection RPAREN PERIOD {$$ = P_BUILD("include", P_TOKEN("INCLUDE ", $1), P_TOKEN("LPAREN ", $2), $3, $4, P_TOKEN("RPAREN ", $5), P_TOKEN("PERIOD ", $6), 0, 0, 0, 0);} ; formula_selection : null {$$ = P_BUILD("formula_selection", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | COMMA LBRKT name_list RBRKT {$$ = P_BUILD("formula_selection", P_TOKEN("COMMA ", $1), P_TOKEN("LBRKT ", $2), $3, P_TOKEN("RBRKT ", $4), 0, 0, 0, 0, 0, 0);} ; name_list : name {$$ = P_BUILD("name_list", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | name COMMA name_list {$$ = P_BUILD("name_list", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; /*----General purpose */ general_term : general_function {$$ = P_BUILD("general_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | general_list {$$ = P_BUILD("general_term", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; general_list : LBRKT RBRKT {$$ = P_BUILD("general_list", P_TOKEN("LBRKT ", $1), P_TOKEN("RBRKT ", $2), 0, 0, 0, 0, 0, 0, 0, 0);} | LBRKT general_arguments RBRKT {$$ = P_BUILD("general_list", P_TOKEN("LBRKT ", $1), $2, P_TOKEN("RBRKT ", $3), 0, 0, 0, 0, 0, 0, 0);} ; general_function : constant {$$ = P_BUILD("general_function", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | functor LPAREN general_arguments RPAREN {$$ = P_BUILD("general_function", $1, P_TOKEN("LPAREN ", $2), $3, P_TOKEN("RPAREN ", $4), 0, 0, 0, 0, 0, 0);} ; general_arguments : general_term {$$ = P_BUILD("general_arguments", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | general_term COMMA general_arguments {$$ = P_BUILD("general_arguments", $1, P_TOKEN("COMMA ", $2), $3, 0, 0, 0, 0, 0, 0, 0);} ; /*----The following are reserved name s: unknown file inference creator */ name : atomic_word {$$ = P_BUILD("name", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} | unsigned_integer {$$ = P_BUILD("name", P_TOKEN("unsigned_integer ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; atomic_word : lower_word {$$ = P_BUILD("atomic_word", P_TOKEN("lower_word ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | single_quoted {$$ = P_BUILD("atomic_word", P_TOKEN("single_quoted ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; null : {$$ = P_BUILD("null", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*----All numbers are implicitly distinct */ number : real {$$ = P_BUILD("number", P_TOKEN("real ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | integer {$$ = P_BUILD("number", $1, 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; integer : signed_integer {$$ = P_BUILD("integer", P_TOKEN("signed_integer ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} | unsigned_integer {$$ = P_BUILD("integer", P_TOKEN("unsigned_integer ", $1), 0, 0, 0, 0, 0, 0, 0, 0, 0);} ; /*------------------------------------------------------------------------------ */ /*----Rules from here on down are for building tokens in the lexer. */ /*----System Comments are used for system specific annotation of anything. */ /*----They look like comments (see next), so by default they are discarded. */ /*----However, a wily user of the syntax can notice the $$ and store/extract */ /*----information from the "comment". */ /*----System specific annotations should begin $$, then identify the system, */ /*----followed by a :, e.g., /*$$Otter 3.3: Demodulator */ /*----Comments. These may be retained for non-logical purposes. Comments */ /*----can occur only between annotated formulae (see TPTP_input ), but */ /*----it seems likely that people will put them elsewhere and simply */ /*----strip them before tokenising. */ /*----A string that matches both system_comment and comment should be */ /*----recognized as system_comment . */ /*----\ is used as the escape character for ' and \, i.e., \' is a quote and */ /*----\\ is a backslash. For input and output in TPTP syntax the \ is printed. */ /*----All distinct_object are implicitly distinct. */ /*----\ is used as the escape character for " and \, i.e., \" is a quote and */ /*----\\ is a backslash. For input and output in TPTP syntax the \ is printed. */