From cbe87d8cb720bb1cca9ffddc8fc610f577a80f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 9 Jun 2017 22:00:00 +0200 Subject: [PATCH] Fixed issue with simplifying binary operations in arguments. --- include/anthem/ASTVisitors.h | 2 +- tests/TestCompletion.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/anthem/ASTVisitors.h b/include/anthem/ASTVisitors.h index b56f8c3..18d075a 100644 --- a/include/anthem/ASTVisitors.h +++ b/include/anthem/ASTVisitors.h @@ -112,7 +112,7 @@ struct RecursiveTermVisitor ReturnType visit(BinaryOperation &binaryOperation, Term &term, Arguments &&... arguments) { binaryOperation.left.accept(*this, binaryOperation.left, std::forward(arguments)...); - binaryOperation.right.accept(*this, binaryOperation.left, std::forward(arguments)...); + binaryOperation.right.accept(*this, binaryOperation.right, std::forward(arguments)...); return T::accept(binaryOperation, term, std::forward(arguments)...); } diff --git a/tests/TestCompletion.cpp b/tests/TestCompletion.cpp index 8c8e069..0742b0a 100644 --- a/tests/TestCompletion.cpp +++ b/tests/TestCompletion.cpp @@ -145,4 +145,14 @@ TEST_CASE("[completion] Rules are completed", "[completion]") "forall U2 not (U2 in 1..n and not covered(U2))\n" "forall U3, U4, U5 not (in(U3, U4) and in(U5, U4) and exists X1 (X1 in (U3 + U5) and in(X1, U4)))\n"); } + + SECTION("binary operations with multiple variables") + { + input << "a(X, Y) :- b(c(X + Y), d(1 + Y))."; + anthem::translate("input", input, context); + + CHECK(output.str() == + "forall V1, V2 (a(V1, V2) <-> b(c((V1 + V2)), d((1 + V2))))\n" + "forall V3, V4 not b(V3, V4)\n"); + } }