summaryrefslogtreecommitdiff
path: root/src/theory/quantifiers/sygus
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-02-22 17:19:20 -0600
committerGitHub <noreply@github.com>2021-02-22 17:19:20 -0600
commit13819c4ae33a103b1075e816772a305b16db9157 (patch)
treef8598d57ac30065091fd2115af2f25cef1673acd /src/theory/quantifiers/sygus
parent4479383c2fd8a3b81ab63d66f843b09b5c9d0cd3 (diff)
Eliminate raw use of output channel and valuation in quantifiers (#5933)
This makes all lemmas in quantifiers sent through the inference manager. It begins adding InferenceId values for some of these calls. All uses of Valuation are replaced by calls to QuantifiersState.
Diffstat (limited to 'src/theory/quantifiers/sygus')
-rw-r--r--src/theory/quantifiers/sygus/cegis.cpp6
-rw-r--r--src/theory/quantifiers/sygus/cegis.h4
-rw-r--r--src/theory/quantifiers/sygus/cegis_core_connective.cpp3
-rw-r--r--src/theory/quantifiers/sygus/cegis_core_connective.h4
-rw-r--r--src/theory/quantifiers/sygus/cegis_unif.cpp23
-rw-r--r--src/theory/quantifiers/sygus/cegis_unif.h8
-rw-r--r--src/theory/quantifiers/sygus/sygus_module.cpp6
-rw-r--r--src/theory/quantifiers/sygus/sygus_module.h9
-rw-r--r--src/theory/quantifiers/sygus/sygus_pbe.cpp6
-rw-r--r--src/theory/quantifiers/sygus/sygus_pbe.h4
-rw-r--r--src/theory/quantifiers/sygus/synth_conjecture.cpp28
-rw-r--r--src/theory/quantifiers/sygus/synth_engine.cpp4
-rw-r--r--src/theory/quantifiers/sygus/term_database_sygus.cpp6
13 files changed, 70 insertions, 41 deletions
diff --git a/src/theory/quantifiers/sygus/cegis.cpp b/src/theory/quantifiers/sygus/cegis.cpp
index c09c78158..a97888d36 100644
--- a/src/theory/quantifiers/sygus/cegis.cpp
+++ b/src/theory/quantifiers/sygus/cegis.cpp
@@ -30,8 +30,10 @@ namespace CVC4 {
namespace theory {
namespace quantifiers {
-Cegis::Cegis(QuantifiersEngine* qe, SynthConjecture* p)
- : SygusModule(qe, p), d_eval_unfold(nullptr), d_usingSymCons(false)
+Cegis::Cegis(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p)
+ : SygusModule(qe, qim, p), d_eval_unfold(nullptr), d_usingSymCons(false)
{
d_eval_unfold = qe->getTermDatabaseSygus()->getEvalUnfold();
}
diff --git a/src/theory/quantifiers/sygus/cegis.h b/src/theory/quantifiers/sygus/cegis.h
index c466afe0f..c1415d92f 100644
--- a/src/theory/quantifiers/sygus/cegis.h
+++ b/src/theory/quantifiers/sygus/cegis.h
@@ -41,7 +41,9 @@ namespace quantifiers {
class Cegis : public SygusModule
{
public:
- Cegis(QuantifiersEngine* qe, SynthConjecture* p);
+ Cegis(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p);
~Cegis() override {}
/** initialize */
virtual bool initialize(Node conj,
diff --git a/src/theory/quantifiers/sygus/cegis_core_connective.cpp b/src/theory/quantifiers/sygus/cegis_core_connective.cpp
index 4549a0945..db2a972d5 100644
--- a/src/theory/quantifiers/sygus/cegis_core_connective.cpp
+++ b/src/theory/quantifiers/sygus/cegis_core_connective.cpp
@@ -69,8 +69,9 @@ bool VariadicTrie::hasSubset(const std::vector<Node>& is) const
}
CegisCoreConnective::CegisCoreConnective(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
SynthConjecture* p)
- : Cegis(qe, p)
+ : Cegis(qe, qim, p)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
diff --git a/src/theory/quantifiers/sygus/cegis_core_connective.h b/src/theory/quantifiers/sygus/cegis_core_connective.h
index d70624f0a..cdc43658d 100644
--- a/src/theory/quantifiers/sygus/cegis_core_connective.h
+++ b/src/theory/quantifiers/sygus/cegis_core_connective.h
@@ -155,7 +155,9 @@ class VariadicTrie
class CegisCoreConnective : public Cegis
{
public:
- CegisCoreConnective(QuantifiersEngine* qe, SynthConjecture* p);
+ CegisCoreConnective(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p);
~CegisCoreConnective() {}
/**
* Return whether this module has the possibility to construct solutions. This
diff --git a/src/theory/quantifiers/sygus/cegis_unif.cpp b/src/theory/quantifiers/sygus/cegis_unif.cpp
index 239fa3c94..c548f7f8f 100644
--- a/src/theory/quantifiers/sygus/cegis_unif.cpp
+++ b/src/theory/quantifiers/sygus/cegis_unif.cpp
@@ -30,8 +30,9 @@ namespace quantifiers {
CegisUnif::CegisUnif(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
SynthConjecture* p)
- : Cegis(qe, p), d_sygus_unif(p), d_u_enum_manager(qe, qs, p)
+ : Cegis(qe, qim, p), d_sygus_unif(p), d_u_enum_manager(qe, qs, qim, p)
{
}
@@ -216,7 +217,7 @@ bool CegisUnif::getEnumValues(const std::vector<Node>& enums,
<< "CegisUnif::lemma, inter-unif-enumerator "
"symmetry breaking lemma : "
<< slem << "\n";
- d_qe->getOutputChannel().lemma(slem);
+ d_qim.lemma(slem, InferenceId::UNKNOWN);
addedUnifEnumSymBreakLemma = true;
break;
}
@@ -364,7 +365,7 @@ bool CegisUnif::processConstructCandidates(const std::vector<Node>& enums,
{
Trace("cegis-unif-lemma")
<< "CegisUnif::lemma, separation lemma : " << lem << "\n";
- d_qe->getOutputChannel().lemma(lem);
+ d_qim.lemma(lem, InferenceId::UNKNOWN);
}
Trace("cegis-unif") << "..failed to separate heads\n---CegisUnif Engine---\n";
return false;
@@ -399,9 +400,13 @@ void CegisUnif::registerRefinementLemma(const std::vector<Node>& vars,
}
CegisUnifEnumDecisionStrategy::CegisUnifEnumDecisionStrategy(
- QuantifiersEngine* qe, QuantifiersState& qs, SynthConjecture* parent)
- : DecisionStrategyFmf(qs.getSatContext(), qe->getValuation()),
+ QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* parent)
+ : DecisionStrategyFmf(qs.getSatContext(), qs.getValuation()),
d_qe(qe),
+ d_qim(qim),
d_parent(parent)
{
d_initialized = false;
@@ -503,7 +508,7 @@ Node CegisUnifEnumDecisionStrategy::mkLiteral(unsigned n)
// G_uq_i => size(ve) >= log_2( i-1 )
// In other words, if we use i conditions, then we allow terms in our
// solution whose size is at most log_2(i-1).
- d_qe->getOutputChannel().lemma(fair_lemma);
+ d_qim.lemma(fair_lemma, InferenceId::UNKNOWN);
}
}
@@ -611,7 +616,7 @@ void CegisUnifEnumDecisionStrategy::setUpEnumerator(Node e,
Trace("cegis-unif-enum-lemma")
<< "CegisUnifEnum::lemma, remove redundant ops of " << e << " : "
<< sym_break_red_ops << "\n";
- d_qe->getOutputChannel().lemma(sym_break_red_ops);
+ d_qim.lemma(sym_break_red_ops, InferenceId::UNKNOWN);
}
// symmetry breaking between enumerators
if (!si.d_enums[index].empty() && index == 0)
@@ -622,7 +627,7 @@ void CegisUnifEnumDecisionStrategy::setUpEnumerator(Node e,
Node sym_break = nm->mkNode(GEQ, size_e, size_e_prev);
Trace("cegis-unif-enum-lemma")
<< "CegisUnifEnum::lemma, enum sym break:" << sym_break << "\n";
- d_qe->getOutputChannel().lemma(sym_break);
+ d_qim.lemma(sym_break, InferenceId::UNKNOWN);
}
// register the enumerator
si.d_enums[index].push_back(e);
@@ -678,7 +683,7 @@ void CegisUnifEnumDecisionStrategy::registerEvalPtAtSize(Node e,
Node lem = NodeManager::currentNM()->mkNode(OR, disj);
Trace("cegis-unif-enum-lemma")
<< "CegisUnifEnum::lemma, domain:" << lem << "\n";
- d_qe->getOutputChannel().lemma(lem);
+ d_qim.lemma(lem, InferenceId::UNKNOWN);
}
} // namespace quantifiers
diff --git a/src/theory/quantifiers/sygus/cegis_unif.h b/src/theory/quantifiers/sygus/cegis_unif.h
index ee9ae0132..9db77fd95 100644
--- a/src/theory/quantifiers/sygus/cegis_unif.h
+++ b/src/theory/quantifiers/sygus/cegis_unif.h
@@ -49,6 +49,7 @@ class CegisUnifEnumDecisionStrategy : public DecisionStrategyFmf
public:
CegisUnifEnumDecisionStrategy(QuantifiersEngine* qe,
QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
SynthConjecture* parent);
/** Make the n^th literal of this strategy (G_uq_n).
*
@@ -101,6 +102,8 @@ class CegisUnifEnumDecisionStrategy : public DecisionStrategyFmf
private:
/** reference to quantifier engine */
QuantifiersEngine* d_qe;
+ /** Reference to the quantifiers inference manager */
+ QuantifiersInferenceManager& d_qim;
/** sygus term database of d_qe */
TermDbSygus* d_tds;
/** reference to the parent conjecture */
@@ -204,7 +207,10 @@ class CegisUnifEnumDecisionStrategy : public DecisionStrategyFmf
class CegisUnif : public Cegis
{
public:
- CegisUnif(QuantifiersEngine* qe, QuantifiersState& qs, SynthConjecture* p);
+ CegisUnif(QuantifiersEngine* qe,
+ QuantifiersState& qs,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p);
~CegisUnif() override;
/** Retrieves enumerators for constructing solutions
*
diff --git a/src/theory/quantifiers/sygus/sygus_module.cpp b/src/theory/quantifiers/sygus/sygus_module.cpp
index 807764230..49a9b1ea0 100644
--- a/src/theory/quantifiers/sygus/sygus_module.cpp
+++ b/src/theory/quantifiers/sygus/sygus_module.cpp
@@ -20,8 +20,10 @@ namespace CVC4 {
namespace theory {
namespace quantifiers {
-SygusModule::SygusModule(QuantifiersEngine* qe, SynthConjecture* p)
- : d_qe(qe), d_tds(qe->getTermDatabaseSygus()), d_parent(p)
+SygusModule::SygusModule(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p)
+ : d_qe(qe), d_qim(qim), d_tds(qe->getTermDatabaseSygus()), d_parent(p)
{
}
diff --git a/src/theory/quantifiers/sygus/sygus_module.h b/src/theory/quantifiers/sygus/sygus_module.h
index 7eef6c46a..e150e52af 100644
--- a/src/theory/quantifiers/sygus/sygus_module.h
+++ b/src/theory/quantifiers/sygus/sygus_module.h
@@ -31,6 +31,7 @@ namespace quantifiers {
class SynthConjecture;
class TermDbSygus;
+class QuantifiersInferenceManager;
/** SygusModule
*
@@ -53,7 +54,9 @@ class TermDbSygus;
class SygusModule
{
public:
- SygusModule(QuantifiersEngine* qe, SynthConjecture* p);
+ SygusModule(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p);
virtual ~SygusModule() {}
/** initialize
*
@@ -150,8 +153,10 @@ class SygusModule
protected:
/** reference to quantifier engine */
QuantifiersEngine* d_qe;
+ /** Reference to the quantifiers inference manager */
+ QuantifiersInferenceManager& d_qim;
/** sygus term database of d_qe */
- quantifiers::TermDbSygus* d_tds;
+ TermDbSygus* d_tds;
/** reference to the parent conjecture */
SynthConjecture* d_parent;
};
diff --git a/src/theory/quantifiers/sygus/sygus_pbe.cpp b/src/theory/quantifiers/sygus/sygus_pbe.cpp
index b1cb330f6..da7c0d6d4 100644
--- a/src/theory/quantifiers/sygus/sygus_pbe.cpp
+++ b/src/theory/quantifiers/sygus/sygus_pbe.cpp
@@ -28,8 +28,10 @@ namespace CVC4 {
namespace theory {
namespace quantifiers {
-SygusPbe::SygusPbe(QuantifiersEngine* qe, SynthConjecture* p)
- : SygusModule(qe, p)
+SygusPbe::SygusPbe(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p)
+ : SygusModule(qe, qim, p)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
diff --git a/src/theory/quantifiers/sygus/sygus_pbe.h b/src/theory/quantifiers/sygus/sygus_pbe.h
index 1999f82c3..df99bc452 100644
--- a/src/theory/quantifiers/sygus/sygus_pbe.h
+++ b/src/theory/quantifiers/sygus/sygus_pbe.h
@@ -86,7 +86,9 @@ class SynthConjecture;
class SygusPbe : public SygusModule
{
public:
- SygusPbe(QuantifiersEngine* qe, SynthConjecture* p);
+ SygusPbe(QuantifiersEngine* qe,
+ QuantifiersInferenceManager& qim,
+ SynthConjecture* p);
~SygusPbe();
/** initialize this class
diff --git a/src/theory/quantifiers/sygus/synth_conjecture.cpp b/src/theory/quantifiers/sygus/synth_conjecture.cpp
index 723f11979..0fcba916b 100644
--- a/src/theory/quantifiers/sygus/synth_conjecture.cpp
+++ b/src/theory/quantifiers/sygus/synth_conjecture.cpp
@@ -58,10 +58,10 @@ SynthConjecture::SynthConjecture(QuantifiersEngine* qe,
d_ceg_gc(new CegGrammarConstructor(d_tds, this)),
d_sygus_rconst(new SygusRepairConst(qe)),
d_exampleInfer(new ExampleInfer(d_tds)),
- d_ceg_pbe(new SygusPbe(qe, this)),
- d_ceg_cegis(new Cegis(qe, this)),
- d_ceg_cegisUnif(new CegisUnif(qe, qs, this)),
- d_sygus_ccore(new CegisCoreConnective(qe, this)),
+ d_ceg_pbe(new SygusPbe(qe, qim, this)),
+ d_ceg_cegis(new Cegis(qe, qim, this)),
+ d_ceg_cegisUnif(new CegisUnif(qe, qs, qim, this)),
+ d_sygus_ccore(new CegisCoreConnective(qe, qim, this)),
d_master(nullptr),
d_set_ce_sk_vars(false),
d_repair_index(0),
@@ -102,7 +102,7 @@ void SynthConjecture::assign(Node q)
// initialize the guard
d_feasible_guard = nm->mkSkolem("G", nm->booleanType());
d_feasible_guard = Rewriter::rewrite(d_feasible_guard);
- d_feasible_guard = d_qe->getValuation().ensureLiteral(d_feasible_guard);
+ d_feasible_guard = d_qstate.getValuation().ensureLiteral(d_feasible_guard);
AlwaysAssert(!d_feasible_guard.isNull());
// pre-simplify the quantified formula based on the process utility
@@ -202,7 +202,7 @@ void SynthConjecture::assign(Node q)
{
// there is a contradictory example pair, the conjecture is infeasible.
Node infLem = d_feasible_guard.negate();
- d_qe->getOutputChannel().lemma(infLem);
+ d_qim.lemma(infLem, InferenceId::QUANTIFIERS_SYGUS_EXAMPLE_INFER_CONTRA);
// we don't need to continue initialization in this case
return;
}
@@ -240,13 +240,13 @@ void SynthConjecture::assign(Node q)
new DecisionStrategySingleton("sygus_feasible",
d_feasible_guard,
d_qstate.getSatContext(),
- d_qe->getValuation()));
+ d_qstate.getValuation()));
d_qe->getDecisionManager()->registerStrategy(
DecisionManager::STRAT_QUANT_SYGUS_FEASIBLE, d_feasible_strategy.get());
// this must be called, both to ensure that the feasible guard is
// decided on with true polariy, but also to ensure that output channel
// has been used on this call to check.
- d_qe->getOutputChannel().requirePhase(d_feasible_guard, true);
+ d_qim.requirePhase(d_feasible_guard, true);
Node gneg = d_feasible_guard.negate();
for (unsigned i = 0; i < guarded_lemmas.size(); i++)
@@ -254,7 +254,7 @@ void SynthConjecture::assign(Node q)
Node lem = nm->mkNode(OR, gneg, guarded_lemmas[i]);
Trace("cegqi-lemma") << "Cegqi::Lemma : initial (guarded) lemma : " << lem
<< std::endl;
- d_qe->getOutputChannel().lemma(lem);
+ d_qim.lemma(lem, InferenceId::UNKNOWN);
}
Trace("cegqi") << "...finished, single invocation = " << isSingleInvocation()
@@ -273,7 +273,7 @@ bool SynthConjecture::needsCheck()
bool value;
Assert(!d_feasible_guard.isNull());
// non or fully single invocation : look at guard only
- if (d_qe->getValuation().hasSatValue(d_feasible_guard, value))
+ if (d_qstate.getValuation().hasSatValue(d_feasible_guard, value))
{
if (!value)
{
@@ -610,7 +610,7 @@ bool SynthConjecture::doCheck(std::vector<Node>& lems)
// We should set incomplete, since a "sat" answer should not be
// interpreted as "infeasible", which would make a difference in the rare
// case where e.g. we had a finite grammar and exhausted the grammar.
- d_qe->getOutputChannel().setIncomplete();
+ d_qim.setIncomplete();
return false;
}
// otherwise we are unsat, and we will process the solution below
@@ -780,7 +780,7 @@ bool SynthConjecture::getEnumeratedValues(std::vector<Node>& n,
Node g = d_tds->getActiveGuardForEnumerator(e);
if (!g.isNull())
{
- Node gstatus = d_qe->getValuation().getSatValue(g);
+ Node gstatus = d_qstate.getValuation().getSatValue(g);
if (gstatus.isNull() || !gstatus.getConst<bool>())
{
Trace("sygus-engine-debug")
@@ -936,7 +936,7 @@ Node SynthConjecture::getEnumeratedValue(Node e, bool& activeIncomplete)
TermDbSygus::toStreamSygus("sygus-active-gen-debug", absE);
Trace("sygus-active-gen-debug") << std::endl;
}
- d_qe->getOutputChannel().lemma(lem);
+ d_qim.lemma(lem, InferenceId::QUANTIFIERS_SYGUS_EXCLUDE_CURRENT);
}
else
{
@@ -1024,7 +1024,7 @@ void SynthConjecture::excludeCurrentSolution(const std::vector<Node>& enums,
exc_lem = exc_lem.negate();
Trace("cegqi-lemma") << "Cegqi::Lemma : stream exclude current solution : "
<< exc_lem << std::endl;
- d_qe->getOutputChannel().lemma(exc_lem);
+ d_qim.lemma(exc_lem, InferenceId::QUANTIFIERS_SYGUS_STREAM_EXCLUDE_CURRENT);
}
}
diff --git a/src/theory/quantifiers/sygus/synth_engine.cpp b/src/theory/quantifiers/sygus/synth_engine.cpp
index 3aa782272..9653c4c9d 100644
--- a/src/theory/quantifiers/sygus/synth_engine.cpp
+++ b/src/theory/quantifiers/sygus/synth_engine.cpp
@@ -94,7 +94,7 @@ void SynthEngine::check(Theory::Effort e, QEffort quant_e)
Trace("sygus-engine") << "---Counterexample Guided Instantiation Engine---"
<< std::endl;
Trace("sygus-engine-debug") << std::endl;
- Valuation& valuation = d_quantEngine->getValuation();
+ Valuation& valuation = d_qstate.getValuation();
std::vector<SynthConjecture*> activeCheckConj;
for (unsigned i = 0, size = d_conjs.size(); i < size; i++)
{
@@ -151,7 +151,7 @@ void SynthEngine::assignConjecture(Node q)
{
Trace("cegqi-lemma") << "Cegqi::Lemma : qe-preprocess : " << lem
<< std::endl;
- d_quantEngine->getOutputChannel().lemma(lem);
+ d_qim.lemma(lem, InferenceId::QUANTIFIERS_SYGUS_QE_PREPROC);
// we've reduced the original to a preprocessed version, return
return;
}
diff --git a/src/theory/quantifiers/sygus/term_database_sygus.cpp b/src/theory/quantifiers/sygus/term_database_sygus.cpp
index e800a52cf..bc5cd1fda 100644
--- a/src/theory/quantifiers/sygus/term_database_sygus.cpp
+++ b/src/theory/quantifiers/sygus/term_database_sygus.cpp
@@ -564,11 +564,11 @@ void TermDbSygus::registerEnumerator(Node e,
// make the guard
Node ag = nm->mkSkolem("eG", nm->booleanType());
// must ensure it is a literal immediately here
- ag = d_quantEngine->getValuation().ensureLiteral(ag);
+ ag = d_qstate.getValuation().ensureLiteral(ag);
// must ensure that it is asserted as a literal before we begin solving
Node lem = nm->mkNode(OR, ag, ag.negate());
- d_quantEngine->getOutputChannel().requirePhase(ag, true);
- d_quantEngine->getOutputChannel().lemma(lem);
+ d_qim.requirePhase(ag, true);
+ d_qim.lemma(lem, InferenceId::QUANTIFIERS_SYGUS_ENUM_ACTIVE_GUARD_SPLIT);
d_enum_to_active_guard[e] = ag;
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback