Added separate simplification step to normalize in a single recursion.

This commit is contained in:
2016-09-04 23:30:08 +02:00
parent 97ad4268d7
commit 4d72c20d9b
11 changed files with 128 additions and 16 deletions

View File

@@ -25,6 +25,20 @@ namespace pddl
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Expression::normalized()
{
return simplified()->negationNormalized();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Expression::simplified()
{
return this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Expression::negationNormalized()
{
return this;
}

View File

@@ -1,5 +1,7 @@
#include <plasp/pddl/expressions/At.h>
#include <plasp/utils/TranslatorException.h>
namespace plasp
{
namespace pddl
@@ -34,11 +36,18 @@ ExpressionPointer At::argument() const
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer At::normalized()
ExpressionPointer At::simplified()
{
throw utils::TranslatorException("“at” predicates currently not supported");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer At::negationNormalized()
{
BOOST_ASSERT(m_argument);
m_argument = m_argument->normalized();
m_argument = m_argument->negationNormalized();
return this;
}

View File

@@ -21,13 +21,13 @@ const std::string Imply::Identifier = "imply";
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Imply::normalized()
ExpressionPointer Imply::simplified()
{
BOOST_ASSERT(m_arguments[0]);
BOOST_ASSERT(m_arguments[1]);
m_arguments[0] = m_arguments[0]->normalized();
m_arguments[1] = m_arguments[1]->normalized();
m_arguments[0] = m_arguments[0]->simplified();
m_arguments[1] = m_arguments[1]->simplified();
auto notArgument0 = NotPointer(new Not);
notArgument0->setArgument(std::move(m_arguments[0]));
@@ -36,7 +36,7 @@ ExpressionPointer Imply::normalized()
orExpression->addArgument(std::move(notArgument0));
orExpression->addArgument(std::move(m_arguments[1]));
auto normalizedOrExpression = orExpression->normalized();
auto normalizedOrExpression = orExpression->simplified();
if (normalizedOrExpression)
return normalizedOrExpression;

View File

@@ -37,7 +37,18 @@ ExpressionPointer Not::argument() const
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Not::normalized()
ExpressionPointer Not::simplified()
{
BOOST_ASSERT(m_argument);
m_argument = m_argument->simplified();
return this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ExpressionPointer Not::negationNormalized()
{
BOOST_ASSERT(m_argument);