Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

q.hpp

Go to the documentation of this file.
00001 
00027 //
00028 // File:         VampireKernel.hpp
00029 // Description:  Vampire kernel interface. 
00030 // Created:      May 19, 2002, Alexandre Riazanov, riazanov@cs.man.ac.uk
00031 //======================================================================
00032 #ifndef VAMPIRE_KERNEL_H
00033 #define VAMPIRE_KERNEL_H
00034 //======================================================================
00035 #include <iostream.h>
00036 #include <fstream.h>
00037 #include "jargon.hpp"
00038 //======================================================================
00039 
00040 class VampireKernel
00041 {
00042  public:
00043   typedef long TermWeightType;
00044   class Options;
00045   class Emergency;
00046   enum TerminationReason
00047   {
00048     UnknownTerminationReason,
00049     RefutationFound,
00050     Satisfiable,
00051     EmptyPassive,
00052     MaxPassive,
00053     MaxActive,
00054     TimeLimitExpired,
00055     AbortedOnAllocationFailure,
00056     AbortedOnExternalInterrupt,
00057     AbortedOnErrorSignal,
00058     AbortedOnError
00059   };
00060   class Subterm;
00061   class Literal;
00062   class Clause;
00063  public:
00064   // Initialisation and destruction
00065   VampireKernel();
00066   ~VampireKernel();
00067   void openSession(const Options& opt);
00068   void closeSession();
00069   void destroy(); // for debugging, mainly for detecting memory leaks
00070 
00071   // Version information
00072   
00073   static float versionNumber();
00074   static const char* versionDescription();
00075 
00076   // Receiving signature information
00077 
00078   void beginInputSignature();  
00079   void endInputSignature();
00080   void registerInputFunction(const char* name,
00081                              ulong arity,
00082                              ulong& id); 
00083 
00084   void registerInputPredicate(const char* name,
00085                               ulong arity,
00086                               bool isAnswer,
00087                               ulong& id); 
00088   
00089   void setSymbolWeightConstPart(ulong symId,const TermWeightType& weight);
00090   void setSymbolPrecedence(ulong symId,long prec); // prec can not be 0
00091   void interpretFunction(const char* inputSymbol,
00092                          ulong arity,
00093                          const char* theory,
00094                          const char* nativeSymbol);
00095   void interpretPredicate(const char* inputSymbol,
00096                           ulong arity,
00097                           const char* theory,
00098                           const char* nativeSymbol);
00099 
00100   // Receiving input clauses
00101   
00102   void beginInputClauses();
00103   void endInputClauses();
00104   
00105   void beginInputClause(ulong clauseNumber,void* origin,bool goal,bool support);
00106   void endInputClause();
00107   
00108   void beginLiteral(bool positive,ulong predicateId);
00109   void endLiteral();
00110   
00111   void receiveFunction(ulong symId);
00112   void receiveNumericConstant(double value);
00113   void receiveVariable(ulong varNum);
00114   
00115   // Searching for a proof, includes preprocessing
00116   
00117   void saturate(ulong nextVacantClauseId,
00118                 long timeLimit); // deciseconds 
00119   void lookForAnotherAnswer();
00120   // throws Emergency and intercepts SIGVTALRM
00121   static VampireKernel* currentSession();
00122   void suspend();
00123   void resume();
00124   void tabulate();
00125   void reportInterrupt(int signalNumber);
00126   void reportErrorSignal(int signalNumber);
00127   void reportError();
00128 
00129   // Communicating search results
00130 
00131   TerminationReason terminationReason() const;
00132   const Clause* refutation() const;
00133 
00134 
00135   // Internal signature interface
00136 
00137   bool isNumericConstantId(ulong symbolId) const;
00138   bool isInputSymbol(ulong symbolId) const; 
00139   bool isAnswerPredicateId(ulong symbolId) const;
00140   ulong symbolArity(ulong symbolId) const;
00141   const char* symbolPrintName(ulong symbolId) const; 
00142   // ^ does not work for numeric constants
00143   double numericConstantValue(ulong symbolId) const; 
00144 
00145   // Getting the session statistics
00146   
00147   float statTime() const;   // seconds
00148   long statMemory() const;  // bytes
00149   long statNumOfGeneratedCl() const;
00150   long statNumOfDiscardedEquationalTautologies() const;
00151   long statNumOfDiscardedPropositionalTautologies() const;
00152   long statNumOfForwSubsumedCl() const;
00153   long statNumOfClSimplifiedByForwSubsResol() const;
00154   long statNumOfClSimplifiedByForwDemod() const; // includes statNumOfClSimplifiedByForwDemodOnSplitBranches()
00155   long statNumOfClSimplifiedByForwDemodOnSplitBranches() const;
00156   long statNumOfClSimplifiedByBuiltInTheories() const;
00157   long statNumOfClSimplifiedByEqualityResol() const;
00158   long statNumOfSplitCl() const;
00159   long statNumOfDifferentSplitComponents() const;
00160   float statAverageNumOfSplitComponentsPerCl() const;
00161   long statNumOfDiscardedClWithTooBigLiterals() const;
00162   long statNumOfDiscardedTooDeepCl() const;
00163   long statNumOfDiscardedTooBigCl() const;
00164   long statNumOfDiscardedClWithTooManyVariables() const;
00165   long statNumOfNewClDiscardedDueToLackOfMemory() const;
00166   long statNumOfRetainedCl() const;
00167   long statNumOfSelectedCl() const;
00168   long statNumOfBackSubsumedCl() const;
00169   long statNumOfClSimplifiedByBackDemod() const; // includes statNumOfClSimplifiedByBackDemodOnSplitBranches()
00170   long statNumOfClSimplifiedByBackDemodOnSplitBranches() const;
00171   long statNumOfMurederedPassiveOrphans() const;
00172   long statNumOfMurederedActiveOrphans() const;
00173   long statNumOfClRecycledDueToLackOfResources() const;  
00174   long statNumOfCurrentlyPassiveCl() const;
00175   long statNumOfCurrentlyActiveCl() const;
00176 
00177  private:
00178   class _Implementation; 
00179   
00180  private:
00181   _Implementation* _implementation;
00182 }; // class VampireKernel
00183 
00184 //======================================================================
00185 
00186 class VampireKernel::Options
00187 {
00188  public:
00189   enum SimplificationOrdering
00190   {
00191     NonrecursiveKBOrdering,
00192     StandardKBOrdering
00193   };
00194   enum TermWeightingScheme
00195   {
00196     UniformTermWeighting,
00197     NonuniformConstantTermWeighting
00198   };
00199  public:
00200   Options() { setDefaultValues(); };
00201   ~Options() {};
00202   void setDefaultValues();
00203   ostream& output(ostream& str);
00204  public:
00205   
00206   // session attributes
00207   const char* job_id;
00208   
00209 
00210   // main algorithm
00211     
00212   long main_alg;
00213 
00214   // inference rules
00215   bool no_inferences_between_rules;
00216   bool static_splitting;
00217   bool dynamic_splitting;
00218   long splitting_style;
00219   bool splitting_with_naming;
00220   long static_neg_eq_splitting;
00221   bool paramodulation;
00222   long sim_back_sup;
00223   long selection;
00224   long literal_comparison_mode;
00225   bool inherited_negative_selection;
00226      
00227   // strategy 
00228   bool forward_subsumption;
00229   bool fs_set_mode;
00230   bool fs_optimised_multiset_mode;
00231   bool fs_use_sig_filters;
00232   bool fs_old_style;
00233   long simplify_by_fs;
00234   long forward_demodulation;
00235   bool fd_on_splitting_branches;
00236   bool normalize_by_commutativity;
00237   long backward_demodulation;
00238   bool bd_on_splitting_branches;
00239   bool simplify_by_eq_res;
00240   bool backward_subsumption;
00241   bool bs_set_mode;
00242   bool bs_optimised_multiset_mode;
00243   long orphan_murder;
00244   long lrs;
00245   long elim_def;
00246   SimplificationOrdering simplification_ordering;
00247   long symbol_precedence_by_arity;
00248   bool header_precedence_kinky;
00249   TermWeightingScheme term_weighting_scheme;
00250   long symbol_weight_by_arity;
00251 
00252   // numeric options 
00253   long memory_limit; // kilobytes
00254   long allocation_buffer_size;
00255   double allocation_buffer_price;
00256   long max_skolem; 
00257   long max_active;
00258   long max_passive;
00259   long max_weight;
00260   long max_inference_depth;
00261   long age_weight_ratio;
00262   float selected_pos_eq_penalty_coefficient;    
00263   float nongoal_penalty_coefficient;
00264   long first_time_check;   
00265   long first_mem_check;   
00266     
00267   // interface options    
00268   bool show_opt;
00269   bool show_input;
00270   bool show_prepro;
00271   bool show_gen;
00272   bool show_passive;
00273   bool show_active; 
00274   bool proof;
00275   bool show_profile;
00276   bool show_weight_limit_changes;  
00277   ofstream* tabulation;
00278   ostream* std_output;
00279 }; // class VampireKernel::Options
00280 
00281 inline 
00282 ostream& operator<<(ostream& str,
00283                     const VampireKernel::Options::SimplificationOrdering& so)
00284 {
00285   switch (so)
00286     {
00287     case VampireKernel::Options::NonrecursiveKBOrdering: 
00288       str << "nonrecursive_KB";
00289       break;
00290     case VampireKernel::Options::StandardKBOrdering: 
00291       str << "standard_KB";
00292       break;
00293     };
00294   return str;
00295 };
00296 
00297 inline 
00298 ostream& operator<<(ostream& str,
00299                     const VampireKernel::Options::TermWeightingScheme& tws)
00300 {
00301   switch (tws)
00302     {
00303     case VampireKernel::Options::UniformTermWeighting:
00304       str << "uniform";
00305       break;
00306     case VampireKernel::Options::NonuniformConstantTermWeighting:
00307       str << "nonuniform_constant";
00308       break;
00309     };
00310   return str;
00311 };
00312 
00313 
00314 //======================================================================
00315 
00316 class VampireKernel::Emergency
00317 {
00318  public:
00319   enum Type
00320   {
00321     AllocationFailure,
00322     TimeLimit
00323   };
00324  public:
00325   Emergency(const Type& t) : type_(t) {}; 
00326   ~Emergency() {};
00327   const Type& type() const { return type_; };
00328  private:
00329   Emergency() {};
00330  private:
00331   Type type_;
00332 };
00333 
00334 //======================================================================
00335 
00336 class VampireKernel::Subterm
00337 {
00338  public:
00339   const Subterm* next() const; 
00340   // ^ returns (const Subterm*)0 if this is the last subterm
00341   bool isVariable() const;
00342   ulong variableNumber() const; 
00343   ulong topFunction() const;
00344   const Subterm* firstArgument() const; 
00345   // ^ returns (const Subterm*)0 if there are no arguments
00346  private:
00347   Subterm() {};
00348   ~Subterm() {};
00349   friend class VampireKernel;
00350 };
00351 
00352 class VampireKernel::Literal
00353 {
00354  public:
00355   const Literal* next() const;
00356   // ^ return (const Literal*)0 if this is the last literal
00357   bool isPositive() const;
00358   ulong predicate() const;
00359   const Subterm* firstArgument() const; 
00360   // ^ returns (const Subterm*)0 if there are no arguments
00361  private:
00362   Literal() {};
00363   ~Literal() {};
00364   friend class VampireKernel;
00365 };
00366 
00367 
00368 class VampireKernel::Clause
00369 {
00370  public:
00371   class Ancestor
00372     {
00373     public:
00374       const Clause* clause() const;
00375       const Ancestor* next() const;
00376     private:
00377       Ancestor() {};
00378       ~Ancestor() {};
00379       friend class Clause;
00380     };
00381 
00382   enum BackgroundFlag
00383     { 
00384       IsInputClause,
00385       IsObtainedDuringPreprocessing,
00386       BinaryResolutionUsed,
00387       ForwardSuperpositionUsed,
00388       BackwardSuperpositionUsed,
00389       EqualityResolutionUsed,
00390       EqualityFactoringUsed,
00391       ForwardDemodulationUsed,
00392       BackwardDemodulationUsed,
00393       SimplificationByEqualityResolutionUsed,
00394       ForwardSubsumptionResolutionUsed,
00395       BackwardSubsumptionResolutionUsed,
00396       SplittingUsed, 
00397       IsReanimatedPassive,
00398       IsPartOfNameIntroduction,
00399       SimplificationByBuiltInTheoriesUsed,
00400       IsBuiltInTheoryFact
00401     };
00402 
00403   class BackgroundFlagIterator
00404   {
00405   public:
00406     BackgroundFlagIterator();
00407     ~BackgroundFlagIterator();
00408     bool getCurrentFlag(BackgroundFlag& flag) const;
00409     void goToNextFlag(); 
00410   private:
00411     void* _base;
00412     unsigned long _offset;
00413     friend class Clause;
00414   };
00415 
00416  public:
00417   ulong number() const;
00418   const Literal* literals() const;
00419   // ^ return (const Literal*)0 if the clause is empty
00420   bool isInputClause() const;
00421   void* inputClauseOrigin() const;
00422   bool isBuiltInTheoryFact() const;
00423   const Ancestor* firstAncestor() const;
00424   BackgroundFlagIterator backgroundFlagIterator() const;
00425   bool backgroundFlagIsSet(BackgroundFlag fl) const; 
00426  private:
00427   Clause() {};
00428   ~Clause() {};
00429   friend class VampireKernel;
00430 }; 
00431 
00432 
00433 
00434 //======================================================================
00435 #endif
00436 
00437 
00438 

Generated on Sat Jun 28 15:08:58 2003 for Vampire by doxygen 1.3.2