From: Clark Barrett Date: Mon, 25 Nov 2013 23:21:40 +0000 (-0800) Subject: Array collectModelInfo fix for Andy X-Git-Tag: cvc5-1.0.0~7244^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a68c6b065b569c3094a08b0dbf64a263454b006d;p=cvc5.git Array collectModelInfo fix for Andy --- diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index 98346d0e3..76e48aa1d 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -813,27 +813,40 @@ void TheoryArrays::collectModelInfo( TheoryModel* m, bool fullModel ) for (size_t i=0; ibegin() != defaultValuesSet.getSet(valueType)->end()); - rep = *(defaultValuesSet.getSet(valueType)->begin()); - } - Trace("arrays-models") << "New default value = " << rep << endl; - defValues[mayRep] = rep; + if (fullModel) { + // Compute default value for this array - there is one default value for every mayEqual equivalence class + d_mayEqualEqualityEngine.addTerm(n); // add the term in case it isn't there already + TNode mayRep = d_mayEqualEqualityEngine.getRepresentative(n); + it = defValues.find(mayRep); + // If this mayEqual EC doesn't have a default value associated, get the next available default value for the associated array element type + if (it == defValues.end()) { + TypeNode valueType = n.getType().getArrayConstituentType(); + rep = defaultValuesSet.nextTypeEnum(valueType); + if (rep.isNull()) { + Assert(defaultValuesSet.getSet(valueType)->begin() != defaultValuesSet.getSet(valueType)->end()); + rep = *(defaultValuesSet.getSet(valueType)->begin()); + } + Trace("arrays-models") << "New default value = " << rep << endl; + defValues[mayRep] = rep; + } + else { + rep = (*it).second; + } + + // Build the STORE_ALL term with the default value + rep = nm->mkConst(ArrayStoreAll(n.getType().toType(), rep.toExpr())); } else { - rep = (*it).second; + std::hash_map::iterator it = d_skolemCache.find(n); + if (it == d_skolemCache.end()) { + rep = nm->mkSkolem("array_collect_model_var_$$", n.getType(), "base model variable for array collectModelInfo"); + d_skolemCache[n] = rep; + } + else { + rep = (*it).second; + } } - // Build the STORE_ALL term with the default value - rep = nm->mkConst(ArrayStoreAll(n.getType().toType(), rep.toExpr())); // For each read, require that the rep stores the right value vector& reads = selects[n]; for (unsigned j = 0; j < reads.size(); ++j) {