Move simplification rule to tableau
This moves the rule “exists X (X = t and F(X)) === exists () (F(t))” to the simplification rule tableau.
This commit is contained in:
parent
5c5411c0ff
commit
7e3fc007c8
@ -161,19 +161,25 @@ struct SimplificationRuleTrivialExists
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Simplifies exists statements by using the equivalence “exists X (X = t and F(X))” == “F(t)”
|
||||
// The exists statement has to be of the form “exists <variables> <conjunction>”
|
||||
void simplify(ast::Exists &exists, ast::Formula &formula)
|
||||
struct SimplificationRuleAssignmentInExists
|
||||
{
|
||||
SimplificationRuleTrivialExists::apply(formula);
|
||||
static constexpr const auto Description = "exists X (X = t and F(X)) === exists () (F(t))";
|
||||
|
||||
static SimplificationResult apply(ast::Formula &formula)
|
||||
{
|
||||
if (!formula.is<ast::Exists>())
|
||||
return SimplificationResult::Unchanged;
|
||||
|
||||
auto &exists = formula.get<ast::Exists>();
|
||||
|
||||
if (!exists.argument.is<ast::And>())
|
||||
return;
|
||||
return SimplificationResult::Unchanged;
|
||||
|
||||
auto &conjunction = exists.argument.get<ast::And>();
|
||||
auto &arguments = conjunction.arguments;
|
||||
auto &and_ = exists.argument.get<ast::And>();
|
||||
auto &arguments = and_.arguments;
|
||||
|
||||
auto simplificationResult = SimplificationResult::Unchanged;
|
||||
|
||||
// Simplify formulas of type “exists X (X = t and F(X))” to “F(t)”
|
||||
for (auto i = exists.variables.begin(); i != exists.variables.end();)
|
||||
{
|
||||
const auto &variableDeclaration = **i;
|
||||
@ -201,7 +207,10 @@ void simplify(ast::Exists &exists, ast::Formula &formula)
|
||||
}
|
||||
|
||||
arguments.erase(j);
|
||||
|
||||
wasVariableReplaced = true;
|
||||
simplificationResult = SimplificationResult::Simplified;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -214,6 +223,23 @@ void simplify(ast::Exists &exists, ast::Formula &formula)
|
||||
i++;
|
||||
}
|
||||
|
||||
return simplificationResult;
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void simplify(ast::Exists &exists, ast::Formula &formula)
|
||||
{
|
||||
SimplificationRuleTrivialExists::apply(formula);
|
||||
SimplificationRuleAssignmentInExists::apply(formula);
|
||||
|
||||
if (!exists.argument.is<ast::And>())
|
||||
return;
|
||||
|
||||
auto &and_ = exists.argument.get<ast::And>();
|
||||
auto &arguments = and_.arguments;
|
||||
|
||||
// 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())
|
||||
|
Loading…
Reference in New Issue
Block a user