Finished implementing the prenex normal form with maximal groups of same-type quantifiers.

This commit is contained in:
2016-09-08 02:40:51 +02:00
parent e0ed145716
commit 34496a7158
12 changed files with 207 additions and 86 deletions

View File

@@ -47,19 +47,17 @@ ExpressionPointer Expression::negationNormalized()
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Expression::prenex()
ExpressionPointer Expression::prenex(Expression::Type)
{
return this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Expression::prenex(ExpressionPointer parent, ExpressionPointer &child)
ExpressionPointer Expression::moveUpQuantifiers(ExpressionPointer parent, ExpressionPointer &child)
{
BOOST_ASSERT(child);
child = child->prenex();
if (child->expressionType() == Expression::Type::Exists)
{
auto quantifiedExpression = expressions::ExistsPointer(dynamic_cast<expressions::Exists *>(child.get()));
@@ -67,9 +65,6 @@ ExpressionPointer Expression::prenex(ExpressionPointer parent, ExpressionPointer
// Move argument up
child = quantifiedExpression->argument();
// Recursively build prenex form on new child
parent = Expression::prenex(parent, child);
// Move quantifier up
quantifiedExpression->setArgument(parent);
@@ -83,9 +78,6 @@ ExpressionPointer Expression::prenex(ExpressionPointer parent, ExpressionPointer
// Move argument up
child = quantifiedExpression->argument();
// Recursively build prenex form on new child
parent = Expression::prenex(parent, child);
// Move quantifier up
quantifiedExpression->setArgument(parent);

View File

@@ -54,11 +54,13 @@ ExpressionPointer At::negationNormalized()
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer At::prenex()
ExpressionPointer At::prenex(Expression::Type lastExpressionType)
{
BOOST_ASSERT(m_argument);
return Expression::prenex(this, m_argument);
m_argument = m_argument->prenex(lastExpressionType);
return Expression::moveUpQuantifiers(this, m_argument);
}
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -128,11 +128,13 @@ ExpressionPointer Not::negationNormalized()
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Not::prenex()
ExpressionPointer Not::prenex(Expression::Type lastExpressionType)
{
BOOST_ASSERT(m_argument);
return Expression::prenex(this, m_argument);
m_argument = m_argument->prenex(lastExpressionType);
return Expression::moveUpQuantifiers(this, m_argument);
}
////////////////////////////////////////////////////////////////////////////////////////////////////