Fixed regression in simplifying predicates with more than one argument.
This commit is contained in:
parent
64c9a741c4
commit
5f8c144628
@ -170,6 +170,14 @@ void simplify(ast::Exists &exists, ast::Formula &formula)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there are no arguments left, we had a formula of the form “exists X1, ..., Xn (X1 = Y1 and ... and Xn = Yn)”
|
||||||
|
// Such exists statements are useless and can be safely replaced with “#true”
|
||||||
|
if (arguments.empty())
|
||||||
|
{
|
||||||
|
formula = ast::Formula::make<ast::Boolean>(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the argument now is a conjunction with just one element, directly replace the input formula with the argument
|
// If the argument now is a conjunction with just one element, directly replace the input formula with the argument
|
||||||
if (arguments.size() == 1)
|
if (arguments.size() == 1)
|
||||||
exists.argument = std::move(arguments.front());
|
exists.argument = std::move(arguments.front());
|
||||||
|
@ -166,4 +166,14 @@ TEST_CASE("[completion] Rules are completed", "[completion]")
|
|||||||
"forall V1, V2 (a(V1, V2) <-> b(c((V1 + V2)), d((1 + V2))))\n"
|
"forall V1, V2 (a(V1, V2) <-> b(c((V1 + V2)), d((1 + V2))))\n"
|
||||||
"forall V3, V4 not b(V3, V4)\n");
|
"forall V3, V4 not b(V3, V4)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("predicate with more than one argument")
|
||||||
|
{
|
||||||
|
input << "p(X, Y, Z).";
|
||||||
|
anthem::translate("input", input, context);
|
||||||
|
|
||||||
|
// TODO: simplify further
|
||||||
|
CHECK(output.str() ==
|
||||||
|
"forall V1, V2, V3 (p(V1, V2, V3) <-> #true)\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,4 +171,17 @@ TEST_CASE("[hidden predicate elimination] Hidden predicates are correctly elimin
|
|||||||
"not (s and not t)\n"
|
"not (s and not t)\n"
|
||||||
"not (not #false and not #false and #false)\n");
|
"not (not #false and not #false and #false)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("predicate with more than one argument is hidden correctly")
|
||||||
|
{
|
||||||
|
input <<
|
||||||
|
"a(X, Y, Z) :- p(X, Y, Z).\n"
|
||||||
|
"p(X, Y, Z).\n"
|
||||||
|
"#show a/3.";
|
||||||
|
anthem::translate("input", input, context);
|
||||||
|
|
||||||
|
// TODO: simplify further
|
||||||
|
CHECK(output.str() ==
|
||||||
|
"forall V1, V2, V3 (a(V1, V2, V3) <-> #true)\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user