From 12efe41551c3cb7d54213fcbd192550a59b97a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 24 Jun 2017 18:37:20 +0200 Subject: [PATCH] Fixed issue due to undefined implementations. --- .../detail/normalization/Precondition.cpp | 88 ++++++++++++------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/lib/pddlparse/src/pddlparse/detail/normalization/Precondition.cpp b/lib/pddlparse/src/pddlparse/detail/normalization/Precondition.cpp index db68191..c017fc5 100644 --- a/lib/pddlparse/src/pddlparse/detail/normalization/Precondition.cpp +++ b/lib/pddlparse/src/pddlparse/detail/normalization/Precondition.cpp @@ -22,18 +22,14 @@ namespace detail // Forward Declarations //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::AndPointer &and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::Literal normalizeNested(ast::ExistsPointer &exists, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::Literal normalizeNested(ast::ForAllPointer &forAll, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::Literal normalizeNested(ast::ImplyPointer &, normalizedAST::DerivedPredicateDeclarations &); -normalizedAST::Literal normalizeNested(ast::NotPointer ¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::Literal normalizeNested(ast::OrPointer &or_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::Literal normalizeNested(ast::UnsupportedPointer &unsupported, normalizedAST::DerivedPredicateDeclarations &); -normalizedAST::Literal normalizeNested(ast::AtomicFormula &, normalizedAST::DerivedPredicateDeclarations &); -normalizedAST::PredicatePointer normalize(ast::UnsupportedPointer &&unsupported, normalizedAST::DerivedPredicateDeclarations &); -normalizedAST::AtomicFormula normalize(ast::AtomicFormula &atomicFormula, normalizedAST::DerivedPredicateDeclarations &); -normalizedAST::NotPointer normalize(ast::NotPointer &¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); -normalizedAST::AndPointer normalize(ast::AndPointer &&and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::AndPointer &and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::ExistsPointer &exists, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::ForAllPointer &forAll, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::ImplyPointer &, normalizedAST::DerivedPredicateDeclarations &); +normalizedAST::Literal normalizeNestedImpl(ast::NotPointer ¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::OrPointer &or_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates); +normalizedAST::Literal normalizeNestedImpl(ast::UnsupportedPointer &unsupported, normalizedAST::DerivedPredicateDeclarations &); +normalizedAST::Literal normalizeNestedImpl(ast::AtomicFormula &, normalizedAST::DerivedPredicateDeclarations &); //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -58,7 +54,7 @@ normalizedAST::DerivedPredicatePointer addDerivedPredicate(const std::vector &and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::Literal normalizeNestedImpl(ast::AndPointer &and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { std::vector parameters; VariableStack variableStack; @@ -74,7 +70,7 @@ normalizedAST::Literal normalizeNested(ast::AndPointer &and_, normalizedArguments.emplace_back(argument.match( [&](auto &x) -> normalizedAST::Literal { - return normalizeNested(x, derivedPredicates); + return normalizeNestedImpl(x, derivedPredicates); })); derivedPredicate->declaration->precondition = std::make_unique>(std::move(normalizedArguments)); @@ -85,7 +81,7 @@ normalizedAST::Literal normalizeNested(ast::AndPointer &and_, //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::ExistsPointer &exists, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::Literal normalizeNestedImpl(ast::ExistsPointer &exists, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { std::vector parameters; VariableStack variableStack; @@ -95,7 +91,7 @@ normalizedAST::Literal normalizeNested(ast::ExistsPointer &ex auto derivedPredicate = addDerivedPredicate(parameters, derivedPredicates); derivedPredicate->declaration->existentialParameters = std::move(exists->parameters); - derivedPredicate->declaration->precondition = exists->argument.match([&](auto &x){return normalizeNested(x, derivedPredicates);}); + derivedPredicate->declaration->precondition = exists->argument.match([&](auto &x){return normalizeNestedImpl(x, derivedPredicates);}); // TODO: investigate, could be a compiler bug return std::move(derivedPredicate); @@ -103,7 +99,7 @@ normalizedAST::Literal normalizeNested(ast::ExistsPointer &ex //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::ForAllPointer &, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::Literal normalizeNestedImpl(ast::ForAllPointer &, normalizedAST::DerivedPredicateDeclarations &) { // “forall” expressions should be reduced to negated “exists” statements at this point throw std::logic_error("precondition not in normal form (forall), please report to the bug tracker"); @@ -111,7 +107,7 @@ normalizedAST::Literal normalizeNested(ast::ForAllPointer &, //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::ImplyPointer &, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::Literal normalizeNestedImpl(ast::ImplyPointer &, normalizedAST::DerivedPredicateDeclarations &) { // “imply” expressions should be reduced to disjunctions at this point throw std::logic_error("precondition not in normal form (imply), please report to the bug tracker"); @@ -119,7 +115,7 @@ normalizedAST::Literal normalizeNested(ast::ImplyPointer &, n //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::NotPointer ¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::Literal normalizeNestedImpl(ast::NotPointer ¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { // “not” expressions may be nested one time to form simple literals if (not_->argument.is()) @@ -135,7 +131,7 @@ normalizedAST::Literal normalizeNested(ast::NotPointer ¬_, auto normalizedArgumentLiteral = not_->argument.match( [&](auto &x) -> normalizedAST::Literal { - return normalizeNested(x, derivedPredicates); + return normalizeNestedImpl(x, derivedPredicates); }); // Multiple negations should be eliminated at this point @@ -152,7 +148,7 @@ normalizedAST::Literal normalizeNested(ast::NotPointer ¬_, //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::OrPointer &or_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::Literal normalizeNestedImpl(ast::OrPointer &or_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { std::vector parameters; VariableStack variableStack; @@ -168,7 +164,7 @@ normalizedAST::Literal normalizeNested(ast::OrPointer &or_, n normalizedArguments.emplace_back(argument.match( [&](auto &x) -> normalizedAST::Literal { - return normalizeNested(x, derivedPredicates); + return normalizeNestedImpl(x, derivedPredicates); })); derivedPredicate->declaration->precondition = std::make_unique>(std::move(normalizedArguments)); @@ -179,28 +175,28 @@ normalizedAST::Literal normalizeNested(ast::OrPointer &or_, n //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::UnsupportedPointer &unsupported, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::Literal normalizeNestedImpl(ast::UnsupportedPointer &unsupported, normalizedAST::DerivedPredicateDeclarations &) { throw NormalizationException("“" + unsupported->type + "” expressions in preconditions can’t be normalized currently"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::Literal normalizeNested(ast::AtomicFormula &atomicFormula, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::Literal normalizeNestedImpl(ast::AtomicFormula &atomicFormula, normalizedAST::DerivedPredicateDeclarations &) { return normalize(std::move(atomicFormula)); } //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::PredicatePointer normalize(ast::UnsupportedPointer &&unsupported, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::PredicatePointer normalizeImpl(ast::UnsupportedPointer &&unsupported, normalizedAST::DerivedPredicateDeclarations &) { throw NormalizationException("“" + unsupported->type + "” expressions in preconditions can’t be normalized currently"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -normalizedAST::AtomicFormula normalize(ast::AtomicFormula &&atomicFormula, normalizedAST::DerivedPredicateDeclarations &) +normalizedAST::AtomicFormula normalizeImpl(ast::AtomicFormula &&atomicFormula, normalizedAST::DerivedPredicateDeclarations &) { return normalize(std::move(atomicFormula)); } @@ -208,7 +204,7 @@ normalizedAST::AtomicFormula normalize(ast::AtomicFormula &&atomicFormula, norma //////////////////////////////////////////////////////////////////////////////////////////////////// // Normalize top-level negations -normalizedAST::NotPointer normalize(ast::NotPointer &¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::NotPointer normalizeImpl(ast::NotPointer &¬_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { // “not” expressions may be nested one time to form simple literals if (not_->argument.is()) @@ -217,7 +213,7 @@ normalizedAST::NotPointer normalize(ast::NotPointe auto normalizedArgument = not_->argument.match( [&](auto &nested) -> normalizedAST::AtomicFormula { - auto normalizedLiteral = normalizeNested(nested, derivedPredicates); + auto normalizedLiteral = normalizeNestedImpl(nested, derivedPredicates); // Multiple negations should be eliminated at this point if (normalizedLiteral.template is>()) @@ -232,7 +228,7 @@ normalizedAST::NotPointer normalize(ast::NotPointe //////////////////////////////////////////////////////////////////////////////////////////////////// // Normalize top-level conjunctions -normalizedAST::AndPointer normalize(ast::AndPointer &&and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +normalizedAST::AndPointer normalizeImpl(ast::AndPointer &&and_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { normalizedAST::And::Arguments arguments; @@ -247,13 +243,13 @@ normalizedAST::AndPointer normalize(ast::AndPointer ¬_) -> normalizedAST::Literal { - return normalize(std::move(not_), derivedPredicates); + return normalizeImpl(std::move(not_), derivedPredicates); }; const auto handleNested = [&](auto &nested) -> normalizedAST::Literal { - return normalizeNested(nested, derivedPredicates); + return normalizeNestedImpl(nested, derivedPredicates); }; const auto handleUnsupported = @@ -274,6 +270,34 @@ normalizedAST::AndPointer normalize(ast::AndPointer &&exists, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +{ + return normalizeNestedImpl(exists, derivedPredicates); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +normalizedAST::Literal normalizeImpl(ast::ForAllPointer &&, normalizedAST::DerivedPredicateDeclarations &) +{ + throw std::logic_error("precondition not in normal form (forall), please report to the bug tracker"); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +normalizedAST::Literal normalizeImpl(ast::ImplyPointer &&, normalizedAST::DerivedPredicateDeclarations &) +{ + throw std::logic_error("precondition not in normal form (imply), please report to the bug tracker"); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +normalizedAST::Literal normalizeImpl(ast::OrPointer &&or_, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) +{ + return normalizeNestedImpl(or_, derivedPredicates); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + normalizedAST::Precondition normalize(ast::Precondition &&precondition, normalizedAST::DerivedPredicateDeclarations &derivedPredicates) { // Bring precondition to normal form @@ -282,7 +306,7 @@ normalizedAST::Precondition normalize(ast::Precondition &&precondition, normaliz return precondition.match( [&](auto &x) -> normalizedAST::Precondition { - return normalize(std::move(x), derivedPredicates); + return normalizeImpl(std::move(x), derivedPredicates); }); }