search.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file search.h
00004  * \brief Abstract API to the proof search engine
00005  * 
00006  * Author: Clark Barrett, Vijay Ganesh (Clausal Normal Form Converter)
00007  * 
00008  * Created: Fri Jan 17 13:35:03 2003
00009  *
00010  * <hr>
00011  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00012  * Junior University and by New York University. 
00013  *
00014  * License to use, copy, modify, sell and/or distribute this software
00015  * and its documentation for any purpose is hereby granted without
00016  * royalty, subject to the terms and conditions defined in the \ref
00017  * LICENSE file provided with this distribution.  In particular:
00018  *
00019  * - The above copyright notice and this permission notice must appear
00020  * in all copies of the software and related documentation.
00021  *
00022  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00023  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00024  * 
00025  * <hr>
00026  * 
00027  */
00028 /*****************************************************************************/
00029 
00030 #ifndef _cvcl__include__search_h_
00031 #define _cvcl__include__search_h_
00032 
00033 #include <vector>
00034 #include "cdo.h"
00035 
00036 namespace CVCL {
00037 
00038 class SearchEngineRules;
00039 class Theorem;
00040 class Expr;
00041 class Proof;
00042 class TheoryCore;
00043 class CommonProofRules;
00044 
00045 template<class Data> class ExprMap;
00046 
00047   /*! \defgroup SE Search Engine 
00048    * \ingroup VC
00049    * The search engine includes Boolean reasoning and coordinates with theory
00050    * reasoning.  It consists of a generic abstract API (class SearchEngine) and
00051    * subclasses implementing concrete instances of search engines.
00052    */
00053 
00054   //! API to to a generic proof search engine
00055   /*! \ingroup SE */
00056 class SearchEngine {
00057 
00058 protected:
00059   /*! \addtogroup SE 
00060    * @{
00061    */
00062 
00063   //! Access to theory reasoning
00064   TheoryCore* d_core;
00065 
00066   //! Common proof rules
00067   CommonProofRules* d_commonRules;
00068 
00069   //! Proof rules for the search engine
00070   SearchEngineRules* d_rules;
00071 
00072   //! Create the trusted component
00073   /*! This function is defined in search_theorem_producer.cpp */
00074   SearchEngineRules* createRules();
00075 
00076  public:
00077 
00078   //! Constructor
00079   SearchEngine(TheoryCore* core);
00080 
00081   //! Destructor
00082   virtual ~SearchEngine();
00083 
00084   //! Name of this search engine
00085   virtual const std::string& getName() = 0;
00086 
00087   //! Accessor for TheoryCore
00088   TheoryCore* theoryCore() { return d_core; }
00089 
00090   //! Register an atomic formula of interest.
00091   /*! Registered atoms are tracked by the decision procedures.  If one of them
00092       is deduced to be true or false, it is added to a list of implied literals.
00093       Implied literals can be retrieved with the getImpliedLiteral function */
00094   virtual void registerAtom(const Expr& e) = 0;
00095 
00096   //! Return next literal implied by last assertion.  Null Expr if none.
00097   /*! Returned literals are either registered atomic formulas or their negation
00098    */
00099   virtual Theorem getImpliedLiteral() = 0;
00100 
00101   //! Checks the validity of a formula in the current context
00102   /*! If the query is valid, it returns a theorem and the scope and context
00103    * should be the same as when called.  If the query is invalid, it returns
00104    * a NULL theorem and the context will be one which falsifies the query. */
00105   virtual Theorem checkValid(const Expr& e) = 0;
00106 
00107   //! Reruns last check with e as an additional assumption
00108   /*! This method should only be called after a query which is invalid.
00109    */
00110   virtual Theorem restart(const Expr& e) = 0;
00111 
00112   //! Returns to context immediately before last call to checkValid
00113   /*! This method should only be called after a query which is invalid.
00114    */
00115   virtual void returnFromCheck() = 0;
00116 
00117   //! Returns the result of the most recent valid theorem
00118   /*! Returns Null Theorem if last call was not valid */
00119   virtual Theorem lastThm() = 0;
00120 
00121   /*! @brief Generate and add an assumption to the set of
00122    * assumptions in the current context. */
00123   /*! By default, the assumption is added at the current scope.  The default
00124    * can be overridden by specifying the scope parameter. */
00125   virtual Theorem newUserAssumption(const Expr& e, int scope = -1) = 0;
00126 
00127   //! Get all user assumptions made in this and all previous contexts.
00128   /*! User assumptions are created either by calls to newUserAssumption or
00129    * a call to checkValid.  In the latter case, the negated query is added
00130    * as an assumption.
00131    * \param assumptions should be empty on entry.
00132   */
00133   virtual void getUserAssumptions(std::vector<Expr>& assumptions) = 0;
00134 
00135   //! Get assumptions made internally in this and all previous contexts.
00136   /*! Internal assumptions are literals assumed by the sat solver.
00137    * \param assumptions should be empty on entry.
00138   */
00139   virtual void getInternalAssumptions(std::vector<Expr>& assumptions) = 0;
00140 
00141   //! Get all assumptions made in this and all previous contexts.
00142   /*! \param assumption should be an empty vector which will be filled \
00143     with the assumption */
00144   virtual void getAssumptions(std::vector<Expr>& assumptions) = 0;
00145 
00146   //! Check if the formula has already been assumed previously
00147   virtual bool isAssumption(const Expr& e) = 0;
00148 
00149   //! Will return the set of assertions which make the queried formula false.
00150   /*! This method should only be called after an invalid query It will try to
00151    * return the simplest possible set of assertions which are sufficient to make
00152    * the queried expression false.
00153    * \param assertions should be empty on entry.
00154    * \param inOrder if true, returns the assertions in the order they were
00155    * asserted.  This is slightly more expensive than inOrder = false.
00156   */
00157   virtual void getCounterExample(std::vector<Expr>& assertions,
00158                                  bool inOrder = true) = 0;
00159 
00160   //! Returns the proof term for the last proven query
00161   /*! It should be called only after a valid query.
00162    * In any other case, it returns Null. */
00163   virtual Proof getProof() = 0;
00164 
00165   /*! @brief Build a concrete Model (assign values to variables),
00166    * should only be called after an invalid query. */
00167   void getConcreteModel(ExprMap<Expr>& m);
00168 
00169   /* @} */ // end of group SE
00170 
00171 };
00172 
00173 
00174 }
00175 
00176 #endif

Generated on Thu Apr 13 16:57:32 2006 for CVC Lite by  doxygen 1.4.4