From 54eb1c069f0a86b157945d95eb0ae0999d8470fd Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Tue, 10 Mar 2020 10:56:58 -0500 Subject: [PATCH] Do not set values for non-linear mult terms in collectModelInfo (#3983) Fixes #3803. When non-linear arithmetic determines there is a model, then it should not send model values for multiplication terms that the linear solver assigned when abstracting (non-linear) multiplication. This avoids conflicts if the non-linear solver changed a value for a variable occurring in a non-linear monomial. This avoids check-model failures. --- src/theory/arith/nl_model.cpp | 18 +++++++++++++++++- test/regress/CMakeLists.txt | 1 + .../regress1/nl/issue3803-nl-check-model.smt2 | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/regress/regress1/nl/issue3803-nl-check-model.smt2 diff --git a/src/theory/arith/nl_model.cpp b/src/theory/arith/nl_model.cpp index 904300004..abb2a7921 100644 --- a/src/theory/arith/nl_model.cpp +++ b/src/theory/arith/nl_model.cpp @@ -1277,11 +1277,12 @@ void NlModel::getModelValueRepair( std::map& arithModel, std::map>& approximations) { + Trace("nl-model") << "NlModel::getModelValueRepair:" << std::endl; + // Record the approximations we used. This code calls the // recordApproximation method of the model, which overrides the model // values for variables that we solved for, using techniques specific to // this class. - Trace("nl-model") << "NlModel::getModelValueRepair:" << std::endl; NodeManager* nm = NodeManager::currentNM(); for (const std::pair >& cb : d_check_model_bounds) @@ -1324,6 +1325,21 @@ void NlModel::getModelValueRepair( arithModel[v] = s; Trace("nl-model") << v << " solved is " << s << std::endl; } + + // multiplication terms should not be given values; their values are + // implied by the monomials that they consist of + std::vector amErase; + for (const std::pair& am : arithModel) + { + if (am.first.getKind() == NONLINEAR_MULT) + { + amErase.push_back(am.first); + } + } + for (const Node& ae : amErase) + { + arithModel.erase(ae); + } } } // namespace arith diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index d449669a9..35d5c5bd5 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -1330,6 +1330,7 @@ set(regress_1_tests regress1/nl/issue3617.smt2 regress1/nl/issue3647.smt2 regress1/nl/issue3656.smt2 + regress1/nl/issue3803-nl-check-model.smt2 regress1/nl/metitarski-1025.smt2 regress1/nl/metitarski-3-4.smt2 regress1/nl/metitarski_3_4_2e.smt2 diff --git a/test/regress/regress1/nl/issue3803-nl-check-model.smt2 b/test/regress/regress1/nl/issue3803-nl-check-model.smt2 new file mode 100644 index 000000000..7dfda36ea --- /dev/null +++ b/test/regress/regress1/nl/issue3803-nl-check-model.smt2 @@ -0,0 +1,12 @@ +; COMMAND-LINE: --ext-rew-prep +; EXPECT: sat +(set-logic ALL) +(set-info :status sat) +(declare-fun a () Real) +(declare-fun b () Real) +(declare-fun c () Real) +(declare-fun d () Real) +(declare-fun e () Real) +(assert (exists ((f Real)) (and (or (> (+ d (* (/ (* c e) (- (* c e) e)) f)) 0 (/ 0 a))) (> e 6)))) +(assert (distinct a (/ b e))) +(check-sat) -- 2.30.2