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

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