本文整理汇总了C++中TNode::getMetaKind方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::getMetaKind方法的具体用法?C++ TNode::getMetaKind怎么用?C++ TNode::getMetaKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNode
的用法示例。
在下文中一共展示了TNode::getMetaKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isInequalityOnly
bool InequalitySolver::isInequalityOnly(TNode node) {
if (node.getKind() == kind::NOT) {
node = node[0];
}
if (node.getAttribute(IneqOnlyComputedAttribute())) {
return node.getAttribute(IneqOnlyAttribute());
}
if (node.getKind() != kind::EQUAL &&
node.getKind() != kind::BITVECTOR_ULT &&
node.getKind() != kind::BITVECTOR_ULE &&
node.getKind() != kind::CONST_BITVECTOR &&
node.getKind() != kind::SELECT &&
node.getKind() != kind::STORE &&
node.getMetaKind() != kind::metakind::VARIABLE) {
// not worth caching
return false;
}
bool res = true;
for (unsigned i = 0; res && i < node.getNumChildren(); ++i) {
res = res && isInequalityOnly(node[i]);
}
node.setAttribute(IneqOnlyComputedAttribute(), true);
node.setAttribute(IneqOnlyAttribute(), res);
return res;
}
示例2: case_assoccomm
Node RePairAssocCommutativeOperators::case_assoccomm(TNode n){
Kind k = n.getKind();
Assert(isAssociateCommutative(k));
Assert(n.getMetaKind() != kind::metakind::PARAMETERIZED);
unsigned N = n.getNumChildren();
Assert(N >= 2);
Node last = rePairAssocCommutativeOperators( n[N-1]);
Node nextToLast = rePairAssocCommutativeOperators(n[N-2]);
NodeManager* nm = NodeManager::currentNM();
Node last2 = nm->mkNode(k, nextToLast, last);
if(N <= 2){
return last2;
} else{
Assert(N > 2);
Node prevRound = last2;
for(unsigned prevPos = N-2; prevPos > 0; --prevPos){
unsigned currPos = prevPos-1;
Node curr = rePairAssocCommutativeOperators(n[currPos]);
Node round = nm->mkNode(k, curr, prevRound);
prevRound = round;
}
return prevRound;
}
}
示例3: liftNode
Node BvToBoolPreprocessor::liftNode(TNode current) {
Node result;
if (hasLiftCache(current)) {
result = getLiftCache(current);
}else if (isConvertibleBvAtom(current)) {
result = convertBvAtom(current);
addToLiftCache(current, result);
} else {
if (current.getNumChildren() == 0) {
result = current;
} else {
NodeBuilder<> builder(current.getKind());
if (current.getMetaKind() == kind::metakind::PARAMETERIZED) {
builder << current.getOperator();
}
for (unsigned i = 0; i < current.getNumChildren(); ++i) {
Node converted = liftNode(current[i]);
Assert (converted.getType() == current[i].getType());
builder << converted;
}
result = builder;
addToLiftCache(current, result);
}
}
Assert (result != Node());
Assert(result.getType() == current.getType());
Debug("bv-to-bool") << "BvToBoolPreprocessor::liftNode " << current << " => \n" << result << "\n";
return result;
}
示例4: substituteArguments
Node AbstractionModule::substituteArguments(TNode signature, TNode apply, unsigned& index, TNodeTNodeMap& seen) {
if (seen.find(signature) != seen.end()) {
return seen[signature];
}
if (signature.getKind() == kind::SKOLEM) {
// return corresponding argument and increment counter
seen[signature] = apply[index];
return apply[index++];
}
if (signature.getNumChildren() == 0) {
Assert (signature.getKind() != kind::VARIABLE &&
signature.getKind() != kind::SKOLEM);
seen[signature] = signature;
return signature;
}
NodeBuilder<> builder(signature.getKind());
if (signature.getMetaKind() == kind::metakind::PARAMETERIZED) {
builder << signature.getOperator();
}
for (unsigned i = 0; i < signature.getNumChildren(); ++i) {
Node child = substituteArguments(signature[i], apply, index, seen);
builder << child;
}
Node result = builder;
seen[signature]= result;
return result;
}
示例5:
bool CVC4::theory::bv::utils::isEqualityTerm(TNode term, TNodeBoolMap& cache) {
term = term.getKind() == kind::NOT ? term[0] : term;
TNodeBoolMap::const_iterator it = cache.find(term);
if (it != cache.end()) {
return it->second;
}
if (term.getNumChildren() == 0)
return true;
if (theory::Theory::theoryOf(theory::THEORY_OF_TERM_BASED, term) == THEORY_BV) {
Kind k = term.getKind();
if (k != kind::CONST_BITVECTOR &&
k != kind::EQUAL &&
term.getMetaKind() != kind::metakind::VARIABLE) {
cache[term] = false;
return false;
}
}
for (unsigned i = 0; i < term.getNumChildren(); ++i) {
if (!isEqualityTerm(term[i], cache)) {
cache[term] = false;
return false;
}
}
cache[term]= true;
return true;
}
示例6: computeSignatureRec
Node AbstractionModule::computeSignatureRec(TNode node, NodeNodeMap& cache) {
if (cache.find(node) != cache.end()) {
return cache.find(node)->second;
}
if (node.getNumChildren() == 0) {
if (node.getKind() == kind::CONST_BITVECTOR)
return node;
Node sig = getSignatureSkolem(node);
cache[node] = sig;
return sig;
}
NodeBuilder<> builder(node.getKind());
if (node.getMetaKind() == kind::metakind::PARAMETERIZED) {
builder << node.getOperator();
}
for (unsigned i = 0; i < node.getNumChildren(); ++i) {
Node converted = computeSignatureRec(node[i], cache);
builder << converted;
}
Node result = builder;
cache[node] = result;
return result;
}
示例7: isInequalityOnly
bool InequalitySolver::isInequalityOnly(TNode node) {
if (d_ineqOnlyCache.find(node) != d_ineqOnlyCache.end()) {
return d_ineqOnlyCache[node];
}
if (node.getKind() == kind::NOT) {
node = node[0];
}
if (node.getKind() != kind::EQUAL &&
node.getKind() != kind::BITVECTOR_ULT &&
node.getKind() != kind::BITVECTOR_ULE &&
node.getKind() != kind::CONST_BITVECTOR &&
node.getKind() != kind::SELECT &&
node.getKind() != kind::STORE &&
node.getMetaKind() != kind::metakind::VARIABLE) {
return false;
}
bool res = true;
for (unsigned i = 0; i < node.getNumChildren(); ++i) {
res = res && isInequalityOnly(node[i]);
}
d_ineqOnlyCache[node] = res;
return res;
}
示例8: collectModelInfo
void AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel) {
Debug("bitvector-model") << "AlgebraicSolver::collectModelInfo\n";
AlwaysAssert (!d_quickSolver->inConflict());
set<Node> termSet;
d_bv->computeRelevantTerms(termSet);
// collect relevant terms that the bv theory abstracts to variables
// (variables and parametric terms such as select apply_uf)
std::vector<TNode> variables;
std::vector<Node> values;
for (set<Node>::const_iterator it = termSet.begin(); it != termSet.end(); ++it) {
TNode term = *it;
if (term.getType().isBitVector() &&
(term.getMetaKind() == kind::metakind::VARIABLE ||
Theory::theoryOf(term) != THEORY_BV)) {
variables.push_back(term);
values.push_back(term);
}
}
NodeSet leaf_vars;
Debug("bitvector-model") << "Substitutions:\n";
for (unsigned i = 0; i < variables.size(); ++i) {
TNode current = variables[i];
TNode subst = Rewriter::rewrite(d_modelMap->apply(current));
Debug("bitvector-model") << " " << current << " => " << subst << "\n";
values[i] = subst;
utils::collectVariables(subst, leaf_vars);
}
Debug("bitvector-model") << "Model:\n";
for (NodeSet::const_iterator it = leaf_vars.begin(); it != leaf_vars.end(); ++it) {
TNode var = *it;
Node value = d_quickSolver->getVarValue(var, true);
Assert (!value.isNull() || !fullModel);
// may be a shared term that did not appear in the current assertions
if (!value.isNull()) {
Debug("bitvector-model") << " " << var << " => " << value << "\n";
Assert (value.getKind() == kind::CONST_BITVECTOR);
d_modelMap->addSubstitution(var, value);
}
}
Debug("bitvector-model") << "Final Model:\n";
for (unsigned i = 0; i < variables.size(); ++i) {
TNode current = values[i];
TNode subst = Rewriter::rewrite(d_modelMap->apply(current));
Debug("bitvector-model") << "AlgebraicSolver: " << variables[i] << " => " << subst << "\n";
// Doesn't have to be constant as it may be irrelevant
Assert (subst.getKind() == kind::CONST_BITVECTOR);
model->assertEquality(variables[i], subst, true);
}
}
示例9: storeExtract
void ExtractSkolemizer::storeExtract(TNode var, unsigned high, unsigned low) {
Assert (var.getMetaKind() == kind::metakind::VARIABLE);
if (d_varToExtract.find(var) == d_varToExtract.end()) {
d_varToExtract[var] = ExtractList(utils::getSize(var));
}
VarExtractMap::iterator it = d_varToExtract.find(var);
ExtractList& el = it->second;
Extract e(high, low);
el.addExtract(e);
}
示例10: normalize
Node TheoryEngineModelBuilder::normalize(TheoryModel* m, TNode r, std::map< Node, Node >& constantReps, bool evalOnly)
{
std::map<Node, Node>::iterator itMap = constantReps.find(r);
if (itMap != constantReps.end()) {
return (*itMap).second;
}
NodeMap::iterator it = d_normalizedCache.find(r);
if (it != d_normalizedCache.end()) {
return (*it).second;
}
Node retNode = r;
if (r.getNumChildren() > 0) {
std::vector<Node> children;
if (r.getMetaKind() == kind::metakind::PARAMETERIZED) {
children.push_back(r.getOperator());
}
bool childrenConst = true;
for (size_t i=0; i < r.getNumChildren(); ++i) {
Node ri = r[i];
if (!ri.isConst()) {
if (m->d_equalityEngine.hasTerm(ri)) {
ri = m->d_equalityEngine.getRepresentative(ri);
itMap = constantReps.find(ri);
if (itMap != constantReps.end()) {
ri = (*itMap).second;
}
else if (evalOnly) {
ri = normalize(m, r[i], constantReps, evalOnly);
}
}
else {
ri = normalize(m, ri, constantReps, evalOnly);
}
if (!ri.isConst()) {
childrenConst = false;
}
}
children.push_back(ri);
}
retNode = NodeManager::currentNM()->mkNode( r.getKind(), children );
if (childrenConst) {
retNode = Rewriter::rewrite(retNode);
Assert(retNode.getKind() == kind::APPLY_UF || retNode.isConst());
}
}
d_normalizedCache[r] = retNode;
return retNode;
}
示例11: makeFreshSkolems
void AbstractionModule::makeFreshSkolems(TNode node, SubstitutionMap& map, SubstitutionMap& reverse_map) {
if (map.hasSubstitution(node)) {
return;
}
if (node.getMetaKind() == kind::metakind::VARIABLE) {
Node skolem = utils::mkVar(utils::getSize(node));
map.addSubstitution(node, skolem);
reverse_map.addSubstitution(skolem, node);
return;
}
if (node.isConst())
return;
for (unsigned i = 0; i < node.getNumChildren(); ++i) {
makeFreshSkolems(node[i], map, reverse_map);
}
}
示例12: createSimpContext
Node ITESimplifier::createSimpContext(TNode c, Node& iteNode, Node& simpVar)
{
NodeMap::iterator it;
it = d_simpContextCache.find(c);
if (it != d_simpContextCache.end()) {
return (*it).second;
}
if (!containsTermITE(c)) {
d_simpContextCache[c] = c;
return c;
}
if (c.getKind() == kind::ITE && !c.getType().isBoolean()) {
// Currently only support one ite node in a simp context
// Return Null if more than one is found
if (!iteNode.isNull()) {
return Node();
}
simpVar = getSimpVar(c.getType());
if (simpVar.isNull()) {
return Node();
}
d_simpContextCache[c] = simpVar;
iteNode = c;
return simpVar;
}
NodeBuilder<> builder(c.getKind());
if (c.getMetaKind() == kind::metakind::PARAMETERIZED) {
builder << c.getOperator();
}
unsigned i = 0;
for (; i < c.getNumChildren(); ++ i) {
Node newChild = createSimpContext(c[i], iteNode, simpVar);
if (newChild.isNull()) {
return newChild;
}
builder << newChild;
}
// Mark the substitution and continue
Node result = builder;
d_simpContextCache[c] = result;
return result;
}
示例13: case_other
Node RePairAssocCommutativeOperators::case_other(TNode n){
if(n.isConst() || n.isVar()){
return n;
}
NodeBuilder<> nb(n.getKind());
if(n.getMetaKind() == kind::metakind::PARAMETERIZED) {
nb << n.getOperator();
}
// Remove the ITEs from the children
for(TNode::const_iterator i = n.begin(), end = n.end(); i != end; ++i) {
Node newChild = rePairAssocCommutativeOperators(*i);
nb << newChild;
}
Node result = (Node)nb;
return result;
}
示例14: makeFreshArgs
void AbstractionModule::makeFreshArgs(TNode func, std::vector<Node>& fresh_args) {
Assert (fresh_args.size() == 0);
Assert (func.getKind() == kind::APPLY_UF);
TNodeNodeMap d_map;
for (unsigned i = 0; i < func.getNumChildren(); ++i) {
TNode arg = func[i];
if (arg.isConst()) {
fresh_args.push_back(arg);
continue;
}
Assert (arg.getMetaKind() == kind::metakind::VARIABLE);
TNodeNodeMap::iterator it = d_map.find(arg);
if (it != d_map.end()) {
fresh_args.push_back(it->second);
} else {
Node skolem = utils::mkVar(utils::getSize(arg));
d_map[arg] = skolem;
fresh_args.push_back(skolem);
}
}
Assert (fresh_args.size() == func.getNumChildren());
}
示例15: substitute
Node ITESimplifier::substitute(TNode e, TNodeMap& substTable, TNodeMap& cache)
{
TNodeMap::iterator it = cache.find(e), iend = cache.end();
if (it != iend) {
return it->second;
}
// do substitution?
it = substTable.find(e);
iend = substTable.end();
if (it != iend) {
Node result = substitute(it->second, substTable, cache);
cache[e] = result;
return result;
}
size_t sz = e.getNumChildren();
if (sz == 0) {
cache[e] = e;
return e;
}
NodeBuilder<> builder(e.getKind());
if (e.getMetaKind() == kind::metakind::PARAMETERIZED) {
builder << e.getOperator();
}
for (unsigned i = 0; i < e.getNumChildren(); ++ i) {
builder << substitute(e[i], substTable, cache);
}
Node result = builder;
// it = substTable.find(result);
// if (it != iend) {
// result = substitute(it->second, substTable, cache);
// }
cache[e] = result;
return result;
}