00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #ifndef _CVCL_TRUSTED_
00077 #warning "This file should be included only by TRUSTED code. Define _CVCL_TRUSTED_ before including this file."
00078 #endif
00079
00080 #ifndef _CVC_lite__theorem_producer_h_
00081 #define _CVC_lite__theorem_producer_h_
00082
00083 #include "theorem.h"
00084 #include "theorem_manager.h"
00085 #include "exception.h"
00086
00087
00088
00089
00090
00091 #define CHECK_SOUND(cond, msg) if(!(cond)) \
00092 soundError(__FILE__, __LINE__, #cond, msg)
00093
00094
00095 #define CHECK_PROOFS *d_checkProofs
00096
00097 namespace CVCL {
00098
00099 class TheoremProducer {
00100
00101 protected:
00102 TheoremManager* d_tm;
00103 ExprManager* d_em;
00104
00105
00106 const bool* d_checkProofs;
00107
00108 Op d_pfOp;
00109
00110 Expr d_hole;
00111
00112
00113
00114
00115 Theorem newTheorem(const Expr& thm,
00116 const Assumptions& assump,
00117 const Proof& pf) {
00118 IF_DEBUG(if(!thm.isEq() && !thm.isIff()) {
00119 TRACE("newTheorem", "newTheorem(", thm, ")");
00120 debugger.counter("newTheorem() called on equality")++;
00121 });
00122 return Theorem(d_tm, thm, assump, pf);
00123 }
00124
00125
00126 Theorem newRWTheorem(const Expr& lhs, const Expr& rhs,
00127 const Assumptions& assump,
00128 const Proof& pf) {
00129 return Theorem(d_tm, lhs, rhs, assump, pf);
00130 }
00131
00132
00133 Theorem newReflTheorem(const Expr& e, const Proof& pf) {
00134 return Theorem(d_tm, e, pf);
00135 }
00136
00137 Theorem newAssumption(const Expr& thm, const Proof& pf, int scope = -1) {
00138 return Theorem(d_tm, thm, Assumptions(), pf, true, scope);
00139 }
00140
00141 Theorem3 newTheorem3(const Expr& thm,
00142 const Assumptions& assump,
00143 const Proof& pf) {
00144 IF_DEBUG(if(!thm.isEq() && !thm.isIff()) {
00145 TRACE("newTheorem", "newTheorem3(", thm, ")");
00146 debugger.counter("newTheorem3() called on equality")++;
00147 });
00148 return Theorem3(d_tm, thm, assump, pf);
00149 }
00150
00151 Theorem3 newRWTheorem3(const Expr& lhs, const Expr& rhs,
00152 const Assumptions& assump,
00153 const Proof& pf) {
00154 return Theorem3(d_tm, lhs, rhs, assump, pf);
00155 }
00156
00157 void soundError(const std::string& file, int line,
00158 const std::string& cond, const std::string& msg)
00159 throw(Exception);
00160
00161 public:
00162
00163 TheoremProducer(TheoremManager *tm);
00164
00165 virtual ~TheoremProducer() { }
00166
00167
00168 bool withProof() { return d_tm->withProof(); }
00169
00170
00171 bool withAssumptions() { return d_tm->withAssumptions(); }
00172
00173
00174 Proof newLabel(const Expr& e);
00175
00176
00177
00178
00179
00180
00181 Proof newPf(const std::string& name);
00182 Proof newPf(const std::string& name, const Expr& e);
00183 Proof newPf(const std::string& name, const Proof& pf);
00184 Proof newPf(const std::string& name, const Expr& e1, const Expr& e2);
00185 Proof newPf(const std::string& name, const Expr& e, const Proof& pf);
00186 Proof newPf(const std::string& name, const Expr& e1,
00187 const Expr& e2, const Expr& e3);
00188 Proof newPf(const std::string& name, const Expr& e1,
00189 const Expr& e2, const Proof& pf);
00190
00191
00192
00193
00194
00195
00196 Proof newPf(const std::string& name,
00197 Expr::iterator begin, const Expr::iterator &end);
00198 Proof newPf(const std::string& name, const Expr& e,
00199 Expr::iterator begin, const Expr::iterator &end);
00200 Proof newPf(const std::string& name,
00201 Expr::iterator begin, const Expr::iterator &end,
00202 const std::vector<Proof>& pfs);
00203
00204
00205 Proof newPf(const std::string& name, const std::vector<Expr>& args);
00206 Proof newPf(const std::string& name, const Expr& e,
00207 const std::vector<Expr>& args);
00208 Proof newPf(const std::string& name, const Expr& e,
00209 const std::vector<Proof>& pfs);
00210 Proof newPf(const std::string& name, const Expr& e1, const Expr& e2,
00211 const std::vector<Proof>& pfs);
00212 Proof newPf(const std::string& name, const std::vector<Proof>& pfs);
00213 Proof newPf(const std::string& name, const std::vector<Expr>& args,
00214 const Proof& pf);
00215 Proof newPf(const std::string& name, const std::vector<Expr>& args,
00216 const std::vector<Proof>& pfs);
00217
00218
00219
00220
00221 Proof newPf(const Proof& label, const Expr& frm, const Proof& pf);
00222
00223
00224
00225 Proof newPf(const Proof& label, const Proof& pf);
00226
00227
00228
00229 Proof newPf(const std::vector<Proof>& labels,
00230 const std::vector<Expr>& frms,
00231 const Proof& pf);
00232
00233 Proof newPf(const std::vector<Proof>& labels,
00234 const Proof& pf);
00235
00236 };
00237
00238 };
00239 #endif