本文整理汇总了C++中NodeManager::mkSkolem方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeManager::mkSkolem方法的具体用法?C++ NodeManager::mkSkolem怎么用?C++ NodeManager::mkSkolem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeManager
的用法示例。
在下文中一共展示了NodeManager::mkSkolem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSignatureSkolem
Node AbstractionModule::getSignatureSkolem(TNode node) {
Assert (node.getKind() == kind::VARIABLE);
unsigned bitwidth = utils::getSize(node);
if (d_signatureSkolems.find(bitwidth) == d_signatureSkolems.end()) {
d_signatureSkolems[bitwidth] = vector<Node>();
}
vector<Node>& skolems = d_signatureSkolems[bitwidth];
// get the index of bv variables of this size
unsigned index = getBitwidthIndex(bitwidth);
Assert (skolems.size() + 1 >= index );
if (skolems.size() == index) {
ostringstream os;
os << "sig_" <<bitwidth <<"_" << index;
NodeManager* nm = NodeManager::currentNM();
skolems.push_back(nm->mkSkolem(os.str(), nm->mkBitVectorType(bitwidth), "skolem for computing signatures"));
}
++(d_signatureIndices[bitwidth]);
return skolems[index];
}
示例2: run
Node RemoveITE::run(TNode node, std::vector<Node>& output,
IteSkolemMap& iteSkolemMap) {
// Current node
Debug("ite") << "removeITEs(" << node << ")" << endl;
// The result may be cached already
NodeManager *nodeManager = NodeManager::currentNM();
ITECache::iterator i = d_iteCache.find(node);
if(i != d_iteCache.end()) {
Node cachedRewrite = (*i).second;
Debug("ite") << "removeITEs: in-cache: " << cachedRewrite << endl;
return cachedRewrite.isNull() ? Node(node) : cachedRewrite;
}
// If an ITE replace it
if(node.getKind() == kind::ITE) {
TypeNode nodeType = node.getType();
if(!nodeType.isBoolean()) {
// Make the skolem to represent the ITE
Node skolem = nodeManager->mkSkolem("termITE_$$", nodeType, "a variable introduced due to term-level ITE removal");
// The new assertion
Node newAssertion =
nodeManager->mkNode(kind::ITE, node[0], skolem.eqNode(node[1]),
skolem.eqNode(node[2]));
Debug("ite") << "removeITEs(" << node << ") => " << newAssertion << endl;
// Attach the skolem
d_iteCache[node] = skolem;
// Remove ITEs from the new assertion, rewrite it and push it to the output
newAssertion = run(newAssertion, output, iteSkolemMap);
iteSkolemMap[skolem] = output.size();
output.push_back(newAssertion);
// The representation is now the skolem
return skolem;
}
}
// If not an ITE, go deep
if( node.getKind() != kind::FORALL &&
node.getKind() != kind::EXISTS &&
node.getKind() != kind::REWRITE_RULE ) {
vector<Node> newChildren;
bool somethingChanged = false;
if(node.getMetaKind() == kind::metakind::PARAMETERIZED) {
newChildren.push_back(node.getOperator());
}
// Remove the ITEs from the children
for(TNode::const_iterator it = node.begin(), end = node.end(); it != end; ++it) {
Node newChild = run(*it, output, iteSkolemMap);
somethingChanged |= (newChild != *it);
newChildren.push_back(newChild);
}
// If changes, we rewrite
if(somethingChanged) {
Node cachedRewrite = nodeManager->mkNode(node.getKind(), newChildren);
d_iteCache[node] = cachedRewrite;
return cachedRewrite;
} else {
d_iteCache[node] = Node::null();
return node;
}
} else {
d_iteCache[node] = Node::null();
return node;
}
}
示例3: applyInternal
PreprocessingPassResult SygusAbduct::applyInternal(
AssertionPipeline* assertionsToPreprocess)
{
NodeManager* nm = NodeManager::currentNM();
Trace("sygus-abduct") << "Run sygus abduct..." << std::endl;
Trace("sygus-abduct-debug") << "Collect symbols..." << std::endl;
std::unordered_set<Node, NodeHashFunction> symset;
std::vector<Node>& asserts = assertionsToPreprocess->ref();
// do we have any assumptions, e.g. via check-sat-assuming?
bool usingAssumptions = (assertionsToPreprocess->getNumAssumptions() > 0);
// The following is our set of "axioms". We construct this set only when the
// usingAssumptions (above) is true. In this case, our input formula is
// partitioned into Fa ^ Fc as described in the header of this class, where:
// - The conjunction of assertions marked as assumptions are the negated
// conjecture Fc, and
// - The conjunction of all other assertions are the axioms Fa.
std::vector<Node> axioms;
for (size_t i = 0, size = asserts.size(); i < size; i++)
{
expr::getSymbols(asserts[i], symset);
// if we are not an assumption, add it to the set of axioms
if (usingAssumptions && i < assertionsToPreprocess->getAssumptionsStart())
{
axioms.push_back(asserts[i]);
}
}
Trace("sygus-abduct-debug")
<< "...finish, got " << symset.size() << " symbols." << std::endl;
Trace("sygus-abduct-debug") << "Setup symbols..." << std::endl;
std::vector<Node> syms;
std::vector<Node> vars;
std::vector<Node> varlist;
std::vector<TypeNode> varlistTypes;
for (const Node& s : symset)
{
TypeNode tn = s.getType();
if (tn.isFirstClass())
{
std::stringstream ss;
ss << s;
Node var = nm->mkBoundVar(tn);
syms.push_back(s);
vars.push_back(var);
Node vlv = nm->mkBoundVar(ss.str(), tn);
varlist.push_back(vlv);
varlistTypes.push_back(tn);
}
}
Trace("sygus-abduct-debug") << "...finish" << std::endl;
Trace("sygus-abduct-debug") << "Make abduction predicate..." << std::endl;
// make the abduction predicate to synthesize
TypeNode abdType = varlistTypes.empty() ? nm->booleanType()
: nm->mkPredicateType(varlistTypes);
Node abd = nm->mkBoundVar("A", abdType);
Trace("sygus-abduct-debug") << "...finish" << std::endl;
Trace("sygus-abduct-debug") << "Make abduction predicate app..." << std::endl;
std::vector<Node> achildren;
achildren.push_back(abd);
achildren.insert(achildren.end(), vars.begin(), vars.end());
Node abdApp = vars.empty() ? abd : nm->mkNode(APPLY_UF, achildren);
Trace("sygus-abduct-debug") << "...finish" << std::endl;
Trace("sygus-abduct-debug") << "Set attributes..." << std::endl;
// set the sygus bound variable list
Node abvl = nm->mkNode(BOUND_VAR_LIST, varlist);
abd.setAttribute(theory::SygusSynthFunVarListAttribute(), abvl);
Trace("sygus-abduct-debug") << "...finish" << std::endl;
Trace("sygus-abduct-debug") << "Make conjecture body..." << std::endl;
Node input = asserts.size() == 1 ? asserts[0] : nm->mkNode(AND, asserts);
input = input.substitute(syms.begin(), syms.end(), vars.begin(), vars.end());
// A(x) => ~input( x )
input = nm->mkNode(OR, abdApp.negate(), input.negate());
Trace("sygus-abduct-debug") << "...finish" << std::endl;
Trace("sygus-abduct-debug") << "Make conjecture..." << std::endl;
Node res = input.negate();
if (!vars.empty())
{
Node bvl = nm->mkNode(BOUND_VAR_LIST, vars);
// exists x. ~( A( x ) => ~input( x ) )
res = nm->mkNode(EXISTS, bvl, res);
}
// sygus attribute
Node sygusVar = nm->mkSkolem("sygus", nm->booleanType());
theory::SygusAttribute ca;
sygusVar.setAttribute(ca, true);
Node instAttr = nm->mkNode(INST_ATTRIBUTE, sygusVar);
std::vector<Node> iplc;
iplc.push_back(instAttr);
if (!axioms.empty())
{
Node aconj = axioms.size() == 1 ? axioms[0] : nm->mkNode(AND, axioms);
aconj =
aconj.substitute(syms.begin(), syms.end(), vars.begin(), vars.end());
Trace("sygus-abduct") << "---> Assumptions: " << aconj << std::endl;
//.........这里部分代码省略.........
示例4: finalizeSignatures
void AbstractionModule::finalizeSignatures() {
NodeManager* nm = NodeManager::currentNM();
Debug("bv-abstraction") << "AbstractionModule::finalizeSignatures num signatures = " << d_signatures.size() <<"\n";
TNodeSet new_signatures;
// "unify" signatures
for (SignatureMap::const_iterator ss = d_signatures.begin(); ss != d_signatures.end(); ++ss) {
for (SignatureMap::const_iterator tt = ss; tt != d_signatures.end(); ++tt) {
TNode t = getGeneralization(tt->first);
TNode s = getGeneralization(ss->first);
if (t != s) {
int status = comparePatterns(s, t);
Assert (status);
if (status < 0)
continue;
if (status == 1) {
storeGeneralization(t, s);
} else {
storeGeneralization(s, t);
}
}
}
}
// keep only most general signatures
for (SignatureMap::iterator it = d_signatures.begin(); it != d_signatures.end(); ) {
TNode sig = it->first;
TNode gen = getGeneralization(sig);
if (sig != gen) {
Assert (d_signatures.find(gen) != d_signatures.end());
// update the count
d_signatures[gen]+= d_signatures[sig];
d_signatures.erase(it++);
} else {
++it;
}
}
// remove signatures that are not frequent enough
for (SignatureMap::iterator it = d_signatures.begin(); it != d_signatures.end(); ) {
if (it->second <= 7) {
d_signatures.erase(it++);
} else {
++it;
}
}
for (SignatureMap::const_iterator it = d_signatures.begin(); it != d_signatures.end(); ++it) {
TNode signature = it->first;
// we already processed this signature
Assert (d_signatureToFunc.find(signature) == d_signatureToFunc.end());
Debug("bv-abstraction") << "Processing signature " << signature << " count " << it->second << "\n";
std::vector<TypeNode> arg_types;
TNodeSet seen;
collectArgumentTypes(signature, arg_types, seen);
Assert (signature.getType().isBoolean());
// make function return a bitvector of size 1
//Node bv_function = utils::mkNode(kind::ITE, signature, utils::mkConst(1, 1u), utils::mkConst(1, 0u));
TypeNode range = NodeManager::currentNM()->mkBitVectorType(1);
TypeNode abs_type = nm->mkFunctionType(arg_types, range);
Node abs_func = nm->mkSkolem("abs_$$", abs_type, "abstraction function for bv theory");
Debug("bv-abstraction") << " abstracted by function " << abs_func << "\n";
// NOTE: signature expression type is BOOLEAN
d_signatureToFunc[signature] = abs_func;
d_funcToSignature[abs_func] = signature;
}
d_statistics.d_numFunctionsAbstracted.setData(d_signatureToFunc.size());
Debug("bv-abstraction") << "AbstractionModule::finalizeSignatures abstracted " << d_signatureToFunc.size() << " signatures. \n";
}