summaryrefslogtreecommitdiff
path: root/src/theory/arith
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2020-07-16 12:10:58 -0500
committerGitHub <noreply@github.com>2020-07-16 12:10:58 -0500
commitf7559c879d1ebc7d4d9b9f72b0858bdf42c9ed8c (patch)
treef4ceec82dfec21737b4cc1c555706bd8426fc9e9 /src/theory/arith
parent051106d0033c8108008acba65ad02a77b5ddd19c (diff)
Make ExtTheory a utility and not a member of Theory (#4753)
Previously, we assumed that ExtTheory, the module for doing context-dependent simplification, was one-to-one with Theory. This design is not necessary. This makes this class a utility, which can be used as needed. This makes e.g. the initialization of TheoryStrings much easier, since the ExtTheory object can be created first.
Diffstat (limited to 'src/theory/arith')
-rw-r--r--src/theory/arith/nl/nonlinear_extension.cpp19
-rw-r--r--src/theory/arith/nl/nonlinear_extension.h7
-rw-r--r--src/theory/arith/theory_arith.cpp10
-rw-r--r--src/theory/arith/theory_arith_private.cpp2
4 files changed, 24 insertions, 14 deletions
diff --git a/src/theory/arith/nl/nonlinear_extension.cpp b/src/theory/arith/nl/nonlinear_extension.cpp
index 97f0ce2c1..12772f4d2 100644
--- a/src/theory/arith/nl/nonlinear_extension.cpp
+++ b/src/theory/arith/nl/nonlinear_extension.cpp
@@ -37,12 +37,18 @@ NonlinearExtension::NonlinearExtension(TheoryArith& containing,
d_containing(containing),
d_ee(ee),
d_needsLastCall(false),
+ d_extTheory(&containing),
d_model(containing.getSatContext()),
d_trSlv(d_model),
d_nlSlv(containing, d_model),
d_iandSlv(containing, d_model),
d_builtModel(containing.getSatContext(), false)
{
+ d_extTheory.addFunctionKind(kind::NONLINEAR_MULT);
+ d_extTheory.addFunctionKind(kind::EXPONENTIAL);
+ d_extTheory.addFunctionKind(kind::SINE);
+ d_extTheory.addFunctionKind(kind::PI);
+ d_extTheory.addFunctionKind(kind::IAND);
d_true = NodeManager::currentNM()->mkConst(true);
d_zero = NodeManager::currentNM()->mkConst(Rational(0));
d_one = NodeManager::currentNM()->mkConst(Rational(1));
@@ -51,6 +57,13 @@ NonlinearExtension::NonlinearExtension(TheoryArith& containing,
NonlinearExtension::~NonlinearExtension() {}
+void NonlinearExtension::preRegisterTerm(TNode n)
+{
+ // register terms with extended theory, to find extended terms that can be
+ // eliminated by context-depedendent simplification.
+ d_extTheory.registerTermRec(n);
+}
+
bool NonlinearExtension::getCurrentSubstitution(
int effort,
const std::vector<Node>& vars,
@@ -596,12 +609,12 @@ void NonlinearExtension::check(Theory::Effort e)
<< ", built model = " << d_builtModel.get() << std::endl;
if (e == Theory::EFFORT_FULL)
{
- d_containing.getExtTheory()->clearCache();
+ d_extTheory.clearCache();
d_needsLastCall = true;
if (options::nlExtRewrites())
{
std::vector<Node> nred;
- if (!d_containing.getExtTheory()->doInferences(0, nred))
+ if (!d_extTheory.doInferences(0, nred))
{
Trace("nl-ext") << "...sent no lemmas, # extf to reduce = "
<< nred.size() << std::endl;
@@ -657,7 +670,7 @@ bool NonlinearExtension::modelBasedRefinement(std::vector<NlLemma>& mlems)
// get the extended terms belonging to this theory
std::vector<Node> xts;
- d_containing.getExtTheory()->getTerms(xts);
+ d_extTheory.getTerms(xts);
if (Trace.isOn("nl-ext-debug"))
{
diff --git a/src/theory/arith/nl/nonlinear_extension.h b/src/theory/arith/nl/nonlinear_extension.h
index 69710265c..b4e5df976 100644
--- a/src/theory/arith/nl/nonlinear_extension.h
+++ b/src/theory/arith/nl/nonlinear_extension.h
@@ -32,6 +32,7 @@
#include "theory/arith/nl/stats.h"
#include "theory/arith/nl/transcendental_solver.h"
#include "theory/arith/theory_arith.h"
+#include "theory/ext_theory.h"
#include "theory/uf/equality_engine.h"
namespace CVC4 {
@@ -70,6 +71,10 @@ class NonlinearExtension
public:
NonlinearExtension(TheoryArith& containing, eq::EqualityEngine* ee);
~NonlinearExtension();
+ /**
+ * Does non-context dependent setup for a node connected to a theory.
+ */
+ void preRegisterTerm(TNode n);
/** Get current substitution
*
* This function and the one below are
@@ -289,6 +294,8 @@ class NonlinearExtension
NlStats d_stats;
// needs last call effort
bool d_needsLastCall;
+ /** Extended theory, responsible for context-dependent simplification. */
+ ExtTheory d_extTheory;
/** The non-linear model object
*
* This class is responsible for computing model values for arithmetic terms
diff --git a/src/theory/arith/theory_arith.cpp b/src/theory/arith/theory_arith.cpp
index eb5bf3685..fcbfd1baf 100644
--- a/src/theory/arith/theory_arith.cpp
+++ b/src/theory/arith/theory_arith.cpp
@@ -44,16 +44,6 @@ TheoryArith::TheoryArith(context::Context* c,
d_proofRecorder(nullptr)
{
smtStatisticsRegistry()->registerStat(&d_ppRewriteTimer);
- // if logic is non-linear
- if (logicInfo.isTheoryEnabled(THEORY_ARITH) && !logicInfo.isLinear())
- {
- setupExtTheory();
- getExtTheory()->addFunctionKind(kind::NONLINEAR_MULT);
- getExtTheory()->addFunctionKind(kind::EXPONENTIAL);
- getExtTheory()->addFunctionKind(kind::SINE);
- getExtTheory()->addFunctionKind(kind::PI);
- getExtTheory()->addFunctionKind(kind::IAND);
- }
}
TheoryArith::~TheoryArith(){
diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp
index d0da29e7a..39a3a6558 100644
--- a/src/theory/arith/theory_arith_private.cpp
+++ b/src/theory/arith/theory_arith_private.cpp
@@ -1447,7 +1447,7 @@ void TheoryArithPrivate::preRegisterTerm(TNode n) {
if (d_nonlinearExtension != nullptr)
{
- d_containing.getExtTheory()->registerTermRec( n );
+ d_nonlinearExtension->preRegisterTerm(n);
}
try {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback