summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGereon Kremer <gereon.kremer@cs.rwth-aachen.de>2020-08-19 18:54:17 +0200
committerGitHub <noreply@github.com>2020-08-19 11:54:17 -0500
commit1c67e4cc188b4812cedb614e6e998ea944ddb320 (patch)
tree0d423f7ff5abbc0ae94549a99d90440567522b99
parent41f1a9a0036f3d18ec21ef6005fb218cf704fe60 (diff)
Changes assertion (about maximum set cardinality) to an exception. (#4907)
Changes the assertion that checks for the maximum cardinality of set models to an exception, following #4374. Also cleans up the code around it: previously, the Rational was checked against LONG_MAX, converted to std::uint32_t and then stored into an unsigned. Now we use std::uint32_t all the way. Fixes #4374.
-rw-r--r--src/theory/sets/cardinality_extension.cpp11
-rw-r--r--src/theory/strings/theory_strings.cpp13
-rw-r--r--test/regress/regress0/strings/large-model.smt23
3 files changed, 17 insertions, 10 deletions
diff --git a/src/theory/sets/cardinality_extension.cpp b/src/theory/sets/cardinality_extension.cpp
index 1c12c71e4..4aa866d27 100644
--- a/src/theory/sets/cardinality_extension.cpp
+++ b/src/theory/sets/cardinality_extension.cpp
@@ -997,9 +997,14 @@ void CardinalityExtension::mkModelValueElementsFor(
Node v = val.getModelValue(it->second);
Trace("sets-model") << "Cardinality of " << eqc << " is " << v
<< std::endl;
- Assert(v.getConst<Rational>() <= LONG_MAX)
- << "Exceeded LONG_MAX in sets model";
- unsigned vu = v.getConst<Rational>().getNumerator().toUnsignedInt();
+ if (v.getConst<Rational>() > UINT32_MAX)
+ {
+ std::stringstream ss;
+ ss << "The model for " << eqc << " was computed to have cardinality "
+ << v << ". We only allow sets up to cardinality " << UINT32_MAX;
+ throw LogicException(ss.str());
+ }
+ std::uint32_t vu = v.getConst<Rational>().getNumerator().toUnsignedInt();
Assert(els.size() <= vu);
NodeManager* nm = NodeManager::currentNM();
if (elementType.isInterpretedFinite())
diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp
index b23765313..c78e8dc2a 100644
--- a/src/theory/strings/theory_strings.cpp
+++ b/src/theory/strings/theory_strings.cpp
@@ -312,7 +312,7 @@ bool TheoryStrings::collectModelInfoType(
std::map< Node, Node > processed;
//step 1 : get all values for known lengths
std::vector< Node > lts_values;
- std::map<unsigned, Node> values_used;
+ std::map<std::size_t, Node> values_used;
std::vector<Node> len_splits;
for( unsigned i=0; i<col.size(); i++ ) {
Trace("strings-model") << "Checking length for {";
@@ -339,15 +339,16 @@ bool TheoryStrings::collectModelInfoType(
else
{
// must throw logic exception if we cannot construct the string
- if (len_value.getConst<Rational>() > Rational(String::maxSize()))
+ if (len_value.getConst<Rational>() > String::maxSize())
{
std::stringstream ss;
- ss << "Cannot generate model with string whose length exceeds UINT32_MAX";
+ ss << "The model was computed to have strings of length " << len_value
+ << ". We only allow strings up to length " << String::maxSize();
throw LogicException(ss.str());
}
- unsigned lvalue =
+ std::size_t lvalue =
len_value.getConst<Rational>().getNumerator().toUnsignedInt();
- std::map<unsigned, Node>::iterator itvu = values_used.find(lvalue);
+ auto itvu = values_used.find(lvalue);
if (itvu == values_used.end())
{
values_used[lvalue] = lts[i];
@@ -417,7 +418,7 @@ bool TheoryStrings::collectModelInfoType(
if( !pure_eq.empty() ){
if( lts_values[i].isNull() ){
// start with length two (other lengths have special precendence)
- unsigned lvalue = 2;
+ std::size_t lvalue = 2;
while( values_used.find( lvalue )!=values_used.end() ){
lvalue++;
}
diff --git a/test/regress/regress0/strings/large-model.smt2 b/test/regress/regress0/strings/large-model.smt2
index 74b781c82..f3aa7f8f2 100644
--- a/test/regress/regress0/strings/large-model.smt2
+++ b/test/regress/regress0/strings/large-model.smt2
@@ -1,5 +1,6 @@
; COMMAND-LINE: --lang=smt2.6 --check-models
-; EXPECT: (error "Cannot generate model with string whose length exceeds UINT32_MAX")
+; SCRUBBER: sed -E 's/of length [0-9]+/of length LENGTH/'
+; EXPECT: (error "The model was computed to have strings of length LENGTH. We only allow strings up to length 4294967295")
; EXIT: 1
(set-logic SLIA)
(declare-fun x () String)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback