本文整理汇总了C++中CNode::contains_term方法的典型用法代码示例。如果您正苦于以下问题:C++ CNode::contains_term方法的具体用法?C++ CNode::contains_term怎么用?C++ CNode::contains_term使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNode
的用法示例。
在下文中一共展示了CNode::contains_term方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eliminate_var_rec
CNode* VariableEliminator::eliminate_var_rec(CNode* node,
VariableTerm* evar, CNode* active_constraint)
{
CNode* and_c = Connective::make(AND, node, active_constraint);
/*CNode* canonical = and_c->make_canonical();
Solver s(canonical, UNSAT_SIMPLIFY);
CNode* res_c = s.get_result();
if(res_c->get_type() == FALSE_NODE) return False::make(); */
if(DEBUG) {
cout << "CUR CONSTRAINT: " << node->to_string() << endl;
cout << "Active constraint: " << active_constraint->to_string() << endl;
}
if(!and_c->contains_term(evar)){
if(DEBUG) {
cout << "Does not contain var to eliminate " << endl;
cout << "Result: " << and_c->to_string() << endl;
}
return and_c;
}
/*
* If we can find an equality like t=T', then substitute
* every occurence of t in the subtree with T'.
*/
Term* sub = and_c->contains_term_equality(evar);
if(sub != NULL) {
if(DEBUG){
cout << "Simple substitution found! " << evar->to_string()
<< "-> " << sub->to_string() << " in constraint: " <<
and_c->to_string() << endl;
}
map<Term*, Term*> sub_map;
sub_map[evar] = sub;
CNode* res = and_c->substitute(sub_map);
if(DEBUG) {
cout << "Result: " << res->to_string() << endl;
}
return res;
}
if(and_c->is_conjunct())
{
simplify = true;
CNode* res = eliminate_var_conjunct(and_c, evar);
CNode* simp_res = res;
if(DEBUG) {
cout << "Base case (conjunct) " << endl;
//cout << "Result: " << res->to_string() << endl;
}
return simp_res;
}
if(node->is_conjunct())
{
CNode* res = eliminate_var_rec(and_c, evar, True::make());
if(DEBUG) {
cout << "Pseudo base-case: " << endl;
cout << "Result: " << res->to_string() << endl;
}
return res;
}
assert(node->is_connective());
Connective* parent = (Connective*) node;
bool changed = false;
set<CNode*> new_children;
set<CNode*>::const_iterator it = parent->get_operands().begin();
if(parent->get_type() == OR)
{
bool and_active_constraint = false;
it = parent->get_operands().begin();
for(; it!= parent->get_operands().end() ;it++)
{
CNode* child = *it;
if(!child->contains_term(evar)) {
and_active_constraint = true;
new_children.insert(child);
continue;
}
CNode* new_child = eliminate_var_rec(child, evar,
active_constraint);
if(new_child->get_type() == TRUE_NODE) {
return True::make();
}
if(new_child != child) {
changed = true;
}
new_children.insert(new_child);
//.........这里部分代码省略.........