diff --git a/pddl/_validation.py b/pddl/_validation.py index 4f281bc..d5f76fd 100644 --- a/pddl/_validation.py +++ b/pddl/_validation.py @@ -22,13 +22,7 @@ from pddl.exceptions import PDDLValidationError from pddl.helpers.base import check, ensure, ensure_set, find_cycle from pddl.logic import Predicate -from pddl.logic.base import ( - BinaryOp, - FalseFormula, - QuantifiedCondition, - TrueFormula, - UnaryOp, -) +from pddl.logic.base import BinaryOp, QuantifiedCondition, UnaryOp from pddl.logic.effects import AndEffect, Forall, When from pddl.logic.predicates import DerivedPredicate, EqualTo from pddl.logic.terms import Term @@ -261,14 +255,6 @@ def _(self, formula: BinaryOp) -> None: """Check types annotations of a PDDL binary operator.""" self.check_type(formula.operands) - @check_type.register - def _(self, formula: TrueFormula) -> None: - """Check types annotations of a PDDL true formula.""" - - @check_type.register - def _(self, formula: FalseFormula) -> None: - """Check types annotations of a PDDL false formula.""" - @check_type.register def _(self, formula: QuantifiedCondition) -> None: """Check types annotations of a PDDL quantified condition.""" diff --git a/pddl/core.py b/pddl/core.py index 196d72b..063c518 100644 --- a/pddl/core.py +++ b/pddl/core.py @@ -27,7 +27,7 @@ from pddl.custom_types import name as name_type from pddl.custom_types import namelike, parse_name, to_names, to_types # noqa: F401 from pddl.helpers.base import assert_, check, ensure, ensure_set -from pddl.logic.base import Formula, TrueFormula, is_literal +from pddl.logic.base import And, Formula, is_literal from pddl.logic.predicates import DerivedPredicate, Predicate from pddl.logic.terms import Constant from pddl.requirements import Requirements @@ -172,7 +172,7 @@ def __init__( ] = self._parse_requirements(domain, requirements) self._objects: AbstractSet[Constant] = ensure_set(objects) self._init: AbstractSet[Formula] = ensure_set(init) - self._goal: Formula = ensure(goal, TrueFormula()) + self._goal: Formula = ensure(goal, And()) validate( all(map(is_literal, self.init)), "Not all formulas of initial condition are literals!", diff --git a/pddl/formatter.py b/pddl/formatter.py index 8b5a845..acf4790 100644 --- a/pddl/formatter.py +++ b/pddl/formatter.py @@ -16,7 +16,6 @@ from pddl.core import Domain, Problem from pddl.custom_types import name -from pddl.logic.base import TRUE from pddl.logic.terms import Constant @@ -153,11 +152,7 @@ def problem_to_string(problem: Problem) -> str: body += _sort_and_print_collection( "(:init ", problem.init, ")\n", is_mandatory=True ) - body += ( - f"{'(:goal ' + str(problem.goal) + ')'}\n" - if problem.goal != TRUE - else "(:goal (and))\n" - ) + body += f"{'(:goal ' + str(problem.goal) + ')'}\n" result = result + "\n" + indent(body, indentation) + "\n)" result = _remove_empty_lines(result) return result diff --git a/pddl/parser/domain.py b/pddl/parser/domain.py index 2e7ebd1..f0cf83b 100644 --- a/pddl/parser/domain.py +++ b/pddl/parser/domain.py @@ -21,16 +21,7 @@ from pddl.custom_types import name from pddl.exceptions import PDDLMissingRequirementError, PDDLParsingError from pddl.helpers.base import assert_ -from pddl.logic.base import ( - And, - ExistsCondition, - FalseFormula, - ForallCondition, - Imply, - Not, - OneOf, - Or, -) +from pddl.logic.base import And, ExistsCondition, ForallCondition, Imply, Not, OneOf, Or from pddl.logic.effects import AndEffect, Forall, When from pddl.logic.predicates import DerivedPredicate, EqualTo, Predicate from pddl.logic.terms import Constant, Variable @@ -138,7 +129,7 @@ def action_parameters(self, args): def emptyor_pregd(self, args): """Process the 'emptyor_pregd' rule.""" if len(args) == 2: - return FalseFormula() + return Or() else: assert_(len(args) == 1) return args[0] @@ -217,7 +208,7 @@ def gd(self, args): def emptyor_effect(self, args): """Process the 'emptyor_effect' rule.""" if len(args) == 2: - return FalseFormula() + return Or() else: return args[0] diff --git a/tests/test_domain.py b/tests/test_domain.py index 08561d8..affbb61 100644 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -21,7 +21,7 @@ from pddl.core import Domain from pddl.exceptions import PDDLValidationError from pddl.logic import Constant, Variable -from pddl.logic.base import Not, TrueFormula +from pddl.logic.base import And, Not from pddl.logic.helpers import constants, variables from pddl.logic.predicates import DerivedPredicate, Predicate from pddl.parser.symbols import Symbols @@ -157,7 +157,7 @@ def test_derived_predicate_type_not_available() -> None: """Test that when a type of a term of a derived predicate is not declared we raise error.""" x = Variable("a", type_tags={"t1", "t2"}) p = Predicate("p", x) - dp = DerivedPredicate(p, TrueFormula()) + dp = DerivedPredicate(p, And()) my_type = "my_type" type_set = {my_type: None} diff --git a/tests/test_formatter.py b/tests/test_formatter.py index 63bc66e..52c40b3 100644 --- a/tests/test_formatter.py +++ b/tests/test_formatter.py @@ -96,6 +96,6 @@ def test_typed_objects_formatting_in_problem() -> None: (:requirements :typing) (:objects a b c - type_1 d e f - type_2 g h i - type_3 j k l) (:init ) - (:goal (and)) + (:goal (and )) )""" ) diff --git a/tests/test_problem.py b/tests/test_problem.py index 2428506..b858bde 100644 --- a/tests/test_problem.py +++ b/tests/test_problem.py @@ -17,7 +17,7 @@ import pytest from pddl.core import Domain, Problem -from pddl.logic.base import Not, TrueFormula +from pddl.logic.base import And, Not from pddl.logic.helpers import constants, variables from pddl.logic.predicates import Predicate from tests.conftest import pddl_objects_problems @@ -64,7 +64,7 @@ def test_init(self): def test_goal(self): """Test the goal getter.""" - assert self.problem.goal == TrueFormula() + assert self.problem.goal == And() def test_build_simple_problem():