Alternative for https://github.com/cvc5/cvc5/pull/8546.
We were mistakenly using `mkGroundTerm` instead of `mkGroundValue` to make the domain of an uninterpreted sort non-empty.
This ensures that get-value calls do not throw a spurious exception when there is a declared uninterpreted sort and there are no terms of that sort.
As a result, this also required fixing a few further issues regarding how uninterpreted sort constants are printed in models, and fixing the expected results on 2 more regressions.
for (const cvc5::Sort& s : declareSorts)
{
std::vector<cvc5::Term> elements = d_solver->getModelDomainElements(s);
+ Trace("parser") << "elements for " << s << ":" << std::endl;
for (const cvc5::Term& e : elements)
{
- defineVar(e.getUninterpretedSortValue(), e);
+ Trace("parser") << " " << e.getKind() << " " << e << std::endl;
+ if (e.getKind() == Kind::UNINTERPRETED_SORT_VALUE)
+ {
+ defineVar(e.getUninterpretedSortValue(), e);
+ }
+ else
+ {
+ Assert(false)
+ << "model domain element is not an uninterpreted sort value: " << e;
+ }
}
}
}
// print the representatives
for (const Node& trn : elements)
{
- if (trn.isVar())
+ if (options::modelUninterpPrint()
+ == options::ModelUninterpPrintMode::DeclSortAndFun
+ || options::modelUninterpPrint()
+ == options::ModelUninterpPrintMode::DeclFun)
{
- if (options::modelUninterpPrint()
- == options::ModelUninterpPrintMode::DeclSortAndFun
- || options::modelUninterpPrint()
- == options::ModelUninterpPrintMode::DeclFun)
+ out << "(declare-fun ";
+ if (trn.getKind() == kind::UNINTERPRETED_SORT_VALUE)
{
- out << "(declare-fun " << trn << " () " << tn << ")" << endl;
+ // prints as raw symbol
+ const UninterpretedSortValue& av =
+ trn.getConst<UninterpretedSortValue>();
+ out << av;
}
+ else
+ {
+ Assert(false)
+ << "model domain element is not an uninterpreted sort value: "
+ << trn;
+ out << trn;
+ }
+ out << " () " << tn << ")" << endl;
}
else
{
{
// This is called when t is a sort that does not occur in this model.
// Sorts are always interpreted as non-empty, thus we add a single element.
+ // We use mkGroundValue here, since domain elements must all be
+ // of UNINTERPRETED_SORT_VALUE kind.
NodeManager* nm = NodeManager::currentNM();
- elements.push_back(nm->mkGroundTerm(tn));
+ elements.push_back(nm->mkGroundValue(tn));
return elements;
}
return *type_refs;
regress0/cvc3.userdoc.04.cvc.smt2
regress0/cvc3.userdoc.05.cvc.smt2
regress0/cvc3.userdoc.06.cvc.smt2
+ regress0/cvc5-printing.cpp-sample.smt2
regress0/datatypes/4482-unc-simp-one.smt2
regress0/datatypes/boolean-equality.cvc.smt2
regress0/datatypes/boolean-terms-datatype.cvc.smt2
--- /dev/null
+; SCRUBBER: sed -e 's/((x.*//g'
+; EXPECT: unsat
+; EXPECT: sat
+(set-option :bv-print-consts-as-indexed-symbols true)
+(set-logic QF_AUFBV)
+(set-option :produce-models true)
+(set-option :incremental true)
+(set-option :produce-unsat-assumptions true)
+(declare-sort S 0)
+(declare-fun x () (_ BitVec 32))
+(declare-fun y () (_ BitVec 32))
+(declare-fun arr () (Array (_ BitVec 32) (_ BitVec 32)))
+(declare-fun f ((_ BitVec 32) ) S)
+(declare-fun s () S)
+(declare-fun ind1 () Bool)
+(push 1)
+(assert ind1)
+(assert (= ind1 (= (f x) s)))
+(assert (= (f x) s))
+(assert (not (=> (= x y) (= (select arr x) (select arr y)))))
+(check-sat-assuming (ind1 ))
+(pop 1)
+(check-sat)
+(get-value (x))
; the purpose of this test is to verify that there is a `as` term in the output.
; the scrubber excludes all lines without "(as @", and replaces this pattern by "AS".
-; SCRUBBER: sed -e 's/.*(as @.*/AS/; /sat/d; /cardinality/d; /^($/d; /^)$/d'
+; SCRUBBER: sed -e 's/.*(as @.*/AS/; /sat/d; /cardinality/d; /rep/d; /^($/d; /^)$/d'
+; EXPECT: AS
; EXPECT: AS
(set-logic QF_UF)
(set-option :produce-models true)
; COMMAND-LINE: --model-u-print=decl-fun
-; EXPECT: (declare-fun gt () us_image)
-; EXPECT: (declare-fun gt () ||)
-; SCRUBBER: sed -e '/declare-fun/!d; s/declare-fun [^[:space:]]*/declare-fun gt/g'
+; EXPECT: (declare-fun a () us_image)
+; EXPECT: (declare-fun a () ||)
+; SCRUBBER: sed -e '/declare-fun/!d; s/declare-fun [^[:space:]]*/declare-fun a/g'
(set-option :produce-models true)
(set-logic QF_UF)
(declare-sort us_image 0)