From e0846857d7f0a926203695315b565b3541175525 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Tue, 8 Dec 2020 22:08:52 -0600 Subject: [PATCH] Ensure CEGQI is applied for parametric datatypes when applicable (#5628) Previously was a bug computing the argument types of parametric datatypes. --- .../quantifiers/cegqi/ceg_instantiator.cpp | 16 ++++++++++++++-- test/regress/CMakeLists.txt | 1 + .../quantifiers/cegqi-par-dt-simple.smt2 | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/regress/regress0/quantifiers/cegqi-par-dt-simple.smt2 diff --git a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp index 0a5deb480..4e00a08e7 100644 --- a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp @@ -344,12 +344,24 @@ CegHandledStatus CegInstantiator::isCbqiSort( const DType& dt = tn.getDType(); for (unsigned i = 0, ncons = dt.getNumConstructors(); i < ncons; i++) { - for (unsigned j = 0, nargs = dt[i].getNumArgs(); j < nargs; j++) + // get the constructor type + TypeNode consType; + if (dt.isParametric()) + { + // if parametric, must instantiate the argument types + consType = dt[i].getSpecializedConstructorType(tn); + } + else + { + consType = dt[i].getConstructor().getType(); + } + for (const TypeNode& crange : consType) { - TypeNode crange = dt[i].getArgType(j); CegHandledStatus cret = isCbqiSort(crange, visited, qe); if (cret == CEG_UNHANDLED) { + Trace("cegqi-debug2") + << "Non-cbqi sort : " << tn << " due to " << crange << std::endl; visited[tn] = CEG_UNHANDLED; return CEG_UNHANDLED; } diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt index 590c2fef2..0bb5c9ef7 100644 --- a/test/regress/CMakeLists.txt +++ b/test/regress/CMakeLists.txt @@ -765,6 +765,7 @@ set(regress_0_tests regress0/quantifiers/cbqi-lia-dt-simp.smt2 regress0/quantifiers/cegqi-nl-simp.cvc regress0/quantifiers/cegqi-nl-sq.smt2 + regress0/quantifiers/cegqi-par-dt-simple.smt2 regress0/quantifiers/clock-10.smt2 regress0/quantifiers/clock-3.smt2 regress0/quantifiers/cond-var-elim-binary.smt2 diff --git a/test/regress/regress0/quantifiers/cegqi-par-dt-simple.smt2 b/test/regress/regress0/quantifiers/cegqi-par-dt-simple.smt2 new file mode 100644 index 000000000..1b72d3ba8 --- /dev/null +++ b/test/regress/regress0/quantifiers/cegqi-par-dt-simple.smt2 @@ -0,0 +1,7 @@ +; EXPECT: unsat +(set-logic ALL) +(declare-datatype List (par (T) ((nil) (cons (head T) (tail (List T)))))) + +(declare-const x (List Int)) +(assert (not (exists ((y (List Int))) (= x (tail y))))) +(check-sat) -- 2.30.2