PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00016 //***************************************************************************** 00017 00018 #ifndef BooleVariable_h_ 00019 #define BooleVariable_h_ 00020 00021 // include basic definitions 00022 #include "pbori_defs.h" 00023 00024 // get BoolePolynomial's definition 00025 #include "BooleEnv.h" 00026 #include "BoolePolynomial.h" 00027 #include "BooleSet.h" 00028 00029 BEGIN_NAMESPACE_PBORI 00030 00039 class BooleVariable: 00040 public CAuxTypes { 00041 00043 typedef BooleVariable self; 00044 00045 public: 00046 00048 typedef BooleSet set_type; 00049 00051 typedef BoolePolyRing ring_type; 00052 00054 explicit BooleVariable(idx_type idx = 0): 00055 m_poly( BooleEnv::ring().variable(idx) ) {} 00056 00058 BooleVariable(idx_type idx, const ring_type& ring): 00059 m_poly( ring.variable(idx) ) {} 00060 00062 BooleVariable(const self& rhs): 00063 m_poly(rhs.m_poly) {} 00064 00066 operator const BoolePolynomial&() const { return m_poly; } 00067 00069 idx_type index() const { return *m_poly.firstBegin(); } 00070 00072 bool operator== (const self& other) const{ 00073 return m_poly==other.m_poly; 00074 } 00075 00076 // Nonequality check 00077 bool operator!= (const self& other) const{ 00078 return m_poly!=other.m_poly; 00079 } 00080 00082 hash_type stableHash() const{ return m_poly.stableHash(); } 00083 00085 hash_type hash() const { return m_poly.hash(); } 00086 00088 set_type set() const { return m_poly.set(); } 00089 00091 const ring_type& ring() const { return m_poly.ring(); } 00092 00093 private: 00094 friend class BoolePolyRing; 00095 BooleVariable(const BoolePolynomial& poly):m_poly(poly){} 00096 00097 BoolePolynomial m_poly; 00098 }; 00099 00100 00102 inline BoolePolynomial 00103 operator/(const BooleVariable& lhs, const BooleVariable& rhs) { 00104 return BoolePolynomial(BooleConstant(lhs == rhs), lhs.ring()); 00105 } 00106 00107 // /// Access nvar-th ring variable 00108 // inline BooleVariable BoolePolyRing::variable(idx_type nvar) const { 00109 // return var_type(nvar, *this); 00110 // } 00111 00112 END_NAMESPACE_PBORI 00113 00114 #endif // of BooleVariable_h_