Fixed issue with simplifying binary operations in arguments.

This commit is contained in:
Patrick Lühne 2017-06-09 22:00:00 +02:00
parent 9d1a1249d3
commit cbe87d8cb7
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 11 additions and 1 deletions

View File

@ -112,7 +112,7 @@ struct RecursiveTermVisitor
ReturnType visit(BinaryOperation &binaryOperation, Term &term, Arguments &&... arguments) ReturnType visit(BinaryOperation &binaryOperation, Term &term, Arguments &&... arguments)
{ {
binaryOperation.left.accept(*this, binaryOperation.left, std::forward<Arguments>(arguments)...); binaryOperation.left.accept(*this, binaryOperation.left, std::forward<Arguments>(arguments)...);
binaryOperation.right.accept(*this, binaryOperation.left, std::forward<Arguments>(arguments)...); binaryOperation.right.accept(*this, binaryOperation.right, std::forward<Arguments>(arguments)...);
return T::accept(binaryOperation, term, std::forward<Arguments>(arguments)...); return T::accept(binaryOperation, term, std::forward<Arguments>(arguments)...);
} }

View File

@ -145,4 +145,14 @@ TEST_CASE("[completion] Rules are completed", "[completion]")
"forall U2 not (U2 in 1..n and not covered(U2))\n" "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"); "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");
}
} }