diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2021-10-19 18:01:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 18:01:11 -0500 |
commit | bda77d20d51b0ebdd8dec4bd50c6ce5faef7f218 (patch) | |
tree | 8a814346774eea7f3b4a8af27ef0a8eb5177126b /src/theory/strings/base_solver.cpp | |
parent | 8fe459b1fb3843ebdbda86f24a414c46b986aa90 (diff) |
Support sequences of fixed finite cardinality (#7371)
The only open case is dynamic cardinality types (e.g. uninterpreted sorts when FMF is enabled).
Diffstat (limited to 'src/theory/strings/base_solver.cpp')
-rw-r--r-- | src/theory/strings/base_solver.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/theory/strings/base_solver.cpp b/src/theory/strings/base_solver.cpp index b675d2444..9396e3e87 100644 --- a/src/theory/strings/base_solver.cpp +++ b/src/theory/strings/base_solver.cpp @@ -17,6 +17,7 @@ #include "theory/strings/base_solver.h" #include "expr/sequence.h" +#include "options/quantifiers_options.h" #include "options/strings_options.h" #include "theory/rewriter.h" #include "theory/strings/theory_strings_utils.h" @@ -539,8 +540,41 @@ void BaseSolver::checkCardinalityType(TypeNode tn, // infinite cardinality, we are fine return; } - // TODO (cvc4-projects #23): how to handle sequence for finite types? - return; + // we check the cardinality class of the type, assuming that FMF is + // disabled. + if (isCardinalityClassFinite(etn.getCardinalityClass(), false)) + { + Cardinality c = etn.getCardinality(); + bool smallCardinality = false; + if (!c.isLargeFinite()) + { + Integer ci = c.getFiniteCardinality(); + if (ci.fitsUnsignedInt()) + { + smallCardinality = true; + typeCardSize = ci.toUnsignedInt(); + } + } + if (!smallCardinality) + { + // if it is large finite, then there is no way we could have + // constructed that many terms in memory, hence there is nothing + // to do. + return; + } + } + else + { + Assert(options().quantifiers.finiteModelFind); + // we are in a case where the cardinality of the type is infinite + // if not FMF, and finite given the Env's option value for FMF. In this + // case, FMF must be true, and the cardinality is finite and dynamic + // (i.e. it depends on the model's finite interpretation for uninterpreted + // sorts). We do not know how to handle this case, we set incomplete. + // TODO (cvc4-projects #23): how to handle sequence for finite types? + d_im.setIncomplete(IncompleteId::SEQ_FINITE_DYNAMIC_CARDINALITY); + return; + } } // for each collection for (unsigned i = 0, csize = cols.size(); i < csize; ++i) |