/* ------------------------------------------------------------------------- */
-Node mkConjunction(const std::set<TNode> nodes)
-{
- std::set<TNode> expandedNodes;
-
- std::set<TNode>::const_iterator it = nodes.begin();
- std::set<TNode>::const_iterator it_end = nodes.end();
- while (it != it_end)
- {
- TNode current = *it;
- if (current != mkTrue())
- {
- Assert(current.getKind() == kind::EQUAL
- || (current.getKind() == kind::NOT
- && current[0].getKind() == kind::EQUAL));
- expandedNodes.insert(current);
- }
- ++it;
- }
-
- Assert(expandedNodes.size() > 0);
- if (expandedNodes.size() == 1)
- {
- return *expandedNodes.begin();
- }
-
- NodeBuilder<> conjunction(kind::AND);
-
- it = expandedNodes.begin();
- it_end = expandedNodes.end();
- while (it != it_end)
- {
- conjunction << *it;
- ++it;
- }
-
- return conjunction;
-}
-
Node mkConjunction(const std::vector<TNode>& nodes)
{
- std::vector<TNode> expandedNodes;
-
- std::vector<TNode>::const_iterator it = nodes.begin();
- std::vector<TNode>::const_iterator it_end = nodes.end();
- while (it != it_end)
+ NodeBuilder<> conjunction(kind::AND);
+ Node btrue = mkTrue();
+ for (const Node& n : nodes)
{
- TNode current = *it;
-
- if (current != mkTrue())
+ if (n != btrue)
{
- Assert(isBVPredicate(current));
- expandedNodes.push_back(current);
+ Assert(isBVPredicate(n));
+ conjunction << n;
}
- ++it;
- }
-
- if (expandedNodes.size() == 0)
- {
- return mkTrue();
- }
-
- if (expandedNodes.size() == 1)
- {
- return *expandedNodes.begin();
- }
-
- NodeBuilder<> conjunction(kind::AND);
-
- it = expandedNodes.begin();
- it_end = expandedNodes.end();
- while (it != it_end)
- {
- conjunction << *it;
- ++it;
}
-
+ unsigned nchildren = conjunction.getNumChildren();
+ if (nchildren == 0) { return btrue; }
+ if (nchildren == 1) { return conjunction[0]; }
return conjunction;
}
* http://ieeexplore.ieee.org/document/987767 */
Node mkUmulo(TNode t1, TNode t2);
-/* Create conjunction over a set of (dis)equalities. */
-Node mkConjunction(const std::set<TNode> nodes);
+/* Create conjunction. */
Node mkConjunction(const std::vector<TNode>& nodes);
/* Get a set of all operands of nested and nodes. */