static void getBoundVars( Node n, std::vector< Node >& bvs);
//for skolem
private:
- /** map from universal quantifiers to the list of skolem constants */
- std::map< Node, std::vector< Node > > d_skolem_constants;
/** map from universal quantifiers to their skolemized body */
std::map< Node, Node > d_skolem_body;
public:
+ /** map from universal quantifiers to the list of skolem constants */
+ std::map< Node, std::vector< Node > > d_skolem_constants;
/** make the skolemized body f[e/x] */
static Node mkSkolemizedBody( Node f, Node n, std::vector< TypeNode >& fvTypes, std::vector< TNode >& fvs,
std::vector< Node >& sk );
void TheoryQuantifiers::assertUniversal( Node n ){
Assert( n.getKind()==FORALL );
if( options::recurseCbqi() || !TermDb::hasInstConstAttr(n) ){
- getQuantifiersEngine()->registerQuantifier( n );
- getQuantifiersEngine()->assertNode( n );
+ getQuantifiersEngine()->assertQuantifier( n, true );
}
}
void TheoryQuantifiers::assertExistential( Node n ){
Assert( n.getKind()== NOT && n[0].getKind()==FORALL );
if( !options::cbqi() || options::recurseCbqi() || !TermDb::hasInstConstAttr(n[0]) ){
- if( d_skolemized.find( n )==d_skolemized.end() ){
- Node body = getQuantifiersEngine()->getTermDatabase()->getSkolemizedBody( n[0] );
- NodeBuilder<> nb(kind::OR);
- nb << n[0] << body.notNode();
- Node lem = nb;
- Trace("quantifiers-sk") << "Skolemize lemma : " << lem << std::endl;
- d_out->lemma( lem, false, true );
- d_skolemized[n] = true;
- }
+ getQuantifiersEngine()->assertQuantifier( n[0], false );
}
}
class TheoryQuantifiers : public Theory {
private:
typedef context::CDHashMap< Node, bool, NodeHashFunction > BoolMap;
- /** quantifiers that have been skolemized */
- std::map< Node, bool > d_skolemized;
/** number of instantiations */
int d_numInstantiations;
int d_baseDecLevel;
}
}
-void QuantifiersEngine::assertNode( Node f ){
- d_model->assertQuantifier( f );
- for( int i=0; i<(int)d_modules.size(); i++ ){
- d_modules[i]->assertNode( f );
+void QuantifiersEngine::assertQuantifier( Node f, bool pol ){
+ if( !pol ){
+ //do skolemization
+ if( d_skolemized.find( f )==d_skolemized.end() ){
+ Node body = d_term_db->getSkolemizedBody( f );
+ NodeBuilder<> nb(kind::OR);
+ nb << f << body.notNode();
+ Node lem = nb;
+ if( Trace.isOn("quantifiers-sk") ){
+ Node slem = Rewriter::rewrite( lem );
+ Trace("quantifiers-sk") << "Skolemize lemma : " << slem << std::endl;
+ }
+ getOutputChannel().lemma( lem, false, true );
+ d_skolemized[f] = true;
+ }
+ }
+ //assert to modules TODO : handle !pol
+ if( pol ){
+ //register the quantifier
+ registerQuantifier( f );
+ //assert it to each module
+ d_model->assertQuantifier( f );
+ for( int i=0; i<(int)d_modules.size(); i++ ){
+ d_modules[i]->assertNode( f );
+ }
}
}
}
void QuantifiersEngine::printInstantiations( std::ostream& out ) {
+ for( std::map< Node, bool >::iterator it = d_skolemized.begin(); it != d_skolemized.end(); ++it ){
+ out << "Skolem constants of " << it->first << " : " << std::endl;
+ out << " ( ";
+ for( unsigned i=0; i<d_term_db->d_skolem_constants[it->first].size(); i++ ){
+ if( i>0 ){ out << ", "; }
+ out << d_term_db->d_skolem_constants[it->first][i];
+ }
+ out << " )" << std::endl;
+ out << std::endl;
+ }
if( options::incrementalSolving() ){
for( std::map< Node, inst::CDInstMatchTrie* >::iterator it = d_c_inst_match_trie.begin(); it != d_c_inst_match_trie.end(); ++it ){
out << "Instantiations of " << it->first << " : " << std::endl;
/** list of all instantiations produced for each quantifier */
std::map< Node, inst::InstMatchTrie > d_inst_match_trie;
std::map< Node, inst::CDInstMatchTrie* > d_c_inst_match_trie;
+ /** quantifiers that have been skolemized */
+ std::map< Node, bool > d_skolemized;
/** term database */
quantifiers::TermDb* d_term_db;
/** all triggers will be stored in this trie */
/** register quantifier */
void registerPattern( std::vector<Node> & pattern);
/** assert universal quantifier */
- void assertNode( Node f );
+ void assertQuantifier( Node q, bool pol );
/** propagate */
void propagate( Theory::Effort level );
/** get next decision request */