diff options
author | ajreynol <andrew.j.reynolds@gmail.com> | 2016-02-19 11:00:48 -0600 |
---|---|---|
committer | ajreynol <andrew.j.reynolds@gmail.com> | 2016-02-19 11:00:48 -0600 |
commit | 2150eb22aaff94f9d0d9f0ee0854ea44675fd854 (patch) | |
tree | 061ee4c79296a6625d7f42f0ccb2dd1f1bab4fe9 /src | |
parent | f47f24528f5d19ac0affd572f3d34c090e97f9f9 (diff) |
Fixes and improvements for datatypes properties and splitting.
Diffstat (limited to 'src')
-rw-r--r-- | src/expr/datatype.cpp | 20 | ||||
-rw-r--r-- | src/theory/quantifiers/quant_split.cpp | 17 | ||||
-rw-r--r-- | src/theory/quantifiers_engine.cpp | 10 |
3 files changed, 31 insertions, 16 deletions
diff --git a/src/expr/datatype.cpp b/src/expr/datatype.cpp index 45a7447aa..b52ceb856 100644 --- a/src/expr/datatype.cpp +++ b/src/expr/datatype.cpp @@ -306,10 +306,11 @@ bool Datatype::isUFinite() const throw(IllegalArgumentException) { if(self.getAttribute(DatatypeUFiniteComputedAttr())) { return self.getAttribute(DatatypeUFiniteAttr()); } + //start by assuming it is not + self.setAttribute(DatatypeUFiniteComputedAttr(), true); + self.setAttribute(DatatypeUFiniteAttr(), false); for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) { if(! (*i).isUFinite()) { - self.setAttribute(DatatypeUFiniteComputedAttr(), true); - self.setAttribute(DatatypeUFiniteAttr(), false); return false; } } @@ -838,7 +839,7 @@ bool DatatypeConstructor::isFinite() const throw(IllegalArgumentException) { return self.getAttribute(DatatypeFiniteAttr()); } for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) { - if(! SelectorType((*i).getSelector().getType()).getRangeType().getCardinality().isFinite()) { + if(! (*i).getRangeType().getCardinality().isFinite()) { self.setAttribute(DatatypeFiniteComputedAttr(), true); self.setAttribute(DatatypeFiniteAttr(), false); return false; @@ -858,9 +859,18 @@ bool DatatypeConstructor::isUFinite() const throw(IllegalArgumentException) { if(self.getAttribute(DatatypeUFiniteComputedAttr())) { return self.getAttribute(DatatypeUFiniteAttr()); } + bool success = true; for(const_iterator i = begin(), i_end = end(); i != i_end; ++i) { - Type t = SelectorType((*i).getSelector().getType()).getRangeType(); - if(!t.isSort() && !t.getCardinality().isFinite()) { + Type t = (*i).getRangeType(); + if( t.isDatatype() ){ + const Datatype& dt = ((DatatypeType)t).getDatatype(); + if( !dt.isUFinite() ){ + success = false; + } + }else if(!t.isSort() && !t.getCardinality().isFinite()) { + success = false; + } + if(!success ){ self.setAttribute(DatatypeUFiniteComputedAttr(), true); self.setAttribute(DatatypeUFiniteAttr(), false); return false; diff --git a/src/theory/quantifiers/quant_split.cpp b/src/theory/quantifiers/quant_split.cpp index e874ee5b8..1ae1c3c5f 100644 --- a/src/theory/quantifiers/quant_split.cpp +++ b/src/theory/quantifiers/quant_split.cpp @@ -48,11 +48,11 @@ void QuantDSplit::preRegisterQuantifier( Node q ) { }else{ int score = -1; if( options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_AGG ){ - score = dt.isFinite() ? 1 : -1; - }else if( options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_DEFAULT ){ + score = dt.isUFinite() ? 1 : -1; + }else if( options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_DEFAULT ){ score = dt.isUFinite() ? 1 : -1; } - Trace("quant-dsplit-debug") << "Datatype " << dt.getName() << " is score " << score << std::endl; + Trace("quant-dsplit-debug") << "Datatype " << dt.getName() << " is score " << score << " (" << dt.isUFinite() << " " << dt.isFinite() << ")" << std::endl; if( score>max_score ){ max_index = i; max_score = score; @@ -70,11 +70,12 @@ void QuantDSplit::preRegisterQuantifier( Node q ) { /* whether this module needs to check this round */ bool QuantDSplit::needsCheck( Theory::Effort e ) { - return e>=Theory::EFFORT_FULL; + return e>=Theory::EFFORT_FULL && !d_quant_to_reduce.empty(); } + /* Call during quantifier engine's check */ void QuantDSplit::check( Theory::Effort e, unsigned quant_e ) { - //flush lemmas ASAP (they are a reduction) + //add lemmas ASAP (they are a reduction) if( quant_e==QuantifiersEngine::QEFFORT_CONFLICT ){ std::vector< Node > lemmas; for(std::map< Node, int >::iterator it = d_quant_to_reduce.begin(); it != d_quant_to_reduce.end(); ++it) { @@ -92,6 +93,7 @@ void QuantDSplit::check( Theory::Effort e, unsigned quant_e ) { TNode svar = q[0][it->second]; TypeNode tn = svar.getType(); if( tn.isDatatype() ){ + std::vector< Node > cons; const Datatype& dt = ((DatatypeType)(tn).toType()).getDatatype(); for( unsigned j=0; j<dt.getNumConstructors(); j++ ){ std::vector< Node > vars; @@ -110,8 +112,10 @@ void QuantDSplit::check( Theory::Effort e, unsigned quant_e ) { if( !bvs_cmb.empty() ){ body = NodeManager::currentNM()->mkNode( kind::FORALL, NodeManager::currentNM()->mkNode( kind::BOUND_VAR_LIST, bvs_cmb ), body ); } - disj.push_back( body ); + cons.push_back( body ); } + Node conc = cons.size()==1 ? cons[0] : NodeManager::currentNM()->mkNode( kind::AND, cons ); + disj.push_back( conc ); }else{ Assert( false ); } @@ -124,6 +128,7 @@ void QuantDSplit::check( Theory::Effort e, unsigned quant_e ) { Trace("quant-dsplit") << "QuantDSplit lemma : " << lemmas[i] << std::endl; d_quantEngine->addLemma( lemmas[i], false ); } + d_quant_to_reduce.clear(); } } diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index cfb3fda94..bbc41278e 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -241,7 +241,7 @@ void QuantifiersEngine::finishInit(){ d_modules.push_back( d_lte_part_inst ); } if( ( options::finiteModelFind() && options::quantDynamicSplit()!=quantifiers::QUANT_DSPLIT_MODE_NONE ) || - options::quantDynamicSplit()!=quantifiers::QUANT_DSPLIT_MODE_AGG ){ + options::quantDynamicSplit()==quantifiers::QUANT_DSPLIT_MODE_AGG ){ d_qsplit = new quantifiers::QuantDSplit( this, c ); d_modules.push_back( d_qsplit ); } @@ -365,10 +365,10 @@ void QuantifiersEngine::check( Theory::Effort e ){ } bool usedModelBuilder = false; - Trace("quant-engine-debug") << "Quantifiers Engine call to check, level = " << e << std::endl; + Trace("quant-engine-debug2") << "Quantifiers Engine call to check, level = " << e << ", needsCheck=" << needsCheck << std::endl; if( needsCheck ){ - Trace("quant-engine") << "Quantifiers Engine check, level = " << e << std::endl; if( Trace.isOn("quant-engine-debug") ){ + Trace("quant-engine-debug") << "Quantifiers Engine check, level = " << e << std::endl; Trace("quant-engine-debug") << " modules to check : "; for( unsigned i=0; i<qm.size(); i++ ){ Trace("quant-engine-debug") << qm[i]->identify() << " "; @@ -484,9 +484,9 @@ void QuantifiersEngine::check( Theory::Effort e ){ } } } - Trace("quant-engine") << "Finished quantifiers engine check." << std::endl; + Trace("quant-engine-debug2") << "Finished quantifiers engine check." << std::endl; }else{ - Trace("quant-engine") << "Quantifiers Engine does not need check." << std::endl; + Trace("quant-engine-debug2") << "Quantifiers Engine does not need check." << std::endl; } //SAT case |