#
#   Imandra Inc.
#
#   speclogician/modeling/predicates.py
#

from typing import Literal
from enum import StrEnum

from .component import SrcComponent

class PredicateType(StrEnum):
    STATE = "state"
    ACTION = "action"

class StatePredicate(SrcComponent):
    """
    Predicate on the state only
    """
    kind: Literal["state_predicate"] = "state_predicate"

    def __str__ (self):
        """ """
        return f"{self.name} s"

    def to_iml (self):
        """ Return the IML representation of the StatePredicate  """
        return f"let {self.name} (s : state) : bool = \n {self.src_code}\n"

class ActionPredicate(SrcComponent):
    """
    Predicate involving a state and an action
    """
    kind: Literal["action_predicate"] = "action_predicate"

    def __str__(self):
        """
        """
        return f"{self.name} s a"

    def to_iml(self):
        """
        Return the IML representation of the ActionPredicate
        """
        return f"let {self.name} (s : state) (a : action) : bool = \n {self.src_code}\n"

class Transition(SrcComponent):
    """
    Transition functions are used to update the state
    """
    kind: Literal["transition"] = "transition"
    def __str__ (self):
        return f"{self.name} s a"

    def to_iml (self):
        """
        Return the IML representation of the transition
        """
        return f"let {self.name} (s : state) (a : action) : state = \n {self.src_code}"