From: Andrew Reynolds Date: Wed, 20 Jan 2021 18:59:13 +0000 (-0600) Subject: Fix corner case of wrongly applied selector as trigger (#5786) X-Git-Tag: cvc5-1.0.0~2372 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=273219488df1068a1abd444fc677bee57748bc32;p=cvc5.git Fix corner case of wrongly applied selector as trigger (#5786) Fixes #5766. --- diff --git a/src/theory/quantifiers/ematching/candidate_generator.cpp b/src/theory/quantifiers/ematching/candidate_generator.cpp index 728ba61e8..0fd5249e8 100644 --- a/src/theory/quantifiers/ematching/candidate_generator.cpp +++ b/src/theory/quantifiers/ematching/candidate_generator.cpp @@ -279,20 +279,25 @@ CandidateGeneratorSelector::CandidateGeneratorSelector(QuantifiersEngine* qe, d_selOp = qe->getTermDatabase()->getMatchOperator(mpatExp[1]); d_ufOp = qe->getTermDatabase()->getMatchOperator(mpatExp[2]); } - else + else if (mpatExp.getKind() == APPLY_SELECTOR_TOTAL) { // corner case of datatype with one constructor - Assert(mpatExp.getKind() == APPLY_SELECTOR_TOTAL); d_selOp = qe->getTermDatabase()->getMatchOperator(mpatExp); } + else + { + // corner case of a wrongly applied selector as a trigger + Assert(mpatExp.getKind() == APPLY_UF); + d_ufOp = qe->getTermDatabase()->getMatchOperator(mpatExp); + } Assert(d_selOp != d_ufOp); } void CandidateGeneratorSelector::reset(Node eqc) { Trace("sel-trigger-debug") << "Reset in eqc=" << eqc << std::endl; - // start with d_selOp - resetForOperator(eqc, d_selOp); + // start with d_selOp, if it exists + resetForOperator(eqc, !d_selOp.isNull()? d_selOp : d_ufOp); } Node CandidateGeneratorSelector::getNextCandidate() diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index 1c51a6c05..da4c6633b 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -1757,6 +1757,7 @@ set(regress_1_tests regress1/quantifiers/issue5484b-qe.smt2 regress1/quantifiers/issue5506-qe.smt2 regress1/quantifiers/issue5507-qe.smt2 + regress1/quantifiers/issue5766-wrong-sel-trigger.smt2 regress1/quantifiers/issue993.smt2 regress1/quantifiers/javafe.ast.StmtVec.009.smt2 regress1/quantifiers/lia-witness-div-pp.smt2 diff --git a/test/regress/regress1/quantifiers/issue5766-wrong-sel-trigger.smt2 b/test/regress/regress1/quantifiers/issue5766-wrong-sel-trigger.smt2 new file mode 100644 index 000000000..9ccde98cd --- /dev/null +++ b/test/regress/regress1/quantifiers/issue5766-wrong-sel-trigger.smt2 @@ -0,0 +1,15 @@ +; COMMAND-LINE: --sygus-inst --no-check-models +; EXPECT: sat +(set-logic ALL) +(set-info :status sat) +(declare-datatypes ((a 0)) + (((b (c a) (d a)) (n (o a)) (e (f a) (g a)) (h (i (_ BitVec 1)))))) +(declare-fun j (a) Bool) +(declare-fun k (a) a) +(declare-fun l () a) +(assert (forall ((m a)) (=> ((_ is h) m) (j (ite ((_ is b) m) (b m m) + (ite ((_ is e) m) (e m m) (ite ((_ is b) m) (e m m) (ite (xor ((_ + is n) m) ((_ is e) m)) (b m m) (ite (xor ((_ is n) m) ((_ is n) (o + m))) (k (o m)) (ite ((_ is n) m) m (ite ((_ is h) m) m + l))))))))))) +(check-sat)