Proof (positive solution for equivalence problem for regular grammars)

Let $G, G'$ be two regular grammars. Construct, as in the proofs here and here, deterministic automata $D, D'$ such that $\mathcal{L}(G) = \mathcal{L}(D)$ and $\mathcal{L}(G') = \mathcal{L}(D')$.

We will show that our construction for minimal automata can be done algorithmically.

Determining inaccessible states

Let $D = (Σ, Q, δ, q_0, F)$ and $n = |Q|$. A state $q$ is accessible iff there is a word $w\in \mathbb{W}$ of length $\leq n$ such that $\hat δ(q_0, w) = q$ (by the same argument as here).

Check all (finitely many) words of length $\leq n$ whether $\hat δ(q_0, w) = q$.

Determining indistinguishable states

Perform the table filling algorithm: write $Q\times Q$ as a table.

  1. For each pair $(q, q')\in Q\times Q$,

    • if $q\in F$ and $q'\not\in F$ or vice versa, then

      • mark $ε$ into the $(q,q')$-entry of the table (meaning that $ε$ distinguishes $q$ and $q'$).

  2. For each pair $(p,p') \in Q\times Q$ not yet marked in the table,

    • for each $a \in Σ$,

      • let $q = δ(p,a), q' = δ(p',a)$.

      • If $(q,q')$ is already marked in the table, by say $w$, then

        • mark $aw$ into $(p,p')$.

  3. If some pair was marked in step 2, then repeat step 2. Otherwise terminate.

Only finitely many table entries can be filled, so this algorithm terminates in at most $|Q|^2$ steps.

Two states $q, q'\in Q$ are indistinguishable iff $(q,q')$ is unmarked at the end of the algorithm

If $(q,q')$ is marked by say $w$, then by induction $w$, $(\hat δ(q,w), \hat δ(q',w))$ was marked by $ε$ in step 1, so $w$ distinguishes $q$ and $q'$.

Conversely, suppose there exist pairs that can be distinguished but is not marked at the end of the algorithm. Call these bad pairs. Each pair has a distinguishing word. Let $(p,p')$ be a bad pair with a distinguishing word $w$ of minimal length.

Since all pairs distinguished by $ε$ are marked in step 1, we must have $|w|>0$. Let $w = av$ with $a$ being the first letter. Note $q := δ(p, a)$, $q' := δ(p', a)$ are distinguished by $v$, which has a shorter length than $w$, so $(q,q')$ cannot be a bad pair. This means $(q,q')$ is marked. But then in the step after $(q,q')$ was marked, $(p,p')$ would have been marked, which is a contradiction.

Determining whether the minimal automata are isomoprhic

Now that we can find the minimal automata $I$ of $D$ and $I'$ of $D'$, we use the fact that $\mathcal{L}(I) = \mathcal{L}(D) = \mathcal{L}(D') = \mathcal{L}(I')$ iff $I$ and $I'$ are isomorphic.

If $I$ and $I'$ have different number of states, then they are not isomorphic. Otherwise they have the same number $n$ of states and there are at most $n^n$ functions that need to be checked to see if they are an isomorphism.