# Path: stripstream/pddl/logic/formulas.py
# class Formula(object):
# 
#     def is_valid_condition(self):
#         return isinstance(self, Condition) and all(f.is_valid_condition() for f in self.get_formulas())
# 
#     def is_valid_effect(self):
#         return isinstance(self, Effect) and all(f.is_valid_effect() for f in self.get_formulas())
# 
#     def get_atoms(self): raise NotImplementedError()
# 
#     def get_literals(self): raise NotImplementedError()
# 
#     def get_formulas(self): raise NotImplementedError()
# 
#     def de_morgan(self, sign=True): raise NotImplementedError()
# 
#     def simplify(self): return self
# 
#     def get_objects(self):
#         return set(flatten(atom.args for atom in self.get_atoms()))
# 
#     def get_parameters(self):
#         return set(flatten(atom.get_parameters() for atom in self.get_atoms()))
# 
#     def get_quantified(self): raise NotImplementedError()
# 
#     def propositional(self, constants): raise NotImplementedError()
# 
#     def dequantify(self, constants): raise NotImplementedError()
# 
#     def instantiate(self, parameter_map): raise NotImplementedError()
# 
#     def clone(self): return self.instantiate({})
# 
#     def substitute(self, atom, subformula): raise NotImplementedError()
# 
#     def pddl(self): raise NotImplementedError()
#     __repr__ = pddl
#     """
#   Logical formula abstract class.
#   """
# 
# class Condition():
# 
#     def holds(self, atoms, constants): raise NotImplementedError()
# 
#     def positive_supporters(
#         self, atoms, constants): raise NotImplementedError()
# 
#     def negative_supporters(
#         self, atoms, constants): raise NotImplementedError()
#     """
#   Legal condition component interface.
#   """
# 
# class Effect():
# 
#     def add(self, atoms, constants): raise NotImplementedError()
# 
#     def delete(self, atoms, constants): raise NotImplementedError()
#     """
#   Legal effect component interface.
#   """
# 
# Path: stripstream/pddl/logic/predicates.py
# class Head(object):
# class Predicate(Head):
# class EasyPredicate(Predicate):
# class Function(Head):
# class EasyFunction(Function):
#     def __init__(self, name, types=tuple()):
#     def __call__(self, *args):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def pddl(self):
#     def __repr__(self):
#     def __init__(self, *types):
#     def __init__(self, *types):
# def convert_args(self, args):
# 
# Path: stripstream/pddl/objects.py
# class Object(object):
# 
#     def __init__(self, name, type):
#         """
#         PDDL object abstract class.
# 
#         :param name: the string name of the object
#         :param type: the :class:`.Type` of the object
#         """
#         self.name = name.lower()
#         self.type = type
#         self._hash = None
# 
#     def __eq__(self, other):
#         return type(self) == type(other) and self.name == other.name and self.type == other.type
# 
#     def __ne__(self, other):
#         return not(self == other)
# 
#     def __hash__(self):
#         if self._hash is None:
#             self._hash = hash((self.__class__, self.name, self.type))
#         return self._hash
# 
#     def pddl(self):
#         return self.name
# 
#     def typed_pddl(self):
#         return TYPE_PAIR % (self.name, self.type)
#     __repr__ = pddl
# 
# OBJECT = Type('object')
# 
# class Parameter(Object):
# 
#     def __init__(self, name, type):
#         """
#         PDDL parameter which extends :class:`.Object`.
# 
#         :param name: the string name of the parameter
#         :param type: the :class:`.Type` of the parameter
#         """
#         super(Parameter, self).__init__(PARAM_PREFIX + name, type)
# 
#     @property
#     def original(self):
#         return self.name[len(PARAM_PREFIX):]
# 
# class Constant(Object):
#     pass
#     """
#   PDDL constant which extends :class:`.Object`.
#   """


from stripstream.pddl.logic.formulas import Formula, Condition, Effect
from stripstream.pddl.logic.predicates import Function, TotalCost
from stripstream.pddl.objects import Object, OBJECT, Parameter, Constant
import stripstream.pddl.logic.connectives

    def __repr__(self):
        return self.predicate.name + '(' + ','.join(repr(arg) for arg in self.args) + ')'

    def pddl(self):
        return '(' + ' '.join([self.name] + [arg.pddl() for arg in self.args]) + ')'

    def typed_pddl(self):
        return '(' + self.name + ''.join(' ' + arg.typed_pddl() for arg in self.args) + ')'


class Equal(Formula, Condition):
    """
    Equality atom (= O1 O2 ... ON).

    .. code:: python

      BLOCK = EasyType()
      B1, B2 = EasyParameter(BLOCK), EasyParameter(BLOCK)

      f = Equal(B1, B2)
    """

    def __init__(self, arg1, arg2, *args):
        """
        :param arg1: the first :class:`.Object` argument
        :param arg2: the second :class:`.Object` argument
        :param *args: a list of any remaining :class:`.Object` arguments
        """
        self.args = [arg1, arg2] + list(args)

# Path: stripstream/pddl/logic/formulas.py
# class Formula(object):
# 
#     def is_valid_condition(self):
#         return isinstance(self, Condition) and all(f.is_valid_condition() for f in self.get_formulas())
# 
#     def is_valid_effect(self):
#         return isinstance(self, Effect) and all(f.is_valid_effect() for f in self.get_formulas())
# 
#     def get_atoms(self): raise NotImplementedError()
# 
#     def get_literals(self): raise NotImplementedError()
# 
#     def get_formulas(self): raise NotImplementedError()
# 
#     def de_morgan(self, sign=True): raise NotImplementedError()
# 
#     def simplify(self): return self
# 
#     def get_objects(self):
#         return set(flatten(atom.args for atom in self.get_atoms()))
# 
#     def get_parameters(self):
#         return set(flatten(atom.get_parameters() for atom in self.get_atoms()))
# 
#     def get_quantified(self): raise NotImplementedError()
# 
#     def propositional(self, constants): raise NotImplementedError()
# 
#     def dequantify(self, constants): raise NotImplementedError()
# 
#     def instantiate(self, parameter_map): raise NotImplementedError()
# 
#     def clone(self): return self.instantiate({})
# 
#     def substitute(self, atom, subformula): raise NotImplementedError()
# 
#     def pddl(self): raise NotImplementedError()
#     __repr__ = pddl
#     """
#   Logical formula abstract class.
#   """
# 
# class Condition():
# 
#     def holds(self, atoms, constants): raise NotImplementedError()
# 
#     def positive_supporters(
#         self, atoms, constants): raise NotImplementedError()
# 
#     def negative_supporters(
#         self, atoms, constants): raise NotImplementedError()
#     """
#   Legal condition component interface.
#   """
# 
# class Effect():
# 
#     def add(self, atoms, constants): raise NotImplementedError()
# 
#     def delete(self, atoms, constants): raise NotImplementedError()
#     """
#   Legal effect component interface.
#   """
# 
# Path: stripstream/pddl/logic/predicates.py
# class Head(object):
# class Predicate(Head):
# class EasyPredicate(Predicate):
# class Function(Head):
# class EasyFunction(Function):
#     def __init__(self, name, types=tuple()):
#     def __call__(self, *args):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def pddl(self):
#     def __repr__(self):
#     def __init__(self, *types):
#     def __init__(self, *types):
# def convert_args(self, args):
# 
# Path: stripstream/pddl/objects.py
# class Object(object):
# 
#     def __init__(self, name, type):
#         """
#         PDDL object abstract class.
# 
#         :param name: the string name of the object
#         :param type: the :class:`.Type` of the object
#         """
#         self.name = name.lower()
#         self.type = type
#         self._hash = None
# 
#     def __eq__(self, other):
#         return type(self) == type(other) and self.name == other.name and self.type == other.type
# 
#     def __ne__(self, other):
#         return not(self == other)
# 
#     def __hash__(self):
#         if self._hash is None:
#             self._hash = hash((self.__class__, self.name, self.type))
#         return self._hash
# 
#     def pddl(self):
#         return self.name
# 
#     def typed_pddl(self):
#         return TYPE_PAIR % (self.name, self.type)
#     __repr__ = pddl
# 
# OBJECT = Type('object')
# 
# class Parameter(Object):
# 
#     def __init__(self, name, type):
#         """
#         PDDL parameter which extends :class:`.Object`.
# 
#         :param name: the string name of the parameter
#         :param type: the :class:`.Type` of the parameter
#         """
#         super(Parameter, self).__init__(PARAM_PREFIX + name, type)
# 
#     @property
#     def original(self):
#         return self.name[len(PARAM_PREFIX):]
# 
# class Constant(Object):
#     pass
#     """
#   PDDL constant which extends :class:`.Object`.
#   """


# Path: stripstream/pddl/logic/atoms.py
from stripstream.pddl.logic.formulas import Formula, Condition, Effect
from stripstream.pddl.logic.predicates import Function, TotalCost
from stripstream.pddl.objects import Object, OBJECT, Parameter, Constant
import stripstream.pddl.logic.connectives


    def __repr__(self):
        return self.predicate.name + '(' + ','.join(repr(arg) for arg in self.args) + ')'

    def pddl(self):
        return '(' + ' '.join([self.name] + [arg.pddl() for arg in self.args]) + ')'

    def typed_pddl(self):
        return '(' + self.name + ''.join(' ' + arg.typed_pddl() for arg in self.args) + ')'


class Equal(Formula, Condition):
    """
    Equality atom (= O1 O2 ... ON).

    .. code:: python

      BLOCK = EasyType()
      B1, B2 = EasyParameter(BLOCK), EasyParameter(BLOCK)

      f = Equal(B1, B2)
    """

    def __init__(self, arg1, arg2, *args):
        """
        :param arg1: the first :class:`.Object` argument
        :param arg2: the second :class:`.Object` argument
        :param *args: a list of any remaining :class:`.Object` arguments
        """
        self.args = [arg1, arg2] + list(args)

        if not all(isinstance(arg, Object) for arg in self.args):