Added second double negation elimination step after normalizing the argument of a “not” expression.

This commit is contained in:
Patrick Lühne 2016-09-04 22:45:37 +02:00
parent ed2d64c1c9
commit 97ad4268d7

View File

@ -41,7 +41,7 @@ ExpressionPointer Not::normalized()
{
BOOST_ASSERT(m_argument);
// Remove double negations immediately
// Remove immediate double negations
if (m_argument->expressionType() == Expression::Type::Not)
{
auto &argument = dynamic_cast<Not &>(*m_argument);
@ -49,8 +49,17 @@ ExpressionPointer Not::normalized()
return argument.m_argument->normalized();
}
// Normalize argument
m_argument = m_argument->normalized();
// Remove double negations occurring after normalizing the argument
if (m_argument->expressionType() == Expression::Type::Not)
{
auto &argument = dynamic_cast<Not &>(*m_argument);
return argument.m_argument->normalized();
}
// De Morgan for negative conjunctions
if (m_argument->expressionType() == Expression::Type::And)
{