Move simplification rule to tableau
This moves the rule “[conjunction of only F] === F” to the simplification rule tableau.
This commit is contained in:
parent
4a85fc4b23
commit
827d6e40fe
@ -251,6 +251,28 @@ struct SimplificationRuleEmptyConjunction
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct SimplificationRuleOneElementConjunction
|
||||||
|
{
|
||||||
|
static constexpr const auto Description = "[conjunction of only F] === F";
|
||||||
|
|
||||||
|
static SimplificationResult apply(ast::Formula &formula)
|
||||||
|
{
|
||||||
|
if (!formula.is<ast::And>())
|
||||||
|
return SimplificationResult::Unchanged;
|
||||||
|
|
||||||
|
auto &and_ = formula.get<ast::And>();
|
||||||
|
|
||||||
|
if (and_.arguments.size() != 1)
|
||||||
|
return SimplificationResult::Unchanged;
|
||||||
|
|
||||||
|
formula = std::move(and_.arguments.front());
|
||||||
|
|
||||||
|
return SimplificationResult::Simplified;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct SimplificationRuleTrivialExists
|
struct SimplificationRuleTrivialExists
|
||||||
{
|
{
|
||||||
static constexpr const auto Description = "exists ... ([#true/#false]) === [#true/#false]";
|
static constexpr const auto Description = "exists ... ([#true/#false]) === [#true/#false]";
|
||||||
@ -278,25 +300,14 @@ void simplify(ast::Exists &exists, ast::Formula &formula)
|
|||||||
SimplificationRuleTrivialAssignmentInExists::apply(formula);
|
SimplificationRuleTrivialAssignmentInExists::apply(formula);
|
||||||
SimplificationRuleAssignmentInExists::apply(formula);
|
SimplificationRuleAssignmentInExists::apply(formula);
|
||||||
|
|
||||||
if (!exists.argument.is<ast::And>())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto &and_ = exists.argument.get<ast::And>();
|
|
||||||
auto &arguments = and_.arguments;
|
|
||||||
|
|
||||||
SimplificationRuleEmptyConjunction::apply(exists.argument);
|
SimplificationRuleEmptyConjunction::apply(exists.argument);
|
||||||
SimplificationRuleTrivialExists::apply(formula);
|
SimplificationRuleTrivialExists::apply(formula);
|
||||||
|
SimplificationRuleOneElementConjunction::apply(exists.argument);
|
||||||
// If the argument now is a conjunction with just one element, directly replace the input formula with the argument
|
|
||||||
if (arguments.size() == 1)
|
|
||||||
exists.argument = std::move(arguments.front());
|
|
||||||
|
|
||||||
// If there are still remaining variables, simplification is over
|
// If there are still remaining variables, simplification is over
|
||||||
if (!exists.variables.empty())
|
if (!exists.variables.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(!arguments.empty());
|
|
||||||
|
|
||||||
// If there is more than one element in the conjunction, replace the input formula with the conjunction
|
// If there is more than one element in the conjunction, replace the input formula with the conjunction
|
||||||
formula = std::move(exists.argument);
|
formula = std::move(exists.argument);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user