BooleMonomial.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_BooleMonomial_h_
#define polybori_BooleMonomial_h_
// include basic definitions
#include <polybori/pbori_defs.h>
// get definition of BoolePolynomial and BooleVariable
#include <polybori/BoolePolynomial.h>
#include <polybori/BooleVariable.h>
// get standard map functionality
#include <map>
// get variable iterator
#include <polybori/iterators/CVariableIter.h>
// get variable iterator
#include <polybori/except/PBoRiError.h>
BEGIN_NAMESPACE_PBORI
class BooleVariable;
class BooleExponent;
template <class DDType, class MonomType> class CDDOperations;
class BooleMonomial:
public CAuxTypes {
typedef BooleMonomial self;
public:
template <class, class> friend class CDDOperations;
friend class COrderingBase;
template <class> friend class CTermGeneratorBase;
template <class, class> friend class CTermGeneratorBase__;
typedef BoolePolynomial poly_type;
typedef poly_type::dd_type dd_type;
typedef poly_type::integer_type integer_type;
typedef poly_type::ostream_type ostream_type;
typedef poly_type::var_type var_type;
typedef poly_type::constant_type constant_type;
typedef poly_type::set_type set_type;
typedef poly_type::exp_type exp_type;
typedef poly_type::ring_type ring_type;
typedef poly_type::first_iterator const_iterator;
typedef CVariableIter<const_iterator, var_type> variable_iterator;
// typedef generate_index_map<self>::type idx_map_type;
typedef std::map<self, idx_type, symmetric_composition<
std::less<poly_type::navigator>,
navigates<poly_type> > > idx_map_type;
typedef dd_type::easy_equality_property easy_equality_property;
BooleMonomial(const self& rhs):
m_poly(rhs.m_poly) {}
BooleMonomial(const var_type& rhs); // not inlined to avoid dependency loop
// (both depend on poly_type)
BooleMonomial(const exp_type& rhs, const ring_type& ring):
m_poly(rhs, ring) { }
BooleMonomial(const ring_type& ring):
m_poly(ring.one()) {}
~BooleMonomial() {}
operator const BoolePolynomial&() const { return m_poly; }
exp_type exp() const;
const_iterator begin() const { return m_poly.firstBegin(); }
const_iterator end() const { return m_poly.firstEnd(); }
variable_iterator variableBegin() const {
return variable_iterator(begin(), ring());
}
variable_iterator variableEnd() const {
return variable_iterator(end(), ring());
}
deg_type deg() const {
return std::distance(m_poly.firstBegin(),m_poly.firstEnd());
}
size_type size() const { return (size_type)deg(); } // always nonnegative
set_type divisors() const { return m_poly.leadDivisors(); }
set_type multiples(const self&) const;
hash_type stableHash() const {
return stable_first_hash_range(m_poly.navigation());
}
hash_type hash() const { return m_poly.hash(); }
self change(idx_type) const;
self& operator*=(const self&);
self& operator/=(const self&);
self& operator*=(const var_type&);
self& operator/=(const var_type&);
bool_type operator==(const self& rhs) const { return m_poly == rhs.m_poly; }
bool_type operator!=(const self& rhs) const { return m_poly != rhs.m_poly; }
bool_type operator==(constant_type rhs) const { return m_poly == rhs; }
bool_type operator!=(constant_type rhs) const { return m_poly != rhs; }
bool_type isOne() const { return m_poly.isOne(); }
bool_type isConstant() const { return m_poly.isConstant(); }
bool_type reducibleBy(const self& rhs) const {
return m_poly.firstReducibleBy(rhs); }
bool_type reducibleBy(const var_type& rhs) const;
comp_type compare(const self&) const;
deg_type LCMDeg(const self&) const;
self& LCMAssign(const self&);
self LCM(const self&) const;
self& GCDAssign(const self&);
self GCD(const self&) const;
const dd_type& diagram() const { return m_poly.diagram(); }
set_type set() const { return m_poly.set(); }
self& popFirst() {
PBORI_ASSERT(!m_poly.isConstant());
return *this = set_type( dd_type(m_poly.ring(),
m_poly.navigation().thenBranch()) );
}
var_type firstVariable() const;
idx_type firstIndex() const {
return *m_poly.navigation();
}
const ring_type& ring() const { return m_poly.ring(); }
protected:
dd_type& internalDiagram() { return m_poly.internalDiagram(); }
BooleMonomial(const set_type& rhs): m_poly(rhs.diagram()) {
PBORI_ASSERT(!m_poly.isZero());
}
private:
BoolePolynomial m_poly;
};
inline BooleMonomial
operator*(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return BooleMonomial(lhs) *= rhs;
}
inline BooleMonomial
operator*(const BooleMonomial& lhs, const BooleVariable& rhs) {
return BooleMonomial(lhs) *= rhs;
}
inline BoolePolynomial
operator*(const BooleMonomial& lhs, BooleConstant rhs) {
return BoolePolynomial(lhs) *= rhs;
}
inline BoolePolynomial
operator*(BooleConstant lhs, const BooleMonomial& rhs) {
return rhs * lhs;
}
inline BooleMonomial
operator/(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return BooleMonomial(lhs) /= rhs;
}
inline BooleMonomial
operator/(const BooleMonomial& lhs, const BooleVariable& rhs) {
return lhs / BooleMonomial(rhs);
}
inline BooleMonomial::bool_type
operator<(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return (lhs.compare(rhs) == CTypes::less_than);
}
inline BooleMonomial::bool_type
operator>(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return (lhs.compare(rhs) == CTypes::greater_than);
}
inline BooleMonomial::bool_type
operator<=(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return (lhs.compare(rhs) <= CTypes::less_or_equal_max);
}
inline BooleMonomial::bool_type
operator>=(const BooleMonomial& lhs, const BooleMonomial& rhs) {
return (lhs.compare(rhs) >= CTypes::greater_or_equal_min);
}
inline BooleMonomial
GCD(const BooleMonomial& lhs, const BooleMonomial& rhs ){
return lhs.GCD(rhs);
}
inline BooleMonomial
LCM(const BooleMonomial& lhs, const BooleMonomial& rhs ){
return lhs.LCM(rhs);
}
// Anyone need this?
// BooleMonomial::bool_type
// greater_variable(BooleMonomial::idx_type lhs, BooleMonomial::idx_type rhs);
inline BoolePolynomial
operator*(const BooleVariable& lhs, const BooleConstant& rhs){
return BooleMonomial(lhs) * rhs;
}
inline BoolePolynomial
operator*(const BooleConstant& lhs, const BooleVariable& rhs){
return rhs * lhs;
}
inline BoolePolynomial
operator*(const BooleVariable& lhs,
const BoolePolynomial& rhs){
return BoolePolynomial(rhs) *= BooleMonomial(lhs);
}
inline BooleMonomial
operator*(const BooleVariable& lhs,
const BooleMonomial& rhs){
return BooleMonomial(lhs) * rhs;
}
inline BoolePolynomial&
operator*=(BoolePolynomial& lhs,
const BooleVariable& rhs){
return lhs *= BooleMonomial(rhs);
}
inline BooleMonomial
operator*(const BooleVariable& lhs,
const BooleVariable& rhs){
return BooleMonomial(lhs) *= BooleMonomial(rhs);
}
inline BoolePolynomial
operator*(const BoolePolynomial& lhs,
const BooleVariable& rhs){
return BoolePolynomial(lhs) *= BooleMonomial(rhs);
}
inline BoolePolynomial
operator/(const BoolePolynomial& lhs,
const BooleVariable& rhs){
return lhs / BooleMonomial(rhs);
}
inline BoolePolynomial
operator%(const BoolePolynomial& lhs,
const BooleVariable& rhs){
return lhs % BooleMonomial(rhs);
}
END_NAMESPACE_PBORI
#endif // of polybori_BooleMonomial_h_
polybori::BooleMonomial::deg
deg_type deg() const
Degree of the monomial.
Definition: BooleMonomial.h:146
polybori::BooleExponent
This class is just a wrapper for using variables for storing indices as interim data structure for Bo...
Definition: BooleExponent.h:34
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::operator/
BoolePolynomial operator/(const BoolePolynomial &lhs, const BooleVariable &rhs)
Division of a polynomial by a variable (forcing monomial variant)
Definition: BooleMonomial.h:390
polybori::BooleMonomial::var_type
poly_type::var_type var_type
Type of Boolean variables.
Definition: BooleMonomial.h:73
polybori::BooleMonomial::reducibleBy
bool_type reducibleBy(const self &rhs) const
Test for reducibility.
Definition: BooleMonomial.h:190
polybori::BooleMonomial::ring_type
poly_type::ring_type ring_type
Type for Boolean polynomial rings (without ordering)
Definition: BooleMonomial.h:85
polybori::BooleMonomial::GCD
self GCD(const self &) const
Compute the greatest common divisor.
Definition: BooleMonomial.cc:169
polybori::BooleMonomial::BooleMonomial
BooleMonomial(const set_type &rhs)
Construct from decision diagram.
Definition: BooleMonomial.h:242
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::BooleMonomial::idx_map_type
std::map< self, idx_type, symmetric_composition< std::less< poly_type::navigator >, navigates< poly_type > > > idx_map_type
Type for index maps.
Definition: BooleMonomial.h:98
polybori::stable_first_hash_range
void stable_first_hash_range(HashType &seed, NaviType navi)
Definition: pbori_routines_hash.h:60
polybori::BooleMonomial::set
set_type set() const
Get corresponding subset of of the powerset over all variables.
Definition: BooleMonomial.h:216
polybori::BooleSet::diagram
const self & diagram() const
Access internal decision diagram.
Definition: BooleSet.h:231
polybori::BooleMonomial::LCM
self LCM(const self &) const
Compute the least common multiple.
Definition: BooleMonomial.cc:219
polybori::CAuxTypes::deg_type
int deg_type
Type for polynomial degrees (ranges from -1 to maxint)
Definition: pbori_defs.h:222
polybori::groebner::deg_type
int deg_type
Definition: groebner_defs.h:42
polybori::BooleMonomial::begin
const_iterator begin() const
Start iteration over indices.
Definition: BooleMonomial.h:130
polybori::BooleMonomial::popFirst
self & popFirst()
Removes the first variables from monomial.
Definition: BooleMonomial.h:219
polybori::BooleMonomial::internalDiagram
dd_type & internalDiagram()
Access to internal decision diagramm structure.
Definition: BooleMonomial.h:239
polybori::operator%
BoolePolynomial operator%(const BoolePolynomial &lhs, const BooleVariable &rhs)
Remainder of division of a polynomial by a variable.
Definition: BooleMonomial.h:399
polybori::BooleMonomial::BooleMonomial
BooleMonomial(const exp_type &rhs, const ring_type &ring)
Construct from exponent vector.
Definition: BooleMonomial.h:112
polybori::COrderingBase
Definition: COrderingBase.h:43
polybori::BooleMonomial::ostream_type
poly_type::ostream_type ostream_type
Definition: BooleMonomial.h:69
polybori::BooleMonomial::variableBegin
variable_iterator variableBegin() const
Start iteration over variables.
Definition: BooleMonomial.h:136
polybori::BooleMonomial::compare
comp_type compare(const self &) const
Compare with rhs monomial and return comparision code.
Definition: BooleMonomial.cc:115
polybori::BooleMonomial::operator==
bool_type operator==(constant_type rhs) const
Definition: BooleMonomial.h:183
polybori::BooleMonomial::dd_type
poly_type::dd_type dd_type
Definition: BooleMonomial.h:67
polybori::BoolePolyRing
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
polybori::BooleMonomial::end
const_iterator end() const
Finish iteration over indices.
Definition: BooleMonomial.h:133
polybori::BooleMonomial::variable_iterator
CVariableIter< const_iterator, var_type > variable_iterator
Access to iterator over variables.
Definition: BooleMonomial.h:91
polybori::BooleMonomial::firstIndex
idx_type firstIndex() const
Definition: BooleMonomial.h:230
polybori::navigates
Definition: pbori_func.h:722
change
Accessing .change()
polybori::CAuxTypes
This struct contains auxiliary type definitions.
Definition: pbori_defs.h:210
polybori::CDDOperations
Definition: BooleMonomial.h:40
polybori::operator>=
BooleMonomial::bool_type operator>=(const BooleMonomial &lhs, const BooleMonomial &rhs)
Greater or equal than comparision.
Definition: BooleMonomial.h:307
polybori::BooleMonomial::const_iterator
poly_type::first_iterator const_iterator
Access to iterator over indices.
Definition: BooleMonomial.h:88
polybori::BooleMonomial::poly_type
BoolePolynomial poly_type
Type of Boolean polynomials.
Definition: BooleMonomial.h:63
polybori::CAuxTypes::integer_type
int integer_type
Type for integer numbers.
Definition: pbori_defs.h:225
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::GCD
BooleMonomial GCD(const BooleMonomial &lhs, const BooleMonomial &rhs)
Compute the greatest common divisor of two monomials.
Definition: BooleMonomial.h:315
polybori::CAuxTypes::hash_type
std::size_t hash_type
Type for hashing.
Definition: pbori_defs.h:231
polybori::BooleMonomial::stableHash
hash_type stableHash() const
Hash value of the monomial.
Definition: BooleMonomial.h:160
polybori::CVariableIter
This template class defines an iterator for monomial types.
Definition: CVariableIter.h:32
BooleVariable.h
polybori::BooleMonomial::exp_type
poly_type::exp_type exp_type
Type of exponent vector.
Definition: BooleMonomial.h:82
polybori::BooleMonomial::divisors
set_type divisors() const
Divisors of the monomial.
Definition: BooleMonomial.h:154
pbori_defs.h
polybori::BooleMonomial::operator==
bool_type operator==(const self &rhs) const
Definition: BooleMonomial.h:181
polybori::operator<=
BooleMonomial::bool_type operator<=(const BooleMonomial &lhs, const BooleMonomial &rhs)
Less or equal than comparision.
Definition: BooleMonomial.h:300
polybori::BoolePolynomial::ostream_type
CTypes::ostream_type ostream_type
Definition: BoolePolynomial.h:103
polybori::LCM
BooleMonomial LCM(const BooleMonomial &lhs, const BooleMonomial &rhs)
Compute the greatest common divisor of two monomials.
Definition: BooleMonomial.h:322
polybori::BooleMonomial::~BooleMonomial
~BooleMonomial()
Destructor.
Definition: BooleMonomial.h:120
polybori::CTermGeneratorBase
Definition: CTermGenerator.h:151
polybori::operator>
BooleMonomial::bool_type operator>(const BooleMonomial &lhs, const BooleMonomial &rhs)
Greater than comparision.
Definition: BooleMonomial.h:293
polybori::CTermGeneratorBase__
Definition: CTermGenerator.h:34
polybori::BooleMonomial::easy_equality_property
dd_type::easy_equality_property easy_equality_property
The property whether the equality check is easy is inherited from dd_type.
Definition: BooleMonomial.h:101
polybori::BooleMonomial::integer_type
poly_type::integer_type integer_type
Definition: BooleMonomial.h:68
PBORI_ASSERT
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
polybori::symmetric_composition
Compose a binary function with a default constructable unary function for both arguments.
Definition: pbori_func.h:325
polybori::BooleMonomial::BooleMonomial
BooleMonomial(const self &rhs)
Copy constructor.
Definition: BooleMonomial.h:104
BoolePolynomial.h
polybori::BooleMonomial::ring
const ring_type & ring() const
Access ring, where this belongs to.
Definition: BooleMonomial.h:235
polybori::BooleMonomial::BooleMonomial
BooleMonomial(const ring_type &ring)
Construct from given ring.
Definition: BooleMonomial.h:116
polybori::BooleMonomial::operator!=
bool_type operator!=(constant_type rhs) const
Definition: BooleMonomial.h:184
polybori::BooleMonomial::set_type
poly_type::set_type set_type
Type of sets of Boolean variables.
Definition: BooleMonomial.h:79
polybori::CCuddFirstIter
This class defines an iterator over the first minimal term of a given ZDD node.
Definition: CCuddFirstIter.h:35
polybori::operator<
BooleMonomial::bool_type operator<(const BooleMonomial &lhs, const BooleMonomial &rhs)
Less than comparision.
Definition: BooleMonomial.h:286
CVariableIter.h
polybori::BooleMonomial::diagram
const dd_type & diagram() const
Read-only access to internal decision diagramm structure.
Definition: BooleMonomial.h:213
PBoRiError.h
polybori::operator*=
BoolePolynomial & operator*=(BoolePolynomial &lhs, const BooleVariable &rhs)
Multiplication of a polynomial by a variable with assignment.
Definition: BooleMonomial.h:366
polybori::BooleMonomial::isOne
bool_type isOne() const
Definition: BooleMonomial.h:185
polybori::BooleMonomial::size
size_type size() const
Size of the exponents.
Definition: BooleMonomial.h:151
polybori::BooleMonomial::variableEnd
variable_iterator variableEnd() const
Finish iteration over variables.
Definition: BooleMonomial.h:141
polybori::BooleMonomial::isConstant
bool_type isConstant() const
Definition: BooleMonomial.h:186
polybori::groebner::idx_type
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
polybori::operator*
BoolePolynomial operator*(const BoolePolynomial &lhs, const BooleVariable &rhs)
Multiplication of a polynomial by a variable.
Definition: BooleMonomial.h:382
polybori::CAuxTypes::size_type
std::size_t size_type
Type for lengths, dimensions, etc.
Definition: pbori_defs.h:219
polybori::BooleMonomial::constant_type
poly_type::constant_type constant_type
Type of Boolean constants.
Definition: BooleMonomial.h:76
polybori::BooleSet
Definition: BooleSet.h:57
polybori::BooleConstant
This class wraps a bool value, which was not converted to a boolean polynomial or monomial yet...
Definition: BooleConstant.h:40
polybori::BooleMonomial
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
polybori::CAuxTypes::bool_type
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
polybori::BooleMonomial::hash
hash_type hash() const
Get unique hash value (valid only per runtime)
Definition: BooleMonomial.h:165
polybori::BooleVariable
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleVariable.h:39
polybori::valid_tag
This class shows, whether a property of an order is valid.
Definition: tags.h:32
polybori::BooleMonomial::operator!=
bool_type operator!=(const self &rhs) const
Definition: BooleMonomial.h:182