#include "theory/arrays/skolem_cache.h"
#include "theory/arrays/theory_arrays_rewriter.h"
#include "theory/decision_manager.h"
-#include "theory/rewriter.h"
#include "theory/theory_model.h"
#include "theory/trust_substitutions.h"
#include "theory/valuation.h"
name + "number of setModelVal conflicts")),
d_ppEqualityEngine(userContext(), name + "pp", true),
d_ppFacts(userContext()),
- d_rewriter(d_pnm),
+ d_rewriter(env.getRewriter(), d_pnm),
d_state(env, valuation),
d_im(env, *this, d_state, d_pnm),
d_literalsToPropagate(context()),
bool termsExist = d_ppEqualityEngine.hasTerm(a) && d_ppEqualityEngine.hasTerm(b);
Assert(!termsExist || !a.isConst() || !b.isConst() || a == b
|| d_ppEqualityEngine.areDisequal(a, b, false));
- return ((termsExist && d_ppEqualityEngine.areDisequal(a, b, false)) ||
- Rewriter::rewrite(a.eqNode(b)) == d_false);
+ return ((termsExist && d_ppEqualityEngine.areDisequal(a, b, false))
+ || rewrite(a.eqNode(b)) == d_false);
}
// Record read in sharing data structure
TNode index = d_equalityEngine->getRepresentative(node[1]);
- if (!options::arraysWeakEquivalence() && index.isConst())
+ if (!options().arrays.arraysWeakEquivalence && index.isConst())
{
CTNodeList* temp;
CNodeNListMap::iterator it = d_constReads.find(index);
d_infoMap.setModelRep(node, node);
// Add-Store for Weak Equivalence
- if (options::arraysWeakEquivalence())
+ if (options().arrays.arraysWeakEquivalence)
{
Assert(weakEquivGetRep(node[0]) == weakEquivGetRep(a));
Assert(weakEquivGetRep(node) == node);
void TheoryArrays::postCheck(Effort level)
{
- if ((options::arraysEagerLemmas() || fullEffort(level))
- && !d_state.isInConflict() && options::arraysWeakEquivalence())
+ bool eagerLemmas = options().arrays.arraysEagerLemmas;
+ bool weakEquiv = options().arrays.arraysWeakEquivalence;
+
+ if ((eagerLemmas || fullEffort(level)) && !d_state.isInConflict()
+ && weakEquiv)
{
// Replay all array merges to update weak equivalence data structures
context::CDList<Node>::iterator it = d_arrayMerges.begin(), iend = d_arrayMerges.end();
if (weakEquivGetRepIndex(r[0], r[1]) == weakEquivGetRepIndex(r2[0], r[1])) {
// add lemma: r[1] = r2[1] /\ cond(r[0],r2[0]) => r = r2
vector<TNode> conjunctions;
- Assert(d_equalityEngine->areEqual(r, Rewriter::rewrite(r)));
- Assert(d_equalityEngine->areEqual(r2, Rewriter::rewrite(r2)));
- Node lemma = Rewriter::rewrite(r).eqNode(Rewriter::rewrite(r2)).negate();
+ Assert(d_equalityEngine->areEqual(r, rewrite(r)));
+ Assert(d_equalityEngine->areEqual(r2, rewrite(r2)));
+ Node lemma = rewrite(r).eqNode(rewrite(r2)).negate();
d_permRef.push_back(lemma);
conjunctions.push_back(lemma);
if (r[1] != r2[1]) {
d_readTableContext->pop();
}
- if (!options::arraysEagerLemmas() && fullEffort(level)
- && !d_state.isInConflict() && !options::arraysWeakEquivalence())
+ if (!eagerLemmas && fullEffort(level) && !d_state.isInConflict()
+ && !weakEquiv)
{
// generate the lemmas on the worklist
Trace("arrays-lem")<< "Arrays::discharging lemmas. Number of queued lemmas: " << d_RowQueue.size() << "\n";
Node eq = ak.eqNode(bk);
Node lemma = fact[0].orNode(eq.notNode());
- if (options::arraysPropagate() > 0 && d_equalityEngine->hasTerm(ak)
+ if (options().arrays.arraysPropagate > 0 && d_equalityEngine->hasTerm(ak)
&& d_equalityEngine->hasTerm(bk))
{
// Propagate witness disequality - might produce a conflict
void TheoryArrays::setNonLinear(TNode a)
{
- if (options::arraysWeakEquivalence()) return;
+ if (options().arrays.arraysWeakEquivalence) return;
if (d_infoMap.isNonLinear(a)) return;
Trace("arrays") << spaces(context()->getLevel()) << "Arrays::setNonLinear ("
}
d_mergeInProgress = true;
+ bool optLinear = options().arrays.arraysOptimizeLinear;
+ bool weakEquiv = options().arrays.arraysWeakEquivalence;
Node n;
while (true) {
Trace("arrays-merge") << spaces(context()->getLevel()) << "Arrays::merge: ("
<< a << ", " << b << ")\n";
- if (options::arraysOptimizeLinear() && !options::arraysWeakEquivalence()) {
+ if (optLinear && !weakEquiv)
+ {
bool aNL = d_infoMap.isNonLinear(a);
bool bNL = d_infoMap.isNonLinear(b);
if (aNL) {
// merge info adds the list of the 2nd argument to the first
d_infoMap.mergeInfo(a, b);
- if (options::arraysWeakEquivalence()) {
+ if (weakEquiv)
+ {
d_arrayMerges.push_back(a.eqNode(b));
}
d_mergeInProgress = false;
}
+void TheoryArrays::checkStore(TNode a)
+{
+ if (options().arrays.arraysWeakEquivalence) return;
-void TheoryArrays::checkStore(TNode a) {
- if (options::arraysWeakEquivalence()) return;
Trace("arrays-cri")<<"Arrays::checkStore "<<a<<"\n";
if(Trace.isOn("arrays-cri")) {
TNode brep = d_equalityEngine->getRepresentative(b);
- if (!options::arraysOptimizeLinear() || d_infoMap.isNonLinear(brep)) {
+ if (!options().arrays.arraysOptimizeLinear || d_infoMap.isNonLinear(brep))
+ {
const CTNodeList* js = d_infoMap.getIndices(brep);
size_t it = 0;
RowLemmaType lem;
}
}
-
void TheoryArrays::checkRowForIndex(TNode i, TNode a)
{
- if (options::arraysWeakEquivalence()) return;
+ if (options().arrays.arraysWeakEquivalence) return;
+
Trace("arrays-cri")<<"Arrays::checkRowForIndex "<<a<<"\n";
Trace("arrays-cri")<<" index "<<i<<"\n";
queueRowLemma(lem);
}
- if (!options::arraysOptimizeLinear() || d_infoMap.isNonLinear(a)) {
+ if (!options().arrays.arraysOptimizeLinear || d_infoMap.isNonLinear(a))
+ {
it = 0;
for(; it < instores->size(); ++it) {
TNode instore = (*instores)[it];
// look for new ROW lemmas
void TheoryArrays::checkRowLemmas(TNode a, TNode b)
{
- if (options::arraysWeakEquivalence()) return;
+ if (options().arrays.arraysWeakEquivalence) return;
+
Trace("arrays-crl")<<"Arrays::checkLemmas begin \n"<<a<<"\n";
if(Trace.isOn("arrays-crl"))
d_infoMap.getInfo(a)->print();
}
}
- if (!options::arraysOptimizeLinear() || d_infoMap.isNonLinear(b)) {
+ if (!options().arrays.arraysOptimizeLinear || d_infoMap.isNonLinear(b))
+ {
for(it = 0 ; it < i_a->size(); ++it ) {
TNode i = (*i_a)[it];
its = 0;
void TheoryArrays::propagateRowLemma(RowLemmaType lem)
{
- Debug("pf::array") << "TheoryArrays: RowLemma Propagate called. options::arraysPropagate() = "
- << options::arraysPropagate() << std::endl;
+ Debug("pf::array") << "TheoryArrays: RowLemma Propagate called. "
+ "options::arraysPropagate() = "
+ << options().arrays.arraysPropagate << std::endl;
TNode a, b, i, j;
std::tie(a, b, i, j) = lem;
bool bothExist = ajExists && bjExists;
// If propagating, check propagations
- int prop = options::arraysPropagate();
+ int64_t prop = options().arrays.arraysPropagate;
if (prop > 0) {
if (d_equalityEngine->areDisequal(i, j, true) && (bothExist || prop > 1))
{
bool bothExist = ajExists && bjExists;
// If propagating, check propagations
- int prop = options::arraysPropagate();
+ int64_t prop = options().arrays.arraysPropagate;
+
if (prop > 0) {
propagateRowLemma(lem);
}
// Prefer equality between indexes so as not to introduce new read terms
- if (options::arraysEagerIndexSplitting() && !bothExist
+ if (options().arrays.arraysEagerIndexSplitting && !bothExist
&& !d_equalityEngine->areDisequal(i, j, false))
{
Node i_eq_j;
// TODO: maybe add triggers here
- if (options::arraysEagerLemmas() || bothExist)
+ if (options().arrays.arraysEagerLemmas || bothExist)
{
// Make sure that any terms introduced by rewriting are appropriately stored in the equality database
- Node aj2 = Rewriter::rewrite(aj);
+ Node aj2 = rewrite(aj);
if (aj != aj2) {
if (!ajExists) {
preRegisterTermInternal(aj);
d_true,
PfRule::MACRO_SR_PRED_INTRO);
}
- Node bj2 = Rewriter::rewrite(bj);
+ Node bj2 = rewrite(bj);
if (bj != bj2) {
if (!bjExists) {
preRegisterTermInternal(bj);
// construct lemma
Node eq1 = aj2.eqNode(bj2);
- Node eq1_r = Rewriter::rewrite(eq1);
+ Node eq1_r = rewrite(eq1);
if (eq1_r == d_true) {
if (!d_equalityEngine->hasTerm(aj2))
{
}
Node eq2 = i.eqNode(j);
- Node eq2_r = Rewriter::rewrite(eq2);
+ Node eq2_r = rewrite(eq2);
if (eq2_r == d_true) {
d_im.assertInference(eq2,
true,
bool TheoryArrays::dischargeLemmas()
{
+ bool reduceSharing = options().arrays.arraysReduceSharing;
bool lemmasAdded = false;
- size_t sz = d_RowQueue.size();
- for (unsigned count = 0; count < sz; ++count) {
+
+ for (size_t count = 0, sz = d_RowQueue.size(); count < sz; ++count)
+ {
RowLemmaType l = d_RowQueue.front();
d_RowQueue.pop();
if (d_RowAlreadyAdded.contains(l)) {
continue;
}
- int prop = options::arraysPropagate();
+ int64_t prop = options().arrays.arraysPropagate;
if (prop > 0) {
propagateRowLemma(l);
if (d_state.isInConflict())
}
// Make sure that any terms introduced by rewriting are appropriately stored in the equality database
- Node aj2 = Rewriter::rewrite(aj);
+ Node aj2 = rewrite(aj);
if (aj != aj2) {
if (!ajExists) {
preRegisterTermInternal(aj);
d_true,
PfRule::MACRO_SR_PRED_INTRO);
}
- Node bj2 = Rewriter::rewrite(bj);
+ Node bj2 = rewrite(bj);
if (bj != bj2) {
if (!bjExists) {
preRegisterTermInternal(bj);
// construct lemma
Node eq1 = aj2.eqNode(bj2);
- Node eq1_r = Rewriter::rewrite(eq1);
+ Node eq1_r = rewrite(eq1);
if (eq1_r == d_true) {
if (!d_equalityEngine->hasTerm(aj2))
{
}
Node eq2 = i.eqNode(j);
- Node eq2_r = Rewriter::rewrite(eq2);
+ Node eq2_r = rewrite(eq2);
if (eq2_r == d_true) {
d_im.assertInference(eq2,
true,
aj.eqNode(bj), InferenceId::ARRAYS_READ_OVER_WRITE, eq2.notNode(), PfRule::ARRAYS_READ_OVER_WRITE);
++d_numRow;
lemmasAdded = true;
- if (options::arraysReduceSharing()) {
+ if (reduceSharing)
+ {
return true;
}
}