Move simplification rule to tableau
This moves the rule “[primitive A] in [primitive B] === A = B” to the simplification rule tableau.
This commit is contained in:
parent
107dae7287
commit
c4c3156e77
@ -317,6 +317,30 @@ struct SimplificationRuleTrivialExists
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct SimplificationRuleInWithPrimitiveArguments
|
||||||
|
{
|
||||||
|
static constexpr const auto Description = "[primitive A] in [primitive B] === A = B";
|
||||||
|
|
||||||
|
static SimplificationResult apply(ast::Formula &formula)
|
||||||
|
{
|
||||||
|
if (!formula.is<ast::In>())
|
||||||
|
return SimplificationResult::Unchanged;
|
||||||
|
|
||||||
|
auto &in = formula.get<ast::In>();
|
||||||
|
|
||||||
|
assert(ast::isPrimitive(in.element));
|
||||||
|
|
||||||
|
if (!ast::isPrimitive(in.element) || !ast::isPrimitive(in.set))
|
||||||
|
return SimplificationResult::Unchanged;
|
||||||
|
|
||||||
|
formula = ast::Comparison(ast::Comparison::Operator::Equal, std::move(in.element), std::move(in.set));
|
||||||
|
|
||||||
|
return SimplificationResult::Simplified;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void simplify(ast::Exists &exists, ast::Formula &formula)
|
void simplify(ast::Exists &exists, ast::Formula &formula)
|
||||||
{
|
{
|
||||||
SimplificationRuleTrivialAssignmentInExists::apply(formula);
|
SimplificationRuleTrivialAssignmentInExists::apply(formula);
|
||||||
@ -341,14 +365,9 @@ struct SimplifyFormulaVisitor : public ast::RecursiveFormulaVisitor<SimplifyForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simplify formulas of type “A in B” to “A = B” if A and B are primitive
|
// Simplify formulas of type “A in B” to “A = B” if A and B are primitive
|
||||||
static void accept(ast::In &in, ast::Formula &formula)
|
static void accept(ast::In &, ast::Formula &formula)
|
||||||
{
|
{
|
||||||
assert(ast::isPrimitive(in.element));
|
SimplificationRuleInWithPrimitiveArguments::apply(formula);
|
||||||
|
|
||||||
if (!ast::isPrimitive(in.element) || !ast::isPrimitive(in.set))
|
|
||||||
return;
|
|
||||||
|
|
||||||
formula = ast::Comparison(ast::Comparison::Operator::Equal, std::move(in.element), std::move(in.set));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do nothing for all other types of expressions
|
// Do nothing for all other types of expressions
|
||||||
|
Loading…
Reference in New Issue
Block a user