本文整理汇总了C++中TNode::getOperator方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::getOperator方法的具体用法?C++ TNode::getOperator怎么用?C++ TNode::getOperator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNode
的用法示例。
在下文中一共展示了TNode::getOperator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equiv
bool TheoryUFTim::equiv(TNode x, TNode y) {
Assert(x.getKind() == kind::APPLY_UF);
Assert(y.getKind() == kind::APPLY_UF);
if(x.getNumChildren() != y.getNumChildren()) {
return false;
}
if(x.getOperator() != y.getOperator()) {
return false;
}
// intentionally don't look at operator
TNode::iterator xIter = x.begin();
TNode::iterator yIter = y.begin();
while(xIter != x.end()) {
if(!sameCongruenceClass(*xIter, *yIter)) {
return false;
}
++xIter;
++yIter;
}
return true;
}
示例2: 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;
}
示例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: 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;
}
示例5: addTerm
/** add term */
void TheoryModel::addTerm(TNode n ){
Assert(d_equalityEngine.hasTerm(n));
//must collect UF terms
if (n.getKind()==APPLY_UF) {
Node op = n.getOperator();
if( std::find( d_uf_terms[ op ].begin(), d_uf_terms[ op ].end(), n )==d_uf_terms[ op ].end() ){
d_uf_terms[ op ].push_back( n );
Trace("model-add-term-uf") << "Add term " << n << std::endl;
}
}
}
示例6: rewriteAs
Node ModelPostprocessor::rewriteAs(TNode n, TypeNode asType) {
if(n.getType().isSubtypeOf(asType)) {
// good to go, we have the right type
return n;
}
if(!n.isConst()) {
// we don't handle non-const right now
return n;
}
if(asType.isBoolean()) {
if(n.getType().isBitVector(1u)) {
// type mismatch: should only happen for Boolean-term conversion under
// datatype constructor applications; rewrite from BV(1) back to Boolean
bool tf = (n.getConst<BitVector>().getValue() == 1);
return NodeManager::currentNM()->mkConst(tf);
}
if(n.getType().isDatatype() && n.getType().hasAttribute(BooleanTermAttr())) {
// type mismatch: should only happen for Boolean-term conversion under
// datatype constructor applications; rewrite from datatype back to Boolean
Assert(n.getKind() == kind::APPLY_CONSTRUCTOR);
Assert(n.getNumChildren() == 0);
// we assume (by construction) false is first; see boolean_terms.cpp
bool tf = (Datatype::indexOf(n.getOperator().toExpr()) == 1);
Debug("boolean-terms") << "+++ rewriteAs " << n << " : " << asType << " ==> " << tf << endl;
return NodeManager::currentNM()->mkConst(tf);
}
}
if(n.getType().isBoolean()) {
bool tf = n.getConst<bool>();
if(asType.isBitVector(1u)) {
return NodeManager::currentNM()->mkConst(BitVector(1u, tf ? 1u : 0u));
}
if(asType.isDatatype() && asType.hasAttribute(BooleanTermAttr())) {
const Datatype& asDatatype = asType.getConst<Datatype>();
return NodeManager::currentNM()->mkNode(kind::APPLY_CONSTRUCTOR, (tf ? asDatatype[0] : asDatatype[1]).getConstructor());
}
}
if(n.getType().isRecord() && asType.isRecord()) {
Debug("boolean-terms") << "+++ got a record - rewriteAs " << n << " : " << asType << endl;
const Record& rec CVC4_UNUSED = n.getType().getConst<Record>();
const Record& asRec = asType.getConst<Record>();
Assert(rec.getNumFields() == asRec.getNumFields());
Assert(n.getNumChildren() == asRec.getNumFields());
NodeBuilder<> b(n.getKind());
b << asType;
for(size_t i = 0; i < n.getNumChildren(); ++i) {
b << rewriteAs(n[i], TypeNode::fromType(asRec[i].second));
}
Node out = b;
Debug("boolean-terms") << "+++ returning record " << out << endl;
return out;
}
示例7: toCaseOperator
void PicklerPrivate::toCaseOperator(TNode n)
{
Kind k = n.getKind();
kind::MetaKind m = metaKindOf(k);
Assert(m == kind::metakind::PARAMETERIZED || m == kind::metakind::OPERATOR);
if(m == kind::metakind::PARAMETERIZED) {
toCaseNode(n.getOperator());
}
for(TNode::iterator i = n.begin(), i_end = n.end(); i != i_end; ++i) {
toCaseNode(*i);
}
d_current << mkOperatorHeader(k, n.getNumChildren());
}
示例8: Assert
/**
* Assumes the stack without top is consistent, and checks that the
* full stack is consistent
*
* @param stack
*
* @return
*/
bool AbstractionModule::LemmaInstantiatior::isConsistent(const vector<int>& stack) {
if (stack.empty())
return true;
unsigned current = stack.size() - 1;
TNode func = d_functions[current];
ArgsTableEntry& matches = d_argsTable.getEntry(func.getOperator());
ArgsVec& args = matches.getEntry(stack[current]);
Assert (args.size() == func.getNumChildren());
for (unsigned k = 0; k < args.size(); ++k) {
TNode s = func[k];
TNode t = args[k];
TNode s0 = s;
while (d_subst.hasSubstitution(s0)) {
s0 = d_subst.getSubstitution(s0);
}
TNode t0 = t;
while (d_subst.hasSubstitution(t0)) {
t0 = d_subst.getSubstitution(t0);
}
if (s0.isConst() && t0.isConst()) {
if (s0 != t0)
return false; // fail
else
continue;
}
if(s0.getMetaKind() == kind::metakind::VARIABLE &&
t0.isConst()) {
d_subst.addSubstitution(s0, t0);
continue;
}
if (s0.isConst() &&
t0.getMetaKind() == kind::metakind::VARIABLE) {
d_subst.addSubstitution(t0, s0);
continue;
}
Assert (s0.getMetaKind() == kind::metakind::VARIABLE &&
t0.getMetaKind() == kind::metakind::VARIABLE);
if (s0 != t0) {
d_subst.addSubstitution(s0, t0);
}
}
return true;
}
示例9: 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;
}
示例10: 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;
}
示例11: blastChain
Node TheoryBuiltinRewriter::blastChain(TNode in) {
Assert(in.getKind() == kind::CHAIN);
Kind chainedOp = in.getOperator().getConst<Chain>().getOperator();
if(in.getNumChildren() == 2) {
// if this is the case exactly 1 pair will be generated so the
// AND is not required
return NodeManager::currentNM()->mkNode(chainedOp, in[0], in[1]);
} else {
NodeBuilder<> conj(kind::AND);
for(TNode::iterator i = in.begin(), j = i + 1; j != in.end(); ++i, ++j) {
conj << NodeManager::currentNM()->mkNode(chainedOp, *i, *j);
}
return conj;
}
}
示例12: ppRewrite
Node TheoryUF::ppRewrite(TNode node) {
if (node.getKind() != kind::APPLY_UF) {
return node;
}
// perform the callbacks requested by TheoryUF::registerPpRewrite()
RegisterPpRewrites::iterator c = d_registeredPpRewrites.find(node.getOperator());
if (c == d_registeredPpRewrites.end()) {
return node;
} else {
Node res = c->second->ppRewrite(node);
if (res != node) {
return ppRewrite(res);
} else {
return res;
}
}
}
示例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: getInterpretation
Node AbstractionModule::getInterpretation(TNode node) {
Assert (isAbstraction(node));
TNode constant = node[0].getKind() == kind::CONST_BITVECTOR ? node[0] : node[1];
TNode apply = node[0].getKind() == kind::APPLY_UF ? node[0] : node[1];
Assert (constant.getKind() == kind::CONST_BITVECTOR &&
apply.getKind() == kind::APPLY_UF);
Node func = apply.getOperator();
Assert (d_funcToSignature.find(func) != d_funcToSignature.end());
Node sig = d_funcToSignature[func];
// substitute arguments in signature
TNodeTNodeMap seen;
unsigned index = 0;
Node result = substituteArguments(sig, apply, index, seen);
Assert (result.getType().isBoolean());
Assert (index == apply.getNumChildren());
// Debug("bv-abstraction") << "AbstractionModule::getInterpretation " << node << "\n";
// Debug("bv-abstraction") << " => " << result << "\n";
return result;
}
示例15: removeToFPGeneric
Node removeToFPGeneric (TNode node) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_GENERIC);
FloatingPointToFPGeneric info = node.getOperator().getConst<FloatingPointToFPGeneric>();
size_t children = node.getNumChildren();
Node op;
if (children == 1) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPIEEEBitVector(info.t.exponent(),
info.t.significand()));
return NodeManager::currentNM()->mkNode(op, node[0]);
} else {
Assert(children == 2);
Assert(node[0].getType().isRoundingMode());
TypeNode t = node[1].getType();
if (t.isFloatingPoint()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPFloatingPoint(info.t.exponent(),
info.t.significand()));
} else if (t.isReal()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPReal(info.t.exponent(),
info.t.significand()));
} else if (t.isBitVector()) {
op = NodeManager::currentNM()->mkConst(FloatingPointToFPSignedBitVector(info.t.exponent(),
info.t.significand()));
} else {
throw TypeCheckingExceptionPrivate(node, "cannot rewrite to_fp generic due to incorrect type of second argument");
}
return NodeManager::currentNM()->mkNode(op, node[0], node[1]);
}
Unreachable("to_fp generic not rewritten");
}