From d451d2d548657abc56c27f6456a3f7ca8955c9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 27 Jun 2017 11:35:47 +0200 Subject: [PATCH] =?UTF-8?q?Handling=20negations=20introduced=20by=20?= =?UTF-8?q?=E2=80=9Cforall=E2=80=9D=20elimination=20correctly.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/normalization/Reduction.cpp | 66 +------------------ 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/lib/pddlparse/src/pddlparse/detail/normalization/Reduction.cpp b/lib/pddlparse/src/pddlparse/detail/normalization/Reduction.cpp index 26f0a50..1694a28 100644 --- a/lib/pddlparse/src/pddlparse/detail/normalization/Reduction.cpp +++ b/lib/pddlparse/src/pddlparse/detail/normalization/Reduction.cpp @@ -269,78 +269,16 @@ void eliminateForAll(ast::Precondition &precondition) //////////////////////////////////////////////////////////////////////////////////////////////////// -void eliminateDoubleNegations(ast::Precondition &precondition) -{ - const auto handleAtomicFormula = - [](ast::AtomicFormula &) - { - }; - - const auto handleAnd = - [](ast::AndPointer &and_) - { - for (auto &argument : and_->arguments) - eliminateDoubleNegations(argument); - }; - - const auto handleExists = - [](ast::ExistsPointer &exists) - { - eliminateDoubleNegations(exists->argument); - }; - - const auto handleForAll = - [&](ast::ForAllPointer &forAll) - { - eliminateDoubleNegations(forAll->argument); - }; - - const auto handleImply = - [&](ast::ImplyPointer &imply) - { - eliminateDoubleNegations(imply->argumentLeft); - eliminateDoubleNegations(imply->argumentRight); - }; - - const auto handleNot = - [&](ast::NotPointer ¬_) - { - eliminateDoubleNegations(not_->argument); - - if (not_->argument.is>()) - { - // As the parent contains the argument, the argument needs to be saved before overwriting the parent - // TODO: check whether this workaround can be avoided - auto argument = std::move(not_->argument.get>()); - precondition = std::move(argument); - } - }; - - const auto handleOr = - [](ast::OrPointer &or_) - { - for (auto &argument : or_->arguments) - eliminateDoubleNegations(argument); - }; - - precondition.match(handleAtomicFormula, handleAnd, handleExists, handleForAll, handleImply, handleNot, handleOr); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - void reduce(ast::Precondition &precondition) { // Replace “imply” statements with disjunctions eliminateImply(precondition); - // Negation-normalize the precondition - negationNormalize(precondition); - // Eliminate “forall” statements eliminateForAll(precondition); - // Eliminate double negations introduced by eliminating “forall” statements - eliminateDoubleNegations(precondition); + // Negation-normalize the precondition + negationNormalize(precondition); } ////////////////////////////////////////////////////////////////////////////////////////////////////