From 02c6d85573f2372342035239223acbbe4f4991e0 Mon Sep 17 00:00:00 2001 From: Benjamin Kaufmann Date: Fri, 3 Nov 2017 19:14:27 +0100 Subject: [PATCH] Remove wrong assertion * The assertion failed to consider the case where a disjunction was eq to some atom that itself was part of a disjunction. Fixes #13 --- src/logic_program.cpp | 1 - tests/dlp_builder_test.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/logic_program.cpp b/src/logic_program.cpp index 059cd89..08a0224 100644 --- a/src/logic_program.cpp +++ b/src/logic_program.cpp @@ -1277,7 +1277,6 @@ void LogicProgram::finalizeDisjunctions(Preprocessor& p, uint32 numSccs) { d->destroy(); // create shortcut for supports to avoid duplications during shifting Literal supportLit = dx != bot ? getEqAtomLit(dx, supports, p, sccMap) : dx; - POTASSCO_ASSERT(dx == bot || getRootAtom(supportLit.var())->var() == dx.var()); // create shifted rules and split disjunctions into non-hcf components for (VarVec::iterator hIt = head.begin(), hEnd = head.end(); hIt != hEnd; ++hIt) { uint32 scc = getAtom(*hIt)->scc(); diff --git a/tests/dlp_builder_test.cpp b/tests/dlp_builder_test.cpp index 88f01a3..68cb772 100644 --- a/tests/dlp_builder_test.cpp +++ b/tests/dlp_builder_test.cpp @@ -171,6 +171,15 @@ TEST_CASE("Disjunctive logic programs", "[asp][dlp]") { REQUIRE(ctx.master()->isTrue(lp.getLiteral(b))); } + SECTION("testOddLoop") { + lpAdd(lp.start(ctx), + "a|b :- not c.\n" + "c|d :- not a.\n"); + REQUIRE((lp.endProgram() && ctx.endInit())); + REQUIRE(lp.stats.disjunctions[0] == 2); + REQUIRE(lp.stats.disjunctions[1] == 0); + } + SECTION("testNoEqRegression") { lpAdd(lp.start(ctx, LogicProgram::AspOptions().noEq()), "{c}.\n"