00001 /*****************************************************************************/ 00002 /*! 00003 *\file core_proof_rules.h 00004 *\brief Proof rules used by theory_core 00005 * 00006 * Author: Clark Barrett 00007 * 00008 * Created: Wed Jan 11 15:48:35 2006 00009 * 00010 * <hr> 00011 * Copyright (C) 2006 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 _CVC_lite__core_proof_rules_h_ 00031 #define _CVC_lite__core_proof_rules_h_ 00032 00033 #include <vector> 00034 00035 namespace CVCL { 00036 00037 class Theorem; 00038 class Theorem3; 00039 class Expr; 00040 class Op; 00041 00042 class CoreProofRules { 00043 public: 00044 //! Destructor 00045 virtual ~CoreProofRules() { } 00046 00047 //////////////////////////////////////////////////////////////////////// 00048 // TCC rules (3-valued logic) 00049 //////////////////////////////////////////////////////////////////////// 00050 00051 // G1 |- phi G2 |- D_phi 00052 // ------------------------- 00053 // G1,G2 |-_3 phi 00054 /*! 00055 * @brief Convert 2-valued formula to 3-valued by discharging its 00056 * TCC (\f$D_\phi\f$): 00057 * \f[\frac{\Gamma_1\vdash_2 \phi\quad \Gamma_2\vdash_2 D_{\phi}} 00058 * {\Gamma_1,\,\Gamma_2\vdash_3\phi}\f] 00059 */ 00060 virtual Theorem3 queryTCC(const Theorem& phi, const Theorem& D_phi) = 0; 00061 00062 // G0,a1,...,an |-_3 phi G1 |- D_a1 ... Gn |- D_an 00063 // ------------------------------------------------- 00064 // G0,G1,...,Gn |-_3 (a1 & ... & an) -> phi 00065 /*! 00066 * @brief 3-valued implication introduction rule: 00067 * \f[\frac{\Gamma_0,\,\alpha_1\,\ldots,\,\alpha_n\vdash_3\phi\quad 00068 * (\Gamma_i\vdash D_{\alpha_i})_{i\in[1..n]}} 00069 * {\Gamma_0,\,\Gamma_1, \ldots, \Gamma_n\vdash_3 00070 * (\bigwedge_{i=1}^n\alpha_i)\to\phi}\f] 00071 * 00072 * \param phi is the formula \f$\phi\f$ 00073 * \param assump is the vector of assumptions \f$\alpha_1\ldots\alpha_n\f$ 00074 * \param tccs is the vector of TCCs for assumptions 00075 * \f$D_{\alpha_1}\ldots D_{\alpha_n}\f$ 00076 */ 00077 virtual Theorem3 implIntro3(const Theorem3& phi, 00078 const std::vector<Expr>& assump, 00079 const std::vector<Theorem>& tccs) = 0; 00080 00081 00082 //! e: T ==> |- typePred_T(e) [deriving the type predicate of e] 00083 virtual Theorem typePred(const Expr& e) = 0; 00084 00085 //////////////////////////////////////////////////////////////////////// 00086 // Core rewrite rules 00087 //////////////////////////////////////////////////////////////////////// 00088 00089 // Rewrite rules used only in TheoryCore to replace LETDECL and 00090 // CONSTDEF with their definitions 00091 //! Replace LETDECL with its definition 00092 /*! Used only in TheoryCore */ 00093 virtual Theorem rewriteLetDecl(const Expr& e) = 0; 00094 //! Replace CONSTDEF with its definition 00095 /*! Used only in TheoryCore */ 00096 virtual Theorem rewriteConstDef(const Expr& e) = 0; 00097 //! ==> NOT (AND e1 ... en) IFF (OR !e1 ... !en), takes (AND ...) 00098 virtual Theorem rewriteNotAnd(const Expr& e) = 0; 00099 //! ==> NOT (OR e1 ... en) IFF (AND !e1 ... !en), takes (OR ...) 00100 virtual Theorem rewriteNotOr(const Expr& e) = 0; 00101 //! ==> NOT IFF(e1,e2) IFF IFF(e1,NOT e2) 00102 virtual Theorem rewriteNotIff(const Expr& e) = 0; 00103 //! ==> NOT ITE(a,b,c) IFF ITE(a,NOT b,NOT c) 00104 virtual Theorem rewriteNotIte(const Expr& e) = 0; 00105 //! ==> ITE(TRUE, e1, e2) == e1 00106 virtual Theorem rewriteIteTrue(const Expr& e) = 0; 00107 //! ==> ITE(FALSE, e1, e2) == e2 00108 virtual Theorem rewriteIteFalse(const Expr& e) = 0; 00109 //! ==> ITE(c, e, e) == e 00110 virtual Theorem rewriteIteSame(const Expr& e) = 0; 00111 //! a |- b == d ==> ITE(a, b, c) == ITE(a, d, c) 00112 virtual Theorem rewriteIteThen(const Expr& e, const Theorem& thenThm) = 0; 00113 //! !a |- c == d ==> ITE(a, b, c) == ITE(a, b, d) 00114 virtual Theorem rewriteIteElse(const Expr& e, const Theorem& elseThm) = 0; 00115 //! ==> ITE(c, e1, e2) <=> (c => e1) AND (!c => e2) 00116 virtual Theorem rewriteIteBool(const Expr& c, 00117 const Expr& e1, const Expr& e2) = 0; 00118 00119 //! |= (A & B1) | (A & B2) | ... | (A & bn) <=> A & (B1 | B2 | ...| Bn) 00120 virtual Theorem orDistributivityRule(const Expr& e) = 0; 00121 //! |= (A | B1) & (A | B2) & ... & (A | bn) <=> A | (B1 & B2 & ...& Bn) 00122 virtual Theorem andDistributivityRule(const Expr& e) = 0; 00123 00124 00125 //! ==> IMPLIES(e1,e2) IFF OR(!e1, e2) 00126 virtual Theorem rewriteImplies(const Expr& e) = 0; 00127 00128 //! ==> NOT(e) == ITE(e, FALSE, TRUE) 00129 virtual Theorem NotToIte(const Expr& not_e) = 0; 00130 //! ==> Or(e) == ITE(e[1], TRUE, e[0]) 00131 virtual Theorem OrToIte(const Expr& e) = 0; 00132 //! ==> And(e) == ITE(e[1], e[0], FALSE) 00133 virtual Theorem AndToIte(const Expr& e) = 0; 00134 //! ==> IFF(a,b) == ITE(a, b, !b) 00135 virtual Theorem IffToIte(const Expr& e) = 0; 00136 //! ==> IMPLIES(a,b) == ITE(a, b, TRUE) 00137 virtual Theorem ImpToIte(const Expr& e) = 0; 00138 00139 //! ==> ITE(e, FALSE, TRUE) IFF NOT(e) 00140 virtual Theorem rewriteIteToNot(const Expr& e) = 0; 00141 //! ==> ITE(a, TRUE, b) IFF OR(a, b) 00142 virtual Theorem rewriteIteToOr(const Expr& e) = 0; 00143 //! ==> ITE(a, b, FALSE) IFF AND(a, b) 00144 virtual Theorem rewriteIteToAnd(const Expr& e) = 0; 00145 //! ==> ITE(a, b, !b) IFF IFF(a, b) 00146 virtual Theorem rewriteIteToIff(const Expr& e) = 0; 00147 //! ==> ITE(a, b, TRUE) IFF IMPLIES(a, b) 00148 virtual Theorem rewriteIteToImp(const Expr& e) = 0; 00149 //! ==> ITE(a, b(a), c(a)) IFF ITE(a, b(TRUE), c(FALSE)) 00150 virtual Theorem rewriteIteCond(const Expr& e) = 0; 00151 00152 //! |- op(ITE(cond,a,b)) =/<=> ITE(cond,op(a),op(b)) 00153 virtual Theorem ifLiftUnaryRule(const Expr& e) = 0; 00154 //! ((a|b)<=>(a|c))<=>(a|(b<=>c)); takes ((a|b)<=>(a|c)) as 'iff' 00155 virtual Theorem iffOrDistrib(const Expr& iff) = 0; 00156 //! ((a&b)<=>(a&c))<=>(!a|(b<=>c)); takes ((a&b)<=>(a&c)) as 'iff' 00157 virtual Theorem iffAndDistrib(const Expr& iff) = 0; 00158 00159 // Advanced Boolean transformations 00160 00161 //! (a & b) <=> a & b[a/true]; takes the index of a 00162 /*! and rewrites all the other conjuncts. */ 00163 virtual Theorem rewriteAndSubterms(const Expr& e, int idx) = 0; 00164 //! (a | b) <=> a | b[a/false]; takes the index of a 00165 /*! and rewrites all the other disjuncts. */ 00166 virtual Theorem rewriteOrSubterms(const Expr& e, int idx) = 0; 00167 00168 }; // end of class CoreProofRules 00169 00170 } // end of namespace CVCL 00171 00172 #endif