{
Assert(isDefinedKind(k));
Assert(isDefinedIntKind(extToIntKind(k)));
- uint32_t min = CVC4::kind::metakind::getLowerBoundForKind(extToIntKind(k));
+ uint32_t min = CVC4::kind::metakind::getMinArityForKind(extToIntKind(k));
// At the API level, we treat functions/constructors/selectors/testers as
// normal terms instead of making them part of the operator
{
Assert(isDefinedKind(k));
Assert(isDefinedIntKind(extToIntKind(k)));
- uint32_t max = CVC4::kind::metakind::getUpperBoundForKind(extToIntKind(k));
+ uint32_t max = CVC4::kind::metakind::getMaxArityForKind(extToIntKind(k));
// At the API level, we treat functions/constructors/selectors/testers as
// normal terms instead of making them part of the operator
}
unsigned ExprManager::minArity(Kind kind) {
- return metakind::getLowerBoundForKind(kind);
+ return metakind::getMinArityForKind(kind);
}
unsigned ExprManager::maxArity(Kind kind) {
- return metakind::getUpperBoundForKind(kind);
+ return metakind::getMaxArityForKind(kind);
}
bool ExprManager::isNAryKind(Kind fun)
// re-enable the strict-aliasing warning
# pragma GCC diagnostic warning "-Wstrict-aliasing"
-unsigned getLowerBoundForKind(::CVC4::Kind k) {
+uint32_t getMinArityForKind(::CVC4::Kind k)
+{
static const unsigned lbs[] = {
0, /* NULL_EXPR */
${metakind_lbchildren}
return lbs[k];
}
-unsigned getUpperBoundForKind(::CVC4::Kind k) {
+uint32_t getMaxArityForKind(::CVC4::Kind k)
+{
static const unsigned ubs[] = {
0, /* NULL_EXPR */
${metakind_ubchildren}
return ubs[k];
}
-
-}/* CVC4::metakind namespace */
+} // namespace metakind
/**
* Map a kind of the operator to the kind of the enclosing expression. For
*/
void deleteNodeValueConstant(::CVC4::expr::NodeValue* nv);
-unsigned getLowerBoundForKind(::CVC4::Kind k);
-unsigned getUpperBoundForKind(::CVC4::Kind k);
+/** Return the minimum arity of the given kind. */
+uint32_t getMinArityForKind(::CVC4::Kind k);
+/** Return the maximum arity of the given kind. */
+uint32_t getMaxArityForKind(::CVC4::Kind k);
}/* CVC4::kind::metakind namespace */
// check that there are the right # of children for this kind
Assert(getMetaKind() != kind::metakind::CONSTANT)
<< "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds";
- Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind()))
+ Assert(getNumChildren() >= kind::metakind::getMinArityForKind(getKind()))
<< "Nodes with kind " << getKind() << " must have at least "
- << kind::metakind::getLowerBoundForKind(getKind())
+ << kind::metakind::getMinArityForKind(getKind())
<< " children (the one under "
"construction has "
<< getNumChildren() << ")";
- Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind()))
+ Assert(getNumChildren() <= kind::metakind::getMaxArityForKind(getKind()))
<< "Nodes with kind " << getKind() << " must have at most "
- << kind::metakind::getUpperBoundForKind(getKind())
+ << kind::metakind::getMaxArityForKind(getKind())
<< " children (the one under "
"construction has "
<< getNumChildren() << ")";
// check that there are the right # of children for this kind
Assert(getMetaKind() != kind::metakind::CONSTANT)
<< "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds";
- Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind()))
+ Assert(getNumChildren() >= kind::metakind::getMinArityForKind(getKind()))
<< "Nodes with kind " << getKind() << " must have at least "
- << kind::metakind::getLowerBoundForKind(getKind())
+ << kind::metakind::getMinArityForKind(getKind())
<< " children (the one under "
"construction has "
<< getNumChildren() << ")";
- Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind()))
+ Assert(getNumChildren() <= kind::metakind::getMaxArityForKind(getKind()))
<< "Nodes with kind " << getKind() << " must have at most "
- << kind::metakind::getUpperBoundForKind(getKind())
+ << kind::metakind::getMaxArityForKind(getKind())
<< " children (the one under "
"construction has "
<< getNumChildren() << ")";
#include "expr/bound_var_manager.h"
#include "expr/dtype.h"
#include "expr/dtype_cons.h"
+#include "expr/metakind.h"
#include "expr/node_manager_attributes.h"
#include "expr/skolem_manager.h"
#include "expr/type_checker.h"
init();
}
+bool NodeManager::isNAryKind(Kind k)
+{
+ return kind::metakind::getMaxArityForKind(k) == expr::NodeValue::MAX_CHILDREN;
+}
+
TypeNode NodeManager::booleanType()
{
return mkTypeConst<TypeConstant>(BOOLEAN_TYPE);
{
AlwaysAssert(kind::isAssociative(kind)) << "Illegal kind in mkAssociative";
- const unsigned int max = kind::metakind::getUpperBoundForKind(kind);
+ const unsigned int max = kind::metakind::getMaxArityForKind(kind);
size_t numChildren = children.size();
/* If the number of children is within bounds, then there's nothing to do. */
{
return mkNode(kind, children);
}
- const unsigned int min = kind::metakind::getLowerBoundForKind(kind);
+ const unsigned int min = kind::metakind::getMinArityForKind(kind);
std::vector<Node>::const_iterator it = children.begin();
std::vector<Node>::const_iterator end = children.end();
friend class NodeBuilder;
friend class NodeManagerScope;
+ public:
+ /**
+ * Return true if given kind is n-ary. The test is based on n-ary kinds
+ * having their maximal arity as the maximal possible number of children
+ * of a node.
+ */
+ static bool isNAryKind(Kind k);
+
+ private:
/** Predicate for use with STL algorithms */
struct NodeValueReferenceCountNonZero {
bool operator()(expr::NodeValue* nv) { return nv->d_rc > 0; }
namespace CVC4 {
namespace util {
-Node NaryBuilder::mkAssoc(Kind kind, const std::vector<Node>& children){
- if(children.size() == 0){
+Node NaryBuilder::mkAssoc(Kind kind, const std::vector<Node>& children)
+{
+ if (children.size() == 0)
+ {
return zeroArity(kind);
- }else if(children.size() == 1){
+ }
+ else if (children.size() == 1)
+ {
return children[0];
- }else{
- const unsigned int max = kind::metakind::getUpperBoundForKind(kind);
- const unsigned int min = kind::metakind::getLowerBoundForKind(kind);
+ }
+ else
+ {
+ const uint32_t max = kind::metakind::getMaxArityForKind(kind);
+ const uint32_t min = kind::metakind::getMinArityForKind(kind);
Assert(min <= children.size());
// we may have subsumed children down to one
ret = children[0];
}
- else if (isAssoc && children.size() > kind::metakind::getUpperBoundForKind(k))
+ else if (isAssoc
+ && children.size() > kind::metakind::getMaxArityForKind(k))
{
- Assert(kind::metakind::getUpperBoundForKind(k) >= 2);
+ Assert(kind::metakind::getMaxArityForKind(k) >= 2);
// kind may require binary construction
ret = children[0];
for (unsigned i = 1, nchild = children.size(); i < nchild; i++)
// use (= t1 t2) as a premise and rely on a symmetry step to justify it.
unsigned arity = d_node[0].getNumChildren();
Kind k = d_node[0].getKind();
- bool isNary = ExprManager::isNAryKind(k);
+ bool isNary = NodeManager::isNAryKind(k);
// N-ary operators are fun. The following proof is a valid EqProof
//
if ((d_isInternal[id1] || d_isInternal[id2])
&& (k1 != k2 || k1 == kind::APPLY_UF || k1 == kind::APPLY_CONSTRUCTOR
|| k1 == kind::APPLY_SELECTOR || k1 == kind::APPLY_TESTER
- || !ExprManager::isNAryKind(k1)))
+ || !NodeManager::isNAryKind(k1)))
{
return;
}
#ifdef CVC4_ASSERTIONS
ASSERT_DEATH(testNaryExpForSize(AND, 0),
"getNumChildren\\(\\) >= "
- "kind::metakind::getLowerBoundForKind\\(getKind\\(\\)\\)");
+ "kind::metakind::getMinArityForKind\\(getKind\\(\\)\\)");
ASSERT_DEATH(testNaryExpForSize(AND, 1),
"getNumChildren\\(\\) >= "
- "kind::metakind::getLowerBoundForKind\\(getKind\\(\\)\\)");
+ "kind::metakind::getMinArityForKind\\(getKind\\(\\)\\)");
ASSERT_DEATH(testNaryExpForSize(NOT, 0),
"getNumChildren\\(\\) >= "
- "kind::metakind::getLowerBoundForKind\\(getKind\\(\\)\\)");
+ "kind::metakind::getMinArityForKind\\(getKind\\(\\)\\)");
ASSERT_DEATH(testNaryExpForSize(NOT, 2),
"getNumChildren\\(\\) <= "
- "kind::metakind::getUpperBoundForKind\\(getKind\\(\\)\\)");
+ "kind::metakind::getMaxArityForKind\\(getKind\\(\\)\\)");
#endif /* CVC4_ASSERTIONS */
}
{
#ifdef CVC4_ASSERTIONS
std::vector<Node> vars;
- const unsigned int max = metakind::getUpperBoundForKind(AND);
+ const uint32_t max = metakind::getMaxArityForKind(AND);
TypeNode boolType = d_nodeManager->booleanType();
Node skolem_i = d_nodeManager->mkSkolem("i", boolType);
Node skolem_j = d_nodeManager->mkSkolem("j", boolType);