5 FormulaContent<Pol>::FormulaContent(FormulaType _type, size_t _id):
6 mHash(std::hash<Constraint<Pol>>()(Constraint<Pol>(_type == FormulaType::TRUE))),
9 mContent(Constraint<Pol>(_type == FormulaType::TRUE))
11 assert(_type == FormulaType::TRUE || _type == FormulaType::FALSE);
12 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << _type);
15 template<typename Pol>
16 FormulaContent<Pol>::FormulaContent(Variable _variable):
17 mHash(std::hash<Variable>()(_variable)),
20 switch (_variable.type()) {
21 case VariableType::VT_BOOL:
27 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << _variable);
30 template<typename Pol>
31 FormulaContent<Pol>::FormulaContent(Constraint<Pol>&& _constraint):
32 mHash( std::hash<Constraint<Pol>>()(_constraint) ),
33 mType(FormulaType::CONSTRAINT),
34 mContent(std::move(_constraint))
36 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << std::get<Constraint<Pol>>(mContent));
39 template<typename Pol>
40 FormulaContent<Pol>::FormulaContent(VariableComparison<Pol>&& _variableComparison):
41 mHash(std::hash<VariableComparison<Pol>>()(_variableComparison)),
42 mType(FormulaType::VARCOMPARE),
43 mContent(std::move(_variableComparison))
45 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << std::get<VariableComparison<Pol>>(mContent));
48 template<typename Pol>
49 FormulaContent<Pol>::FormulaContent(VariableAssignment<Pol>&& _variableAssignment):
50 mHash(std::hash<VariableAssignment<Pol>>()(_variableAssignment)),
51 mType(FormulaType::VARASSIGN),
52 mContent(std::move(_variableAssignment))
54 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << std::get<VariableAssignment<Pol>>(mContent));
57 template<typename Pol>
58 FormulaContent<Pol>::FormulaContent(BVConstraint&& _constraint):
59 mHash( ((size_t) _constraint.id()) << (sizeof(size_t)*4) ),
60 mType(FormulaType::BITVECTOR),
61 mContent(std::move(_constraint))
63 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << std::get<BVConstraint>(mContent));
67 template<typename Pol>
68 FormulaContent<Pol>::FormulaContent( UEquality&& _ueq ):
69 mHash( std::hash<UEquality>()( _ueq ) ),
70 mType(FormulaType::UEQ),
71 mContent(std::move(_ueq))
73 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << std::get<UEquality>(mContent));
76 template<typename Pol>
77 FormulaContent<Pol>::FormulaContent(FormulaType _type, Formula<Pol>&& _subformula):
78 mHash( ((size_t)NOT << 5) ^ _subformula.hash() ),
80 mContent(std::move(_subformula))
82 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << _type << " " << std::get<Formula<Pol>>(mContent));
85 template<typename Pol>
86 FormulaContent<Pol>::FormulaContent(FormulaType _type, const std::initializer_list<Formula<Pol>>& _subformula):
87 FormulaContent(_type, std::move(Formulas<Pol>(_subformula.begin(), _subformula.end())))
90 template<typename Pol>
91 FormulaContent<Pol>::FormulaContent(FormulaType _type, Formulas<Pol>&& _subformulas):
92 mHash( (size_t)_type ),
94 mContent( std::move(_subformulas) )
96 assert( !std::get<Formulas<Pol>>(mContent).empty() );
98 std::get<Formulas<Pol>>(mContent).shrink_to_fit();
99 for (const auto& subformula: std::get<Formulas<Pol>>(mContent)) {
100 carl::hash_add(mHash, subformula.hash());
102 CARL_LOG_DEBUG("carl.formula", "Created " << *this << " from " << _type << " " << std::get<Formulas<Pol>>(mContent));
105 template<typename Pol>
106 FormulaContent<Pol>::FormulaContent(FormulaType _type, std::vector<carl::Variable>&& _vars, const Formula<Pol>& _term):
107 ///@todo Construct reasonable hash
108 mHash( _term.hash() ),
110 mContent(QuantifierContent<Pol>(std::move(_vars), std::move(Formula<Pol>(_term))))
112 assert(_type == FormulaType::EXISTS || _type == FormulaType::FORALL);
115 template<typename Pol>
116 bool FormulaContent<Pol>::operator==(const FormulaContent& _content) const {
117 CARL_LOG_TRACE("carl.formula", *this << " == " << _content << " (" << mId << " / " << _content.mId << ")");
118 if (mId != 0 && _content.mId != 0) return mId == _content.mId;
119 if (mType != _content.mType) return false;
120 if (mType == FormulaType::TRUE || mType == FormulaType::FALSE) {
123 return mContent == _content.mContent;