Trace("cbqi-debug") << "Do cbqi for " << q << std::endl;
//add cbqi lemma
//get the counterexample literal
- Node ceLit = d_quantEngine->getTermUtil()->getCounterexampleLiteral( q );
+ Node ceLit = getCounterexampleLiteral(q);
Node ceBody = d_quantEngine->getTermUtil()->getInstConstantBody( q );
if( !ceBody.isNull() ){
//add counterexample lemma
d_parent_quant[q].push_back( qi );
d_children_quant[qi].push_back( q );
Assert( hasAddedCbqiLemma( qi ) );
- Node qicel = d_quantEngine->getTermUtil()->getCounterexampleLiteral( qi );
+ Node qicel = getCounterexampleLiteral(qi);
dep.push_back( qi );
dep.push_back( qicel );
}
if( d_quantEngine->getModel()->isQuantifierActive( q ) ){
d_active_quant[q] = true;
Debug("cbqi-debug") << "Check quantified formula " << q << "..." << std::endl;
- Node cel = d_quantEngine->getTermUtil()->getCounterexampleLiteral( q );
+ Node cel = getCounterexampleLiteral(q);
bool value;
if( d_quantEngine->getValuation().hasSatValue( cel, value ) ){
Debug("cbqi-debug") << "...CE Literal has value " << value << std::endl;
}
}
+Node InstStrategyCegqi::getCounterexampleLiteral(Node q)
+{
+ std::map<Node, Node>::iterator it = d_ce_lit.find(q);
+ if (it != d_ce_lit.end())
+ {
+ return it->second;
+ }
+ NodeManager * nm = NodeManager::currentNM();
+ Node g = nm->mkSkolem("g", nm->booleanType());
+ // ensure that it is a SAT literal
+ Node ceLit = d_quantEngine->getValuation().ensureLiteral(g);
+ d_ce_lit[q] = ceLit;
+ return ceLit;
+}
+
bool InstStrategyCegqi::doAddInstantiation( std::vector< Node >& subs ) {
Assert( !d_curr_quant.isNull() );
//if doing partial quantifier elimination, record the instantiation and set the incomplete flag instead of sending instantiation lemma
bool hasAddedCbqiLemma( Node q ) { return d_added_cbqi_lemma.find( q )!=d_added_cbqi_lemma.end(); }
/** process functions */
void process(Node q, Theory::Effort effort, int e);
+ /**
+ * Get counterexample literal. This is the fresh Boolean variable whose
+ * semantics is "there exists a set of values for which the body of
+ * quantified formula q does not hold". These literals are cached by this
+ * class.
+ */
+ Node getCounterexampleLiteral(Node q);
+ /** map from universal quantifiers to their counterexample literals */
+ std::map<Node, Node> d_ce_lit;
//for identification
uint64_t d_qid_count;
}
}
-Node TermUtil::getCounterexampleLiteral( Node q ){
- if( d_ce_lit.find( q )==d_ce_lit.end() ){
- /*
- Node ceBody = getInstConstantBody( f );
- //check if any variable are of bad types, and fail if so
- for( size_t i=0; i<d_inst_constants[f].size(); i++ ){
- if( d_inst_constants[f][i].getType().isBoolean() ){
- d_ce_lit[ f ] = Node::null();
- return Node::null();
- }
- }
- */
- Node g = NodeManager::currentNM()->mkSkolem( "g", NodeManager::currentNM()->booleanType() );
- //otherwise, ensure literal
- Node ceLit = d_quantEngine->getValuation().ensureLiteral( g );
- d_ce_lit[ q ] = ceLit;
- }
- return d_ce_lit[ q ];
-}
-
Node TermUtil::substituteBoundVariablesToInstConstants(Node n, Node q)
{
registerQuantifier( q );
std::map< Node, std::map< Node, unsigned > > d_var_num;
/** map from universal quantifiers to their inst constant body */
std::map< Node, Node > d_inst_const_body;
- /** map from universal quantifiers to their counterexample literals */
- std::map< Node, Node > d_ce_lit;
/** instantiation constants to universal quantifiers */
std::map< Node, Node > d_inst_constants_map;
public:
unsigned getNumInstantiationConstants( Node q ) const;
/** get the ce body q[e/x] */
Node getInstConstantBody( Node q );
- /** get counterexample literal (for cbqi) */
- Node getCounterexampleLiteral( Node q );
/** returns node n with bound vars of q replaced by instantiation constants of q
node n : is the future pattern
node q : is the quantifier containing which bind the variable