CVC3

LFSCBoolProof.h

Go to the documentation of this file.
00001 #ifndef LFSC_BOOL_PROOF_H_
00002 #define LFSC_BOOL_PROOF_H_
00003 
00004 #include "LFSCProof.h"
00005 
00006 class LFSCBoolRes : public LFSCProof
00007 {
00008 private:
00009   RefPtr< LFSCProof > d_children[2];
00010   int d_var;
00011   bool d_col;
00012   LFSCBoolRes(LFSCProof* pf1, LFSCProof* pf2, int v, bool col): LFSCProof(),
00013     d_var(v), d_col(col){
00014     d_children[0] = pf1;
00015     d_children[1] = pf2;
00016   }
00017   virtual ~LFSCBoolRes(){}
00018   long int get_length(){
00019     return 10 + d_children[0]->get_string_length() + d_children[1]->get_string_length();
00020   }
00021 public:
00022   virtual LFSCBoolRes* AsLFSCBoolRes(){ return this; }
00023   void print_pf( std::ostream& s, int ind = 0 );
00024   void print_struct( std::ostream& s, int ind = 0 );
00025   //standard Make
00026   static LFSCProof* Make(LFSCProof* pf1, LFSCProof* pf2, int v, bool col);
00027   // make the boolean resolution proof, where p1 corresponds to pf1, p2 corresponds to pf2
00028   //res is the expression to resolve upon
00029   static LFSCProof* Make( LFSCProof* p1, LFSCProof* p2, const Expr& res, const Expr& pf, bool cascadeOr = false );
00030   //make the boolean resolution collection proof, where e is what to resolve
00031   static LFSCProof* MakeC( LFSCProof* p, const Expr& res );
00032   LFSCProof* clone() { return new LFSCBoolRes( d_children[0].get(), d_children[1].get(), d_var, d_col ); }
00033   int getNumChildren() { return 2; }
00034   LFSCProof* getChild( int n ) { return d_children[n].get(); }
00035   int checkBoolRes( std::vector< int >& clause );
00036 };
00037 
00038 class LFSCLem : public LFSCProof
00039 {
00040 private:
00041   int d_var;
00042   LFSCLem( int v ) : LFSCProof(),
00043     d_var( v ) {}
00044   virtual ~LFSCLem(){}
00045   long int get_length() { return 10; }
00046 public:
00047   virtual LFSCLem* AsLFSCLem(){ return this; }
00048   void print_pf( std::ostream& s, int ind = 0 ){ s << "(lem _ _ @a" << abs( d_var ) << ")"; }
00049   void print_struct( std::ostream& s, int ind = 0 ){ s << "(lem " << d_var << ")"; }
00050   static LFSCProof* Make(int v){ return new LFSCLem( v ); }
00051   bool IsTrivial() { return true; }
00052   LFSCProof* clone() { return new LFSCLem( d_var ); }
00053   int checkBoolRes( std::vector< int >& clause ){
00054     clause.push_back( -d_var );
00055     clause.push_back( d_var );
00056     return 0;
00057   }
00058 };
00059 
00060 class LFSCClausify : public LFSCProof
00061 {
00062 private:
00063   friend class LFSCPrinter;
00064   int d_var;
00065   RefPtr< LFSCProof > d_pf;
00066   LFSCClausify( int v, LFSCProof* pf ) : LFSCProof(), d_var( v ), d_pf( pf ){}
00067   virtual ~LFSCClausify(){}
00068   long int get_length() { return 10 + d_pf->get_string_length(); }
00069   //this should be called by Make
00070   static LFSCProof* Make_i( const Expr& e, LFSCProof* p, std::vector< Expr >& exprs, const Expr& end );
00071 public:
00072   virtual LFSCClausify* AsLFSCClausify(){ return this; }
00073   void print_pf( std::ostream& s, int ind = 0 );
00074   void print_struct( std::ostream& s, int ind = 0 ){ s << "(clausify " << d_var << ")"; }
00075   //standard Make
00076   static LFSCProof* Make( int v, LFSCProof* pf ){ return new LFSCClausify( v, pf ); }
00077   // input : a formula e, and a proof of that formula p.
00078   static LFSCProof* Make( const Expr& e, LFSCProof* p, bool cascadeOr = false );
00079   //clone
00080   LFSCProof* clone() { return new LFSCClausify( d_var, d_pf.get() ); }
00081   int getNumChildren() { return 1; }
00082   LFSCProof* getChild( int n ) { return d_pf.get(); }
00083   int checkBoolRes( std::vector< int >& clause ){
00084     d_pf->checkBoolRes( clause );
00085     clause.push_back( d_var );
00086     return 0;
00087   }
00088 };
00089 
00090 class LFSCAssume : public LFSCProof {
00091 private:
00092   int d_var;
00093   RefPtr< LFSCProof > d_pf;
00094   bool d_assm;
00095   int d_type;
00096   LFSCAssume( int v, LFSCProof* pf, bool assm, int type ) : LFSCProof(), d_var( v ), d_pf( pf ), d_assm( assm ), d_type( type ){}
00097   virtual ~LFSCAssume(){}
00098   long int get_length() { return 10 + d_pf->get_string_length(); }
00099 public:
00100   virtual LFSCAssume* AsLFSCAssume(){ return this; }
00101   void print_pf( std::ostream& s, int ind = 0 );
00102   void print_struct( std::ostream& s, int ind = 0 );
00103   static LFSCProof* Make( int v, LFSCProof* pf, bool assm = true, int type=3 ){
00104     return new LFSCAssume( v, pf, assm, type );
00105   }
00106   LFSCProof* clone() { return new LFSCAssume( d_var, d_pf.get(), d_assm, d_type ); }
00107   int getNumChildren() { return 1; }
00108   LFSCProof* getChild( int n ) { return d_pf.get(); }
00109 
00110   int checkBoolRes( std::vector< int >& clause ){
00111     if( d_type==3 ){
00112       d_pf->checkBoolRes( clause );
00113       clause.push_back( -d_var );
00114     }
00115     return 0;
00116   }
00117 };
00118 
00119 #endif