deepseek/deepseek-chat-v3.1

Exercise 2: Reversed DFA


Subproblem a (6.0/10.0P)

Let Σ≠∅\Sigma\ne\emptyset and M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) be a DFA such that the automaton M′=(Q,Σ,δ′,q0,F)M'=(Q,\Sigma,\delta',q_0,F), which is obtained by reversing all transitions in MM, is also a DFA. Formally, we have δ′(r,c)=q\delta'(r,c)=q for all δ(q,c)=r\delta(q,c)=r. Prove or disprove: L(M)L(M) is infinite or empty.
☒True☐False
The statement is true. The condition that M′M' is a DFA implies that for every state r∈Qr \in Q and every symbol c∈Σc \in \Sigma, there is exactly one q∈Qq \in Q such that δ(q,c)=r\delta(q, c) = r. This means that for each c∈Σc \in \Sigma, the function δc:Q→Q\delta_c : Q \to Q defined by δc(q)=δ(q,c)\delta_c(q) = \delta(q, c) is a bijection, i.e., a permutation of QQ. Consequently, the transformation monoid of MM is a group of permutations on QQ.

Now, consider L(M)L(M). If F=∅F = \emptyset, then L(M)=∅L(M) = \emptyset. If F≠∅F \neq \emptyset, then if no final state is reachable from q0q_0, L(M)=∅L(M) = \emptyset. If some final state f∈Ff \in F is reachable, say δ(q0,w)=f\delta(q_0, w) = f for some w∈Σ∗w \in \Sigma^*, then since the transformation monoid is a finite group and Σ∗\Sigma^* is infinite, there are infinitely many words that map q0q_0 to ff under the transformation, so L(M)L(M) is infinite. Thus, in all cases, L(M)L(M) is either empty or infinite.

google/gemini-2.5-pro

Exercise 2: Reversed DFA


Subproblem a (10.0/10.0P)

Let Σ≠∅\Sigma\ne\emptyset and M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) be a DFA such that the automaton M′=(Q,Σ,δ′,q0,F)M'=(Q,\Sigma,\delta',q_0,F), which is obtained by reversing all transitions in MM, is also a DFA. Formally, we have δ′(r,c)=q\delta'(r,c)=q for all δ(q,c)=r\delta(q,c)=r. Prove or disprove: L(M)L(M) is infinite or empty.
☒True☐False
The statement is True.

Here is a proof.

Let M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) be a DFA. The automaton M′=(Q,Σ,δ′,q0,F)M'=(Q,\Sigma,\delta',q_0,F) is obtained by reversing all transitions, i.e., δ′(r,c)=q\delta'(r,c)=q if and only if δ(q,c)=r\delta(q,c)=r. We are given that M′M' is also a DFA. We will show that this condition implies that either L(M)L(M) is empty or L(M)L(M) is infinite.

1. Analyzing the condition on M′M'

For M′M' to be a DFA, its transition function δ′:Q×Σ→Q\delta': Q \times \Sigma \to Q must be well-defined. This means that for every state r∈Qr \in Q and every symbol c∈Σc \in \Sigma, there must exist exactly one state q∈Qq \in Q such that δ′(r,c)=q\delta'(r,c) = q.

Using the definition of δ′\delta', this condition translates to the properties of the original transition function δ\delta:
For every state r∈Qr \in Q and symbol c∈Σc \in \Sigma, there is exactly one state q∈Qq \in Q such that δ(q,c)=r\delta(q,c) = r.

This property means that for any fixed symbol c∈Σc \in \Sigma, the function δc:Q→Q\delta_c: Q \to Q defined by δc(q)=δ(q,c)\delta_c(q) = \delta(q,c) is a permutation of the finite set of states QQ. A function on a finite set is a permutation if and only if it is a bijection (both injective and surjective). The condition directly states that δc\delta_c is surjective for every cc (every state rr is an image), and since QQ is finite, this also implies it is injective.

2. Consequences for longer strings

Let w=c1c2…ckw = c_1c_2\dots c_k be any non-empty string in Σ+\Sigma^+. The extended transition function for ww, denoted δ^w(q)=δ^(q,w)\hat{\delta}_w(q) = \hat{\delta}(q,w), is the composition of the functions for each symbol: δ^w=δck∘δck−1∘⋯∘δc1\hat{\delta}_w = \delta_{c_k} \circ \delta_{c_{k-1}} \circ \dots \circ \delta_{c_1}.

Since each δci\delta_{c_i} is a permutation, and the composition of permutations is a permutation, the function δ^w\hat{\delta}_w is also a permutation of QQ for any non-empty string ww.

3. Every state is part of a cycle

A key property of any permutation π\pi on a finite set SS is that for any element s∈Ss \in S, repeated application of π\pi eventually returns to ss. That is, there exists an integer k≥1k \ge 1 such that πk(s)=s\pi^k(s) = s. This is a direct consequence of the finiteness of the orbit of ss.

Applying this to our DFA, let qq be any state in QQ. Since we are given Σ≠∅\Sigma \ne \emptyset, we can pick any symbol c∈Σc \in \Sigma. From step 1, δc\delta_c is a permutation. Thus, there exists an integer k≥1k \ge 1 such that (δc)k(q)=q(\delta_c)^k(q) = q. This is equivalent to δ^(q,ck)=q\hat{\delta}(q, c^k) = q. Since ckc^k is a non-empty string, this shows that every state q∈Qq \in Q is part of a cycle.

4. Proving "L(M)L(M) is infinite or empty"

This statement is equivalent to proving: If L(M)L(M) is non-empty, then L(M)L(M) is infinite.

Assume L(M)L(M) is non-empty. A language accepted by a DFA is infinite if and only if there exists a state that is reachable from the start state, can reach a final state, and is part of a cycle.

Let's check these conditions for the start state q0q_0:
1.  Reachability: q0q_0 is reachable from itself (by processing the empty string ϵ\epsilon).
2.  Ability to reach a final state: We assumed L(M)L(M) is non-empty. By definition, this means there is at least one string w∈L(M)w \in L(M). For this string, we have δ^(q0,w)∈F\hat{\delta}(q_0, w) \in F. This shows there is a path from q0q_0 to a final state.
3.  Part of a cycle: From step 3, we proved that every state is part of a cycle, so q0q_0 must be part of a cycle. Let v≠ϵv \ne \epsilon be a string such that δ^(q0,v)=q0\hat{\delta}(q_0, v) = q_0.

Since q0q_0 satisfies all three conditions, the language L(M)L(M) must be infinite. Specifically, if w∈L(M)w \in L(M) and δ^(q0,v)=q0\hat{\delta}(q_0, v)=q_0, then all strings of the form viwv^i w for i≥0i \ge 0 are in L(M)L(M). Because vv is non-empty, this constitutes an infinite set of strings.

Conclusion

We have shown that if L(M)L(M) is non-empty, it must be infinite. Therefore, L(M)L(M) is either empty or infinite.

openai/gpt-5

Exercise 2: Reversed DFA


Subproblem a (10.0/10.0P)

Let Σ≠∅\Sigma\ne\emptyset and M=(Q,Σ,δ,q0,F)M=(Q,\Sigma,\delta,q_0,F) be a DFA such that the automaton M′=(Q,Σ,δ′,q0,F)M'=(Q,\Sigma,\delta',q_0,F), which is obtained by reversing all transitions in MM, is also a DFA. Formally, we have δ′(r,c)=q\delta'(r,c)=q for all δ(q,c)=r\delta(q,c)=r. Prove or disprove: L(M)L(M) is infinite or empty.
☒True☐False
Because M′ is a DFA, δ′ must be total and single-valued. Hence for each c∈Σ, the map δ_c:Q→Q given by δ_c(q)=δ(q,c) is bijective (its inverse is δ′(·,c)). Thus M is a permutation (group) automaton: every letter acts as a permutation of Q.

Let G be the finite group generated by {δ_c : c∈Σ}, and let O be the orbit of q₀ under G: O={g(q₀) : g∈G}. Then
L(M) = { w∈Σ* : δ_w(q₀) ∈ F }.

If O∩F=∅, then L(M)=∅.

Otherwise pick s∈O∩F and u∈Σ* with δ_u(q₀)=s. Since Σ≠∅, choose any a∈Σ. The permutation δ_a has finite order m≥1, so δ_{a^m}=id. Hence for all k≥0,
δ_{u a^{mk}}(q₀)=δ_u(q₀)=s∈F,
so u a^{mk} ∈ L(M). These are infinitely many distinct words, so L(M) is infinite.

Therefore L(M) is either empty or infinite.