CVC3

search_theorem_producer.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file search_theorem_producer.h
00004  * \brief Implementation API to proof rules for the simple search engine
00005  * 
00006  * Author: Sergey Berezin
00007  * 
00008  * Created: Mon Feb 24 14:48:03 2003
00009  *
00010  * <hr>
00011  *
00012  * License to use, copy, modify, sell and/or distribute this software
00013  * and its documentation for any purpose is hereby granted without
00014  * royalty, subject to the terms and conditions defined in the \ref
00015  * LICENSE file provided with this distribution.
00016  * 
00017  * <hr>
00018  * 
00019  */
00020 /*****************************************************************************/
00021 
00022 #ifndef _cvc3__search__search_theorem_producer_h_
00023 #define _cvc3__search__search_theorem_producer_h_
00024 
00025 #include "theorem_producer.h"
00026 #include "search_rules.h"
00027 
00028 namespace CVC3 {
00029 
00030 class CommonProofRules;
00031 
00032   class SearchEngineTheoremProducer
00033     : public SearchEngineRules,
00034       public TheoremProducer {
00035   private:
00036     CommonProofRules* d_commonRules;
00037 
00038     void verifyConflict(const Theorem& thm, TheoremMap& m);
00039      
00040     void checkSoundNoSkolems(const Expr& e, ExprMap<bool>& visited, 
00041                              const ExprMap<bool>& skolems);
00042     void checkSoundNoSkolems(const Theorem& t, ExprMap<bool>& visited, 
00043                              const ExprMap<bool>& skolems);
00044   public:
00045 
00046     SearchEngineTheoremProducer(TheoremManager* tm);
00047     // Destructor
00048     virtual ~SearchEngineTheoremProducer() { }
00049     
00050     // Proof by contradiction: !A |- FALSE ==> |- A.  "!A" doesn't
00051     // have to be present in the assumptions.
00052     virtual Theorem proofByContradiction(const Expr& a,
00053            const Theorem& pfFalse);
00054     
00055     // Similar rule, only negation introduction:
00056     // A |- FALSE ==> !A
00057     virtual Theorem negIntro(const Expr& not_a, const Theorem& pfFalse);
00058     
00059     // Case split: u1:A |- C, u2:!A |- C  ==>  |- C
00060     virtual Theorem caseSplit(const Expr& a,
00061             const Theorem& a_proves_c,
00062             const Theorem& not_a_proves_c);
00063 
00064 
00065    
00066 
00067     
00068     /*! Eliminate skolem axioms: 
00069      * Gamma, Delta |- false => Gamma|- false 
00070      * where Delta is a set of skolem axioms {|-Exists(x) phi (x) => phi(c)}
00071      * and gamma does not contain any of the skolem constants c.
00072      */
00073     virtual Theorem eliminateSkolemAxioms(const Theorem& tFalse, 
00074             const std::vector<Theorem>& delta);
00075  
00076 
00077     // Conflict clause rule: 
00078     // Gamma, A_1,...,A_n |- B ==> Gamma |- (OR B !A_1 ... !A_n)
00079     // The assumptions A_i are given by the vector 'lits'.
00080     // If B==FALSE, it is omitted from the result.
00081     
00082     // NOTE: here "!A_i" means an inverse of A_i, not just a negation.
00083     // That is, if A_i is NOT C, then !A_i is C.
00084 
00085     // NOTE: Theorems with same expressions must 
00086     // be eliminated before passing as lits.
00087     virtual Theorem conflictClause(const Theorem& thm,
00088            const std::vector<Theorem>& lits, 
00089            const std::vector<Theorem>& gamma);
00090 
00091     // "Cut" rule: { G_i |- A_i };  G', { A_i } |- B ==> union(G_i)+G' |- B.
00092     virtual Theorem cutRule(const std::vector<Theorem>& thmsA,
00093           const Theorem& as_prove_b);
00094 
00095     // "Unit propagation" rule:
00096     // G_j |- !l_j, j in [1..n]-{i}
00097     // G |- (OR l_1 ... l_i ... l_n) ==> G, G_j |- l_i
00098     virtual Theorem unitProp(const std::vector<Theorem>& thms,
00099            const Theorem& clause, unsigned i);
00100 
00101     // "Conflict" rule (all literals in a clause become FALSE)
00102     // { G_j |- !l_j, j in [1..n] } , G |- (OR l_1 ... l_n) ==> FALSE
00103     virtual Theorem conflictRule(const std::vector<Theorem>& thms,
00104          const Theorem& clause);
00105  
00106     // Unit propagation for AND
00107     virtual Theorem propAndrAF(const Theorem& andr_th,
00108              bool left,
00109              const Theorem& b_th);
00110 
00111     virtual Theorem propAndrAT(const Theorem& andr_th,
00112              const Theorem& l_th,
00113              const Theorem& r_th);
00114     
00115 
00116     virtual void propAndrLRT(const Theorem& andr_th,
00117            const Theorem& a_th,
00118            Theorem* l_th,
00119            Theorem* r_th);
00120 
00121     virtual Theorem propAndrLF(const Theorem& andr_th,
00122              const Theorem& a_th,
00123              const Theorem& r_th);
00124 
00125     virtual Theorem propAndrRF(const Theorem& andr_th,
00126              const Theorem& a_th,
00127              const Theorem& l_th);
00128 
00129     // Conflicts for AND
00130     virtual Theorem confAndrAT(const Theorem& andr_th,
00131              const Theorem& a_th,
00132              bool left,
00133              const Theorem& b_th);
00134 
00135     virtual Theorem confAndrAF(const Theorem& andr_th,
00136              const Theorem& a_th,
00137              const Theorem& l_th,
00138              const Theorem& r_th);
00139 
00140     // Unit propagation for IFF
00141     virtual Theorem propIffr(const Theorem& iffr_th,
00142            int p,
00143            const Theorem& a_th,
00144            const Theorem& b_th);
00145 
00146     // Conflicts for IFF
00147     virtual Theorem confIffr(const Theorem& iffr_th,
00148            const Theorem& i_th,
00149            const Theorem& l_th,
00150            const Theorem& r_th);
00151 
00152     // Unit propagation for ITE
00153     virtual Theorem propIterIte(const Theorem& iter_th,
00154         bool left,
00155         const Theorem& if_th,
00156         const Theorem& then_th);
00157 
00158     virtual void propIterIfThen(const Theorem& iter_th,
00159         bool left,
00160         const Theorem& ite_th,
00161         const Theorem& then_th,
00162         Theorem* if_th,
00163         Theorem* else_th);
00164 
00165     virtual Theorem propIterThen(const Theorem& iter_th,
00166          const Theorem& ite_th,
00167          const Theorem& if_th);
00168 
00169     // Conflicts for ITE
00170     virtual Theorem confIterThenElse(const Theorem& iter_th,
00171              const Theorem& ite_th,
00172              const Theorem& then_th,
00173              const Theorem& else_th);
00174 
00175     virtual Theorem confIterIfThen(const Theorem& iter_th,
00176            bool left,
00177            const Theorem& ite_th,
00178            const Theorem& if_th,
00179            const Theorem& then_th);
00180 
00181     // CNF Rules
00182     Theorem andCNFRule(const Theorem& thm);
00183     Theorem orCNFRule(const Theorem& thm);
00184     Theorem impCNFRule(const Theorem& thm);
00185     Theorem iffCNFRule(const Theorem& thm);
00186     Theorem iteCNFRule(const Theorem& thm);
00187     Theorem iteToClauses(const Theorem& ite);
00188     Theorem iffToClauses(const Theorem& iff);
00189 
00190     //theorrm for minisat proofs, by yeting
00191     Theorem satProof(const Expr& queryExpr, const Proof& satProof);
00192 
00193     /////////////////////////////////////////////////////////////////////////
00194     //// helper functions for CNF (Conjunctive Normal Form) conversion
00195     /////////////////////////////////////////////////////////////////////////
00196     private:
00197     Theorem opCNFRule(const Theorem& thm, int kind,
00198           const std::string& ruleName);
00199     
00200     Expr convertToCNF(const Expr& v, const Expr & phi);      
00201 
00202     //! checks if phi has v in local cache of opCNFRule, if so reuse v.
00203     /*! similarly for ( ! ... ! (phi)) */
00204     Expr findInLocalCache(const Expr& i, 
00205         ExprMap<Expr>& localCache,
00206         std::vector<Expr>& boundVars);
00207 
00208   }; // end of class SearchEngineRules
00209 } // end of namespace CVC3
00210 #endif