00001 /*****************************************************************************/ 00002 /*! 00003 * \file search_rules.h 00004 * \brief Abstract proof rules interface to the simple search engine 00005 * 00006 * Author: Sergey Berezin 00007 * 00008 * Created: Mon Feb 24 14:19:48 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_rules_h_ 00031 #define _cvcl__search__search_rules_h_ 00032 00033 namespace CVCL { 00034 00035 class Theorem; 00036 class Expr; 00037 00038 /*! \defgroup SE_Rules Proof Rules for the Search Engines 00039 * \ingroup SE 00040 */ 00041 //! API to the proof rules for the Search Engines 00042 /*! \ingroup SE_Rules */ 00043 class SearchEngineRules { 00044 /*! \addtogroup SE_Rules 00045 * @{ 00046 */ 00047 public: 00048 //! Destructor 00049 virtual ~SearchEngineRules() { } 00050 00051 /*! Eliminate skolem axioms: 00052 * Gamma, Delta |- false => Gamma|- false 00053 * where Delta is a set of skolem axioms {|-Exists(x) phi (x) => phi(c)} 00054 * and gamma does not contain any of the skolem constants c. 00055 */ 00056 virtual Theorem eliminateSkolemAxioms(const Theorem& tFalse, 00057 const std::vector<Theorem>& delta) = 0; 00058 00059 // !A |- FALSE ==> |- A 00060 /*! @brief Proof by contradiction: 00061 \f[\frac{\Gamma, \neg A \vdash\mathrm{FALSE}}{\Gamma \vdash A}\f] 00062 */ 00063 /*! \f$\neg A\f$ does not have to be present in the assumptions. 00064 * \param a is the assumption \e A 00065 * 00066 * \param pfFalse is the theorem \f$\Gamma, \neg A \vdash\mathrm{FALSE}\f$ 00067 */ 00068 virtual Theorem proofByContradiction(const Expr& a, 00069 const Theorem& pfFalse) = 0; 00070 00071 // A |- FALSE ==> !A 00072 /*! @brief Negation introduction: 00073 \f[\frac{\Gamma, A \vdash\mathrm{FALSE}}{\Gamma\vdash\neg A}\f] 00074 */ 00075 /*! 00076 * \param not_a is the formula \f$\neg A\f$. We pass the negation 00077 * \f$\neg A\f$, and not just \e A, for efficiency: building 00078 * \f$\neg A\f$ is more expensive (due to uniquifying pointers in 00079 * Expr package) than extracting \e A from \f$\neg A\f$. 00080 * 00081 * \param pfFalse is the theorem \f$\Gamma, A \vdash\mathrm{FALSE}\f$ 00082 */ 00083 virtual Theorem negIntro(const Expr& not_a, const Theorem& pfFalse) = 0; 00084 00085 // u1:A |- C, u2:!A |- C ==> |- C 00086 /*! @brief Case split: 00087 \f[\frac{\Gamma_1, A\vdash C \quad \Gamma_2, \neg A\vdash C} 00088 {\Gamma_1\cup\Gamma_2\vdash C}\f] 00089 */ 00090 /*! 00091 * \param a is the assumption A to split on 00092 * 00093 * \param a_proves_c is the theorem \f$\Gamma_1, A\vdash C\f$ 00094 * 00095 * \param not_a_proves_c is the theorem \f$\Gamma_2, \neg A\vdash C\f$ 00096 */ 00097 virtual Theorem caseSplit(const Expr& a, 00098 const Theorem& a_proves_c, 00099 const Theorem& not_a_proves_c) = 0; 00100 00101 // Gamma, A_1,...,A_n |- FALSE ==> Gamma |- (OR !A_1 ... !A_n) 00102 /*! @brief Conflict clause rule: 00103 \f[\frac{\Gamma,A_1,\ldots,A_n\vdash\mathrm{FALSE}} 00104 {\Gamma\vdash\neg A_1\vee\cdots\vee \neg A_n}\f] 00105 */ 00106 /*! 00107 * \param thm is the theorem 00108 * \f$\Gamma,A_1,\ldots,A_n\vdash\mathrm{FALSE}\f$ 00109 * 00110 * \param lits is the vector of literals <em>A<sub>i</sub></em>. 00111 * They must be present in the set of assumptions of \e thm. 00112 * 00113 * \param gamma FIXME: document this!! 00114 */ 00115 virtual Theorem conflictClause(const Theorem& thm, 00116 const std::vector<Theorem>& lits, 00117 const std::vector<Theorem>& gamma) = 0; 00118 00119 00120 // "Cut" rule: { G_i |- A_i }; G', { A_i } |- B ==> union(G_i)+G' |- B. 00121 /*! @brief Cut rule: 00122 \f[\frac{\Gamma_1\vdash A_1\quad\cdots\quad\Gamma_n\vdash A_n 00123 \quad \Gamma', A_1,\ldots,A_n\vdash B} 00124 {\bigcup_{i=1}^n\Gamma_i\cup\Gamma'\vdash B}\f] 00125 */ 00126 /*! 00127 * \param thmsA is a vector of theorems \f$\Gamma_i\vdash A_i\f$ 00128 * 00129 * \param as_prove_b is the theorem 00130 * \f$\Gamma', A_1,\ldots,A_n\vdash B\f$ 00131 * (the name means "A's prove B") 00132 */ 00133 virtual Theorem cutRule(const std::vector<Theorem>& thmsA, 00134 const Theorem& as_prove_b) = 0; 00135 00136 // { G_j |- !A_j, j in [1..n]-{i} } 00137 // G |- (OR A_1 ... A_i ... A_n) ==> G, G_j |- A_i 00138 /*! @brief Unit propagation rule: 00139 \f[\frac{\Gamma_j\vdash\neg A_j\mbox{ for }j\in[1\ldots n]-\{i\} 00140 \quad \Gamma\vdash A_1\vee\cdots\vee A_n} 00141 {\bigcup_{j\in[1\ldots n]-\{i\}}\Gamma_j\cup\Gamma\vdash A_i}\f] 00142 */ 00143 /*! 00144 * \param clause is the proof of the clause \f$ \Gamma\vdash 00145 * A_1\vee\cdots\vee A_n\f$ 00146 * 00147 * \param i is the index (0..n-1) of the literal to be unit-propagated 00148 * 00149 * \param thms is the vector of theorems \f$\Gamma_j\vdash\neg 00150 * A_j\f$ for all literals except <em>A<sub>i</sub></em> 00151 */ 00152 virtual Theorem unitProp(const std::vector<Theorem>& thms, 00153 const Theorem& clause, unsigned i) = 0; 00154 00155 // { G_j |- !A_j, j in [1..n] } , G |- (OR A_1 ... A_n) ==> FALSE 00156 /*! @brief "Conflict" rule (all literals in a clause become FALSE) 00157 \f[\frac{\Gamma_j\vdash\neg A_j\mbox{ for }j\in[1\ldots n] 00158 \quad \Gamma\vdash A_1\vee\cdots\vee A_n} 00159 {\bigcup_{j\in[1\ldots n]}\Gamma_j\cup\Gamma 00160 \vdash\mathrm{FALSE}}\f] 00161 */ 00162 /*! 00163 * \param clause is the proof of the clause \f$ \Gamma\vdash 00164 * A_1\vee\cdots\vee A_n\f$ 00165 * 00166 * \param thms is the vector of theorems \f$\Gamma_j\vdash\neg 00167 * A_j\f$ 00168 */ 00169 virtual Theorem conflictRule(const std::vector<Theorem>& thms, 00170 const Theorem& clause) = 0; 00171 00172 00173 // Unit propagation for AND 00174 virtual Theorem propAndrAF(const Theorem& andr_th, 00175 bool left, 00176 const Theorem& b_th) = 0; 00177 00178 virtual Theorem propAndrAT(const Theorem& andr_th, 00179 const Theorem& l_th, 00180 const Theorem& r_th) = 0; 00181 00182 00183 virtual void propAndrLRT(const Theorem& andr_th, 00184 const Theorem& a_th, 00185 Theorem* l_th, 00186 Theorem* r_th) = 0; 00187 00188 virtual Theorem propAndrLF(const Theorem& andr_th, 00189 const Theorem& a_th, 00190 const Theorem& r_th) = 0; 00191 00192 virtual Theorem propAndrRF(const Theorem& andr_th, 00193 const Theorem& a_th, 00194 const Theorem& l_th) = 0; 00195 00196 // Conflicts for AND 00197 virtual Theorem confAndrAT(const Theorem& andr_th, 00198 const Theorem& a_th, 00199 bool left, 00200 const Theorem& b_th) = 0; 00201 00202 virtual Theorem confAndrAF(const Theorem& andr_th, 00203 const Theorem& a_th, 00204 const Theorem& l_th, 00205 const Theorem& r_th) = 0; 00206 00207 // Unit propagation for IFF 00208 virtual Theorem propIffr(const Theorem& iffr_th, 00209 int p, 00210 const Theorem& a_th, 00211 const Theorem& b_th) = 0; 00212 00213 // Conflicts for IFF 00214 virtual Theorem confIffr(const Theorem& iffr_th, 00215 const Theorem& i_th, 00216 const Theorem& l_th, 00217 const Theorem& r_th) = 0; 00218 00219 // Unit propagation for ITE 00220 virtual Theorem propIterIte(const Theorem& iter_th, 00221 bool left, 00222 const Theorem& if_th, 00223 const Theorem& then_th) = 0; 00224 00225 virtual void propIterIfThen(const Theorem& iter_th, 00226 bool left, 00227 const Theorem& ite_th, 00228 const Theorem& then_th, 00229 Theorem* if_th, 00230 Theorem* else_th) = 0; 00231 00232 virtual Theorem propIterThen(const Theorem& iter_th, 00233 const Theorem& ite_th, 00234 const Theorem& if_th) = 0; 00235 00236 // Conflict for ITE 00237 virtual Theorem confIterThenElse(const Theorem& iter_th, 00238 const Theorem& ite_th, 00239 const Theorem& then_th, 00240 const Theorem& else_th) = 0; 00241 00242 virtual Theorem confIterIfThen(const Theorem& iter_th, 00243 bool left, 00244 const Theorem& ite_th, 00245 const Theorem& if_th, 00246 const Theorem& then_th) = 0; 00247 00248 // CNF Rules 00249 00250 //! AND(x1,...,xn) <=> v |- CNF[AND(x1,...,xn) <=> v] 00251 virtual Theorem andCNFRule(const Theorem& thm) = 0; 00252 //! OR(x1,...,xn) <=> v |- CNF[OR(x1,...,xn) <=> v] 00253 virtual Theorem orCNFRule(const Theorem& thm) = 0; 00254 //! (x1 => x2) <=> v |- CNF[(x1 => x2) <=> v] 00255 virtual Theorem impCNFRule(const Theorem& thm) = 0; 00256 //! (x1 <=> x2) <=> v |- CNF[(x1 <=> x2) <=> v] 00257 virtual Theorem iffCNFRule(const Theorem& thm) = 0; 00258 //! ITE(c, x1, x2) <=> v |- CNF[ITE(c, x1, x2) <=> v] 00259 virtual Theorem iteCNFRule(const Theorem& thm) = 0; 00260 //! ITE(c, f1, f2) |- (NOT c OR f1) AND (c OR f2) 00261 virtual Theorem iteToClauses(const Theorem& ite) = 0; 00262 //! e1 <=> e2 |- (NOT e1 OR e2) AND (e1 OR NOT e2) 00263 virtual Theorem iffToClauses(const Theorem& iff) = 0; 00264 00265 /*! @} */ // end of SE_Rules 00266 }; // end of class SearchEngineRules 00267 00268 } // end of namespace CVCL 00269 00270 #endif