Side effects on input! Returns the DFA in input trimmed,
    so both reachable and co-reachable.

    Given a DFA A, the corresponding trimmed DFA contains only
    those states that are reachable from the initial state
    and that lead to a final state.
    The trimmed dfa :math:`A_{RF}` corresponding to A is defined as

    :math:`A_{RF} = (Σ, S_R ∩ S_F , s_0 , ρ|S_R∩S_F , F ∩ S_R )`

    where

    • :math:`S_R` set of reachable states from the initial state
    • :math:`S_F` set of states that reaches a final state
    • :math:`ρ|S_R∩S_F` is the restriction on :math:`(S_R ∩ S_F )
      × Σ` of ρ.

    :param dict dfa: input DFA.
    :return: *(dict)* representing the trimmed input DFA.

def dfa_trimming(dfa: dict) -> dict:
    """ Side effects on input! Returns the DFA in input trimmed,
    so both reachable and co-reachable.

    Given a DFA A, the corresponding trimmed DFA contains only
    those states that are reachable from the initial state
    and that lead to a final state.
    The trimmed dfa :math:`A_{RF}` corresponding to A is defined as

    :math:`A_{RF} = (Σ, S_R ∩ S_F , s_0 , ρ|S_R∩S_F , F ∩ S_R )`

    where

    • :math:`S_R` set of reachable states from the initial state
    • :math:`S_F` set of states that reaches a final state
    • :math:`ρ|S_R∩S_F` is the restriction on :math:`(S_R ∩ S_F )
      × Σ` of ρ.

    :param dict dfa: input DFA.
    :return: *(dict)* representing the trimmed input DFA.
    """
    # Reachable DFA
    dfa = dfa_reachable(dfa)
    # Co-reachable DFA
    dfa = dfa_co_reachable(dfa)
    # trimmed DFA
    return dfa