o
    oh	                     @   s    G d d dZ G dd dZdS )c                   @   s"   e Zd ZdZdddZdd ZdS )Statea-  
    A representation of a state managed by a ``StateMachine``.

    Attributes:
        name (instance of FreeGroupElement or string) -- State name which is also assigned to the Machine.
        transisitons (OrderedDict) -- Represents all the transitions of the state object.
        state_type (string) -- Denotes the type (accept/start/dead) of the state.
        rh_rule (instance of FreeGroupElement) -- right hand rule for dead state.
        state_machine (instance of StateMachine object) -- The finite state machine that the state belongs to.
    Nc                 C   s&   || _ i | _|| _|d | _|| _d S )N    )nametransitionsstate_machine
state_typerh_rule)selfr   r   r   r    r	   {/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/combinatorics/rewritingsystem_fsm.py__init__   s
   

zState.__init__c                 C   s   || j |< dS )aZ  
        Add a transition from the current state to a new state.

        Keyword Arguments:
            letter -- The alphabet element the current state reads to make the state transition.
            state -- This will be an instance of the State object which represents a new state after in the transition after the alphabet is read.

        N)r   )r   letterstater	   r	   r
   add_transition   s   	zState.add_transitionNN)__name__
__module____qualname____doc__r   r   r	   r	   r	   r
   r      s    
r   c                   @   s*   e Zd ZdZdd Zd	ddZdd ZdS )
StateMachinez
    Representation of a finite state machine the manages the states and the transitions of the automaton.

    Attributes:
        states (dictionary) -- Collection of all registered `State` objects.
        name (str) -- Name of the state machine.
    c                 C   s$   || _ || _i | _| jddd d S )Nstarts)r   )r   automaton_alphabetstates	add_state)r   r   r   r	   r	   r
   r   (   s   zStateMachine.__init__Nc                 C   s   t || ||}|| j|< dS )ax  
        Instantiate a state object and stores it in the 'states' dictionary.

        Arguments:
            state_name (instance of FreeGroupElement or string) -- name of the new states.
            state_type (string) -- Denotes the type (accept/start/dead) of the state added.
            rh_rule (instance of FreeGroupElement) -- right hand rule for dead state.

        N)r   r   )r   
state_namer   r   	new_stater	   r	   r
   r   .   s   
zStateMachine.add_statec                 C   s
   d| j  S )Nz%s)r   )r   r	   r	   r
   __repr__;   s   
zStateMachine.__repr__r   )r   r   r   r   r   r   r   r	   r	   r	   r
   r      s
    
r   N)r   r   r	   r	   r	   r
   <module>   s    