1 
2 /*
3  * File TPTP.hpp.
4  *
5  * This file is part of the source code of the software program
6  * Vampire. It is protected by applicable
7  * copyright laws.
8  *
9  * This source code is distributed under the licence found here
10  * https://vprover.github.io/license.html
11  * and in the source directory
12  *
13  * In summary, you are allowed to use Vampire for non-commercial
14  * purposes but not allowed to distribute, modify, copy, create derivatives,
15  * or use in competitions.
16  * For other uses of Vampire please contact developers for a different
17  * licence, which we will make an effort to provide.
18  */
19 /**
20  * @file Parse/TPTP.hpp
21  * Defines class TPTP for parsing TPTP files
22  *
23  * @since 08/04/2011 Manchester
24  */
25 
26 #ifndef __Parser_TPTP__
27 #define __Parser_TPTP__
28 
29 #include <iostream>
30 
31 #include "Lib/Array.hpp"
32 #include "Lib/Set.hpp"
33 #include "Lib/Stack.hpp"
34 #include "Lib/Exception.hpp"
35 #include "Lib/IntNameTable.hpp"
36 
37 #include "Kernel/Formula.hpp"
38 #include "Kernel/Unit.hpp"
39 #include "Kernel/Theory.hpp"
40 #include "Kernel/Inference.hpp"
41 
42 //#define DEBUG_SHOW_STATE
43 
44 using namespace std;
45 using namespace Lib;
46 using namespace Kernel;
47 
48 namespace Kernel {
49   class Clause;
50 };
51 
52 namespace Parse {
53 
54 class TPTP;
55 
56 /**
57  * Implements a TPTP parser
58  * @since 08/04/2011 Manchester
59  */
60 class TPTP
61 {
62 public:
63   /** Token types */
64   enum Tag {
65     /** end of file */
66     T_EOF,
67     /** name, identifier beginning with a lower-case letter */
68     T_NAME,
69     /** variable name, identifier beginning with an upper-case letter */
70     T_VAR,
71     /** '(' */
72     T_LPAR,
73     /** ')' */
74     T_RPAR,
75     /** '[' */
76     T_LBRA,
77     /** ']' */
78     T_RBRA,
79     /** ',' */
80     T_COMMA,
81     /** ':' */
82     T_COLON,
83     /** '~' */
84     T_NOT,
85     /** '&' */
86     T_AND,
87     /** '=' */
88     T_EQUAL,
89     /** string */
90     T_STRING,
91     /** inequality */
92     T_NEQ,
93     /** universal quantifier */
94     T_FORALL,
95     /** existential quantifier */
96     T_EXISTS,
97     /** type universal quantifier */
98     T_PI,
99     /** type existential quantifier */
100     T_SIGMA,
101     /** implication */
102     T_IMPLY,
103     /** exclusive or */
104     T_XOR,
105     /** equivalence */
106     T_IFF,
107     /** reverse implication */
108     T_REVERSE_IMP,
109     /** dot */
110     T_DOT,
111     /** real number */
112     T_REAL,
113     /** rational number */
114     T_RAT,
115     /** integer */
116     T_INT,
117     /** connective or */
118     T_OR,
119     /** := */
120     T_ASS,
121     /** lambda operator */
122     T_LAMBDA,
123     /** (higher-order) application */
124     T_APP,
125     /** star (product type) */
126     T_STAR,
127     /** union type? */
128     T_UNION,
129     /** arrow type */
130     T_ARROW,
131     /** Subtype */
132     T_SUBTYPE,
133     /** Geoff's invention, one connective for the price of two */
134     T_NOT_OR,
135     /** Geoff's invention, one connective for the price of two */
136     T_NOT_AND,
137     /** sequent */
138     T_SEQUENT,
139     /** !> */
140     T_THF_QUANT_ALL,
141     /** ?* */
142     T_THF_QUANT_SOME,
143     /** some THF quantifier */
144     T_APP_PLUS,
145     /** some THF quantifier */
146     T_APP_MINUS,
147     /** $true */
148     T_TRUE,
149     /** $false */
150     T_FALSE,
151     /** $tType */
152     T_TTYPE,
153     /** $o */
154     T_BOOL_TYPE,
155     /** $i */
156     T_DEFAULT_TYPE,
157     /** $int */
158     T_INTEGER_TYPE,
159     /** $rat */
160     T_RATIONAL_TYPE,
161     /** $real */
162     T_REAL_TYPE,
163     /** $tuple type */
164     T_TUPLE,
165     /** theory functions */
166     T_THEORY_FUNCTION,
167     /** theory sorts */
168     T_THEORY_SORT,
169     /** $fot, probably useless */
170     T_FOT,
171     /** $fof, probably useless */
172     T_FOF,
173     /** $tff, probably useless */
174     T_TFF,
175     /** $thf, probably useless */
176     T_THF,
177     /** anything that begins with $$ */
178     T_DOLLARS,
179     /** $ite: FOOL level-polymorphic if-then-else */
180     T_ITE,
181     /** $let: FOOL level-polymorphic let-in */
182     T_LET
183   };
184 
185   /** parser state, numbers are just temporarily for debugging */
186   enum State {
187     /** list of units */
188     UNIT_LIST,
189     /** cnf() declaration */
190     CNF,
191     /** fof() declaration */
192     FOF,
193     /** vampire() declaration */
194     VAMPIRE,
195     /** read formula */
196     FORMULA,
197     /** process end of fof() declaration */
198     END_FOF,
199     /** read a simple formula */
200     SIMPLE_FORMULA,
201     /** build formula from a connective and one or more formulas */
202     END_FORMULA,
203     /** read a formula that whould be put inside a term */
204     FORMULA_INSIDE_TERM,
205     /** */
206     TERM_INFIX,
207     /** wrap built formula inside a term */
208     END_FORMULA_INSIDE_TERM,
209     /** make built boolean term a formula */
210     END_TERM_AS_FORMULA,
211     /** read a variable list (for a quantifier) */
212     VAR_LIST,
213     /** read a function application */
214     FUN_APP,
215     /** process application of = or != to an atom */
216     FORMULA_INFIX,
217     /** read arguments */
218     ARGS,
219     /** read term */
220     TERM,
221     /** read arguments after a term */
222     END_TERM,
223     /** read a single token and do nothing */
224     TAG,
225     /** include directive */
226     INCLUDE,
227     /** after the equality */
228     END_EQ,
229     /** tff declaration */
230     TFF,
231     /** THF declaration */
232     THF,
233     /** read type declaration */
234     TYPE,
235     /** after a top-level type declaration */
236     END_TFF,
237     /** after a type declaration */
238     END_TYPE,
239     /** simple type */
240     SIMPLE_TYPE,
241     /** unbinding previously quantified variables */
242     UNBIND_VARIABLES,
243     /** end of an if-then-else expression */
244     END_ITE,
245     /** read tuple */
246     END_TUPLE,
247     /** check the end of arguments */
248     END_ARGS,
249     /** middle of equality */
250     MID_EQ,
251     /** end of $let expression */
252     END_LET,
253     /** a type signature in a let expression */
254     LET_TYPE,
255     /** end of let type signature */
256     END_LET_TYPES,
257     /** start of a binding inside $let */
258     DEFINITION,
259     MID_DEFINITION,
260     /** end of a definition inside $let */
261     END_DEFINITION,
262     /** start of a definition of a function or predicate symbol */
263     SYMBOL_DEFINITION,
264     /** start of tuple definition inside $let */
265     TUPLE_DEFINITION,
266     /** end of a theory function */
267     END_THEORY_FUNCTION
268   };
269 
270   /** token */
271   struct Token {
272     /** token type */
273     Tag tag;
274     /** position of the beginning of this token */
275     int start;
276     /** content */
277     vstring content;
278     vstring toString() const;
279   };
280 
281   /**
282    * Implements lexer and parser exceptions.
283    */
284   class ParseErrorException
285     : public ::Exception
286   {
287   public:
ParseErrorException(vstring message,unsigned ln)288     ParseErrorException(vstring message,unsigned ln) : _message(message), _ln(ln) {}
289     ParseErrorException(vstring message,Token& tok,unsigned ln);
290     ParseErrorException(vstring message,int position,unsigned ln);
291     void cry(ostream&);
~ParseErrorException()292     ~ParseErrorException() {}
293   protected:
294     vstring _message;
295     unsigned _ln;
296   }; // TPTP::ParseErrorException
297   friend class Exception;
298 
299 #define PARSE_ERROR(msg,tok) \
300   throw ParseErrorException(msg,tok,_lineNumber)
301 
302   TPTP(istream& in);
303   ~TPTP();
304   void parse();
305   static UnitList* parse(istream& str);
306   /** Return the list of parsed units */
units()307   inline UnitList* units() { return _units.list(); }
308   /**
309    * Return true if there was a conjecture formula among the parsed units
310    *
311    * The purpose of this information is that when we report success in the
312    * SZS ontology, we decide whether to output "Theorem" or "Unsatisfiable"
313    * based on this value.
314    */
containsConjecture() const315   bool containsConjecture() const { return _containsConjecture; }
316   void addForbiddenInclude(vstring file);
317   static bool findAxiomName(const Unit* unit, vstring& result);
318   //this function is used also by the API
319   static void assignAxiomName(const Unit* unit, vstring& name);
lineNumber()320   unsigned lineNumber(){ return _lineNumber; }
321 private:
322   /** Return the input string of characters */
input()323   const char* input() { return _chars.content(); }
324 
325   enum TypeTag {
326     TT_ATOMIC,
327     TT_PRODUCT,
328     TT_ARROW
329   };
330 
331   /**
332    * Class of types. Should be removed when the Vampire type system is
333    * improved.
334    * @since 14/07/2011 Manchester
335    */
336   class Type {
337   public:
338     CLASS_NAME(Type);
339     USE_ALLOCATOR(Type);
Type(TypeTag tag)340     explicit Type(TypeTag tag) : _tag(tag) {}
341     /** return the kind of this sort */
tag() const342     TypeTag tag() const {return _tag;}
343   protected:
344     /** kind of this type */
345     TypeTag _tag;
346   };
347 
348   /** An atomic type is simply a sort */
349   class AtomicType
350     : public Type
351   {
352   public:
353     CLASS_NAME(AtomicType);
354     USE_ALLOCATOR(AtomicType);
AtomicType(unsigned sortNumber)355     explicit AtomicType(unsigned sortNumber)
356       : Type(TT_ATOMIC), _sortNumber(sortNumber)
357     {}
358     /** return the sort number */
sortNumber() const359     unsigned sortNumber() const {return _sortNumber;}
360   private:
361     /** the sort identified by its number in the signature */
362     unsigned _sortNumber;
363   }; // AtomicType
364 
365   /** Arrow type */
366   class ArrowType
367     : public Type
368   {
369   public:
370     CLASS_NAME(ArrowType);
371     USE_ALLOCATOR(ArrowType);
ArrowType(Type * lhs,Type * rhs)372     ArrowType(Type* lhs,Type* rhs)
373       : Type(TT_ARROW), _lhs(lhs), _rhs(rhs)
374     {}
375     /** the argument type */
argumentType() const376     Type* argumentType() const {return _lhs;}
377     /** the return type */
returnType() const378     Type* returnType() const {return _rhs;}
379   private:
380     /** the argument type */
381     Type* _lhs;
382     /** the return type */
383     Type* _rhs;
384   }; // ArrowType
385 
386   /** Product type. It now only uses a product of two types, which might be
387    * wrong for higher-order logic, yet appropriate for parsing first-order
388    * types.
389    */
390   class ProductType
391     : public Type
392   {
393   public:
394     CLASS_NAME(ProductType);
395     USE_ALLOCATOR(ProductType);
ProductType(Type * lhs,Type * rhs)396     ProductType(Type* lhs,Type* rhs)
397       : Type(TT_PRODUCT), _lhs(lhs), _rhs(rhs)
398     {}
399     /** the left hand side type */
lhs() const400     Type* lhs() const {return _lhs;}
401     /** the right hand side type */
rhs() const402     Type* rhs() const {return _rhs;}
403   private:
404     /** the argument type */
405     Type* _lhs;
406     /** the return type */
407     Type* _rhs;
408   }; // ProductType
409 
410   /**
411    * Class that allows to create a list initially by pushing elements
412    * at the end of it.
413    * @since 10/05/2007 Manchester, updated from List::FIFO
414    */
415   class UnitStack {
416   public:
417     /** constructor */
UnitStack()418     inline explicit UnitStack()
419       : _initial(0),
420 	_last(&_initial)
421     {}
422 
423     /** add element at the end of the original list */
push(Unit * u)424     inline void push(Unit* u)
425     {
426       UnitList* newList = new UnitList(u);
427       *_last = newList;
428       _last = reinterpret_cast<UnitList**>(&newList->tailReference());
429     }
430 
431     /** Return the collected list */
list()432     UnitList* list() { return _initial; }
433 
434   private:
435     /** reference to the initial element */
436     UnitList* _initial;
437     /** last element */
438     UnitList** _last;
439   }; // class UnitStack
440 
441   enum TheorySort {
442     /** $array theoy */
443     TS_ARRAY,
444   };
findTheorySort(const vstring name,TheorySort & ts)445   static bool findTheorySort(const vstring name, TheorySort &ts) {
446     static const vstring theorySortNames[] = {
447       "$array"
448     };
449     static const unsigned theorySorts = sizeof(theorySortNames)/sizeof(vstring);
450     for (unsigned sort = 0; sort < theorySorts; sort++) {
451       if (theorySortNames[sort] == name) {
452         ts = static_cast<TheorySort>(sort);
453         return true;
454       }
455     }
456     return false;
457   }
isTheorySort(const vstring name)458   static bool isTheorySort(const vstring name) {
459     static TheorySort dummy;
460     return findTheorySort(name, dummy);
461   }
getTheorySort(const Token tok)462   static TheorySort getTheorySort(const Token tok) {
463     ASS_REP(tok.tag == T_THEORY_SORT, tok.content);
464     TheorySort ts;
465     if (!findTheorySort(tok.content, ts)) {
466       ASSERTION_VIOLATION_REP(tok.content);
467     }
468     return ts;
469   }
470 
471   enum TheoryFunction {
472     /** $array theory */
473     TF_SELECT, TF_STORE
474   };
findTheoryFunction(const vstring name,TheoryFunction & tf)475   static bool findTheoryFunction(const vstring name, TheoryFunction &tf) {
476     static const vstring theoryFunctionNames[] = {
477       "$select", "$store"
478     };
479     static const unsigned theoryFunctions = sizeof(theoryFunctionNames)/sizeof(vstring);
480     for (unsigned fun = 0; fun < theoryFunctions; fun++) {
481       if (theoryFunctionNames[fun] == name) {
482         tf = static_cast<TheoryFunction>(fun);
483         return true;
484       }
485     }
486     return false;
487   }
isTheoryFunction(const vstring name)488   static bool isTheoryFunction(const vstring name) {
489     static TheoryFunction dummy;
490     return findTheoryFunction(name, dummy);
491   }
getTheoryFunction(const Token tok)492   static TheoryFunction getTheoryFunction(const Token tok) {
493     ASS_REP(tok.tag == T_THEORY_FUNCTION, tok.content);
494     TheoryFunction tf;
495     if (!findTheoryFunction(tok.content, tf)) {
496       ASSERTION_VIOLATION_REP(tok.content);
497     }
498     return tf;
499   }
500 
501   /** true if the input contains a conjecture */
502   bool _containsConjecture;
503   /** Allowed names of formulas.
504    * If non-null, ignore formulas not included in _allowedNames.
505    * This is to support the feature formula_selection of the include
506    * directive of the TPTP format.
507  */
508   Set<vstring>* _allowedNames;
509   /** stacks of allowed names when include is used */
510   Stack<Set<vstring>*> _allowedNamesStack;
511   /** set of files whose inclusion should be ignored */
512   Set<vstring> _forbiddenIncludes;
513   /** the input stream */
514   istream* _in;
515   /** in the case include() is used, previous streams will be saved here */
516   Stack<istream*> _inputs;
517   /** the current include directory */
518   vstring _includeDirectory;
519   /** in the case include() is used, previous sequence of directories will be
520    * saved here, this is required since TPTP requires the directory to be
521    * relative to the "current directory, that is, the directory used by the last include()
522    */
523   Stack<vstring> _includeDirectories;
524   /** input characters */
525   Array<char> _chars;
526   /** position in the input stream of the 0th character in _chars[] */
527   int _gpos;
528   /** the position beyond the last read characters */
529   int _cend;
530   /** tokens currently at work */
531   Array<Token> _tokens;
532   /** the position beyond the last processed token */
533   int _tend;
534   /** line number */
535   unsigned _lineNumber;
536   /** The stack of units read */
537   UnitStack _units;
538   /** stack of unprocessed states */
539   Stack<State> _states;
540   /** input type of the last read unit */ // it must be int since -1 can be used as a value
541   UnitInputType _lastInputType;
542   /** true if the last read unit is a question */
543   bool _isQuestion;
544   /** true if the last read unit is fof() or cnf() due to a subtle difference
545    * between fof() and tff() in treating numeric constants */
546   bool _isFof;
547   /** various strings saved during parsing */
548   Stack<vstring> _strings;
549   /** various connectives saved during parsing */ // they must be int, since non-existing value -1 can be used
550   Stack<int> _connectives;
551   /** various boolean values saved during parsing */
552   Stack<bool> _bools;
553   /** various integer values saved during parsing */
554   Stack<int> _ints;
555   /** variable lists for building formulas */
556   Stack<Formula::VarList*> _varLists;
557   /** sort lists for building formulas */
558   Stack<Formula::SortList*> _sortLists;
559   /** variable lists for binding variables */
560   Stack<Formula::VarList*> _bindLists;
561   /** various tokens to consume */
562   Stack<Tag> _tags;
563   /** various formulas */
564   Stack<Formula*> _formulas;
565   /** various literals */
566   Stack<Literal*> _literals;
567   /** term lists */
568   Stack<TermList> _termLists;
569   /** name table for variable names */
570   IntNameTable _vars;
571   /** parsed types */
572   Stack<Type*> _types;
573   /** various type tags saved during parsing */
574   Stack<TypeTag> _typeTags;
575   typedef List<unsigned> SortList;
576   /**  */
577   Stack<TheoryFunction> _theoryFunctions;
578   /** bindings of variables to sorts */
579   Map<int,SortList*> _variableSorts;
580   /** overflown arithmetical constants for which uninterpreted constants are introduced */
581   Set<vstring> _overflow;
582   /** current color, if the input contains colors */
583   Color _currentColor;
584 
585   /** a function name and arity */
586   typedef pair<vstring, unsigned> LetSymbolName;
587 
588   /** a symbol number with a predicate/function flag */
589   typedef pair<unsigned, bool> LetSymbolReference;
590   #define SYMBOL(ref) (ref.first)
591   #define IS_PREDICATE(ref) (ref.second)
592 
593   /** a definition of a function symbol, defined in $let */
594   typedef pair<LetSymbolName, LetSymbolReference> LetSymbol;
595 
596   /** a scope of function definitions */
597   typedef Stack<LetSymbol> LetSymbols;
598 
599   /** a stack of scopes */
600   Stack<LetSymbols> _letSymbols;
601   Stack<LetSymbols> _letTypedSymbols;
602 
603   /** finds if the symbol has been defined in an enclosing $let */
604   bool findLetSymbol(LetSymbolName symbolName, LetSymbolReference& symbolReference);
605   bool findLetSymbol(LetSymbolName symbolName, LetSymbols scope, LetSymbolReference& symbolReference);
606 
607   typedef Stack<LetSymbolReference> LetDefinitions;
608   Stack<LetDefinitions> _letDefinitions;
609 
610   /** model definition formula */
611   bool _modelDefinition;
612 
613   // A hack to hard-code the precedence of = and != higher than connectives
614   // This is needed for implementation of FOOL
615   unsigned _insideEqualityArgument;
616 
617   /**
618    * Get the next characters at the position pos.
619    */
getChar(int pos)620   inline char getChar(int pos)
621   {
622     CALL("TPTP::getChar");
623 
624     while (_cend <= pos) {
625       int c = _in->get();
626       //      if (c == -1) { cout << "<EOF>"; } else {cout << char(c);}
627       _chars[_cend++] = c == -1 ? 0 : c;
628     }
629     return _chars[pos];
630   } // getChar
631 
632   /**
633    * Shift characters in the buffer by n positions left.
634    */
shiftChars(int n)635   inline void shiftChars(int n)
636   {
637     CALL("TPTP::shiftChars");
638     ASS(n > 0);
639     ASS(n <= _cend);
640 
641     for (int i = 0;i < _cend-n;i++) {
642       _chars[i] = _chars[n+i];
643     }
644     _cend -= n;
645     _gpos += n;
646   } // shiftChars
647 
648   /**
649    * Reset the character buffer.
650    * @since 10/04/2011 Manchester
651    */
resetChars()652   inline void resetChars()
653   {
654     _gpos += _cend;
655     _cend = 0;
656   } // resetChars
657 
658   /**
659    * Get the token at the position pos.
660    */
getTok(int pos)661   inline Token& getTok(int pos)
662   {
663     CALL("TPTP::getTok");
664 
665     while (_tend <= pos) {
666       Token& tok = _tokens[_tend++];
667       readToken(tok);
668     }
669     return _tokens[pos];
670   } // getTok
671 
672   /**
673    * Shift tokens in the buffer by n positions left.
674    */
shiftToks(int n)675   inline void shiftToks(int n)
676   {
677     CALL("TPTP::shiftToks");
678 
679     ASS(n > 0);
680     ASS(n <= _tend);
681 
682     for (int i = 0;i < _tend-n;i++) {
683       _tokens[i] = _tokens[n+i];
684     }
685     _tend -= n;
686   } // shiftToks
687 
688   /**
689    * Reset the character buffer.
690    * @since 10/04/2011 Manchester
691    */
resetToks()692   inline void resetToks()
693   {
694     _tend = 0;
695   } // resetToks
696 
697   // lexer functions
698   bool readToken(Token& t);
699   void skipWhiteSpacesAndComments();
700   void readName(Token&);
701   void readReserved(Token&);
702   void readString(Token&);
703   void readAtom(Token&);
704   Tag readNumber(Token&);
705   int decimal(int pos);
706   int positiveDecimal(int pos);
707   static vstring toString(Tag);
708 
709   // parser functions
710   static Formula* makeJunction(Connective c,Formula* lhs,Formula* rhs);
711   void unitList();
712   void fof(bool fo);
713   void tff();
714   void vampire();
715   void consumeToken(Tag);
716   vstring name();
717   void formula();
718   void funApp();
719   void simpleFormula();
720   void simpleType();
721   void args();
722   void varList();
723   void symbolDefinition();
724   void tupleDefinition();
725   void term();
726   void termInfix();
727   void endTerm();
728   void endArgs();
729   Literal* createEquality(bool polarity,TermList& lhs,TermList& rhs);
730   Formula* createPredicateApplication(vstring name,unsigned arity);
731   TermList createFunctionApplication(vstring name,unsigned arity);
732   void endEquality();
733   void midEquality();
734   void formulaInfix();
735   void endFormula();
736   void formulaInsideTerm();
737   void endFormulaInsideTerm();
738   void endTermAsFormula();
739   void endType();
740   void tag();
741   void endFof();
742   void endTff();
743   void include();
744   void type();
745   void endIte();
746   void letType();
747   void endLetTypes();
748   void definition();
749   void midDefinition();
750   void endDefinition();
751   void endLet();
752   void endTheoryFunction();
753   void endTuple();
754   void addTagState(Tag);
755 
756   unsigned readSort();
757   void bindVariable(int var,unsigned sortNumber);
758   void unbindVariables();
759   void skipToRPAR();
760   void skipToRBRA();
761   unsigned addFunction(vstring name,int arity,bool& added,TermList& someArgument);
762   int addPredicate(vstring name,int arity,bool& added,TermList& someArgument);
763   unsigned addOverloadedFunction(vstring name,int arity,int symbolArity,bool& added,TermList& arg,
764 				 Theory::Interpretation integer,Theory::Interpretation rational,
765 				 Theory::Interpretation real);
766   unsigned addOverloadedPredicate(vstring name,int arity,int symbolArity,bool& added,TermList& arg,
767 				  Theory::Interpretation integer,Theory::Interpretation rational,
768 				  Theory::Interpretation real);
769   unsigned sortOf(TermList term);
770   static bool higherPrecedence(int c1,int c2);
771 
772   bool findInterpretedPredicate(vstring name, unsigned arity);
773 
774   OperatorType* constructOperatorType(Type* t);
775 
776 public:
777   // make the tptp routines for dealing with overflown constants available to other parsers
778   static unsigned addIntegerConstant(const vstring&, Set<vstring>& overflow, bool defaultSort);
779   static unsigned addRationalConstant(const vstring&, Set<vstring>& overflow, bool defaultSort);
780   static unsigned addRealConstant(const vstring&, Set<vstring>& overflow, bool defaultSort);
781   static unsigned addUninterpretedConstant(const vstring& name, Set<vstring>& overflow, bool& added);
782 
783   /**
784    * Used to store the contents of the 'source' of an input formula
785    * This is based on the 'file' and 'inference' record description in
786    * http://pages.cs.miami.edu/~tptp/TPTP/QuickGuide/Derivations.html
787    */
788   struct SourceRecord{
789     virtual bool isFile() = 0;
790   };
791   struct FileSourceRecord : SourceRecord {
792     const vstring fileName;
793     const vstring nameInFile;
isFileParse::TPTP::FileSourceRecord794     bool isFile(){ return true; }
FileSourceRecordParse::TPTP::FileSourceRecord795     FileSourceRecord(vstring fN, vstring nF) : fileName(fN), nameInFile(nF) {}
796   };
797   struct InferenceSourceRecord : SourceRecord{
798     const vstring name;
799     Stack<vstring> premises;
isFileParse::TPTP::InferenceSourceRecord800     bool isFile(){ return false; }
InferenceSourceRecordParse::TPTP::InferenceSourceRecord801     InferenceSourceRecord(vstring n) : name(n) {}
802   };
803 
setUnitSourceMap(DHMap<Unit *,SourceRecord * > * m)804   void setUnitSourceMap(DHMap<Unit*,SourceRecord*>* m){
805     _unitSources = m;
806   }
807   SourceRecord* getSource();
808 
setFilterReserved()809   void setFilterReserved(){ _filterReserved=true; }
810 
811 private:
812   DHMap<Unit*,SourceRecord*>* _unitSources;
813 
814   /** This field stores names of input units if the
815    * output_axiom_names option is enabled */
816   static DHMap<unsigned, vstring> _axiomNames;
817 
818   bool _filterReserved;
819   bool _seenConjecture;
820 
821 
822 #if VDEBUG
823   void printStates(vstring extra);
824   void printInts(vstring extra);
825   const char* toString(State s);
826 #endif
827 #ifdef DEBUG_SHOW_STATE
828   void printStacks();
829 #endif
830 }; // class TPTP
831 
832 }
833 
834 #endif
835 
836