Let Σ be the set {a,b} of letters. For a word w∈Σ∗ and two languages La,Lb⊆Σ∗ over Σ, we define the language w{a↦La,b↦Lb}⊆Σ∗ as follows, by induction on w.
Here, ϵ represents the empty word. For example, if w=aba, La={bn∣n≥0}, and Lb={an∣n≥0}, then w{a↦La,b↦Lb}={blambn∣l,m,n≥0}. Furthermore, for languages L,La,Lb⊆Σ∗, we define L{a↦La,b↦Lb} as ⋃w∈Lw{a↦La,b↦Lb}. For example, if L={anb∣n≥0}, La={ab}, and Lb={an∣n≥0}, then L{a↦La,b↦Lb}={(ab)man∣m,n≥0}.
Answer the following questions.
(1) Let L={(ab)man∣m,n≥0}, La={bb}, and Lb={ab,a}. Express L{a↦La,b↦Lb} using a regular expression.
(2) Let L′={ambn∣m≥n≥0}, La′={an∣n≥0}, and Lb′={ambm∣m≥0}. Express {w∈Σ∗∣w{a↦La′,b↦Lb′}⊆L′} using a regular expression.
(3) Let A0=(Q0,Σ,δ0,q0,0,F0), A1=(Q1,Σ,δ1,q1,0,F1), and A2=(Q2,Σ,δ2,q2,0,F2) be deterministic finite automata, and for each i∈{0,1,2}, let Li be the language accepted by Ai. Here, Qi,δi,qi,0,Fi are the set of states, the transition function, the initial state, and the set of final states of Ai (i∈{0,1,2}), respectively. Assume that the transition functions δi∈Qi×Σ→Qi (i∈{0,1,2}) are total. Give a non-deterministic finite automaton that accepts L0{a↦L1,b↦L2}, with a brief explanation. You may use ϵ-transitions.
(4) For Ai and Li (i∈{0,1,2}) in question (3), give a deterministic finite automaton that accepts {w∈Σ∗∣w{a↦L1,b↦L2}⊆L0}, with a brief explanation.
We will construct an NFA that accepts L0{a↦L1,b↦L2} using ϵ-transitions. The NFA will have the same structure as A0, but the transitions will be replaced based on the input letter with the transitions from A1 and A2, and ϵ-transitions will be used to connect the states.
For example, supposing the original transitions for the input letter a in A0 are q0,0aq0,1, we will replace these transitions with the corresponding transitions from A1:
q0,0ϵq1,0…F1,iϵq0,1
Similarly, for the input letter b, we will replace the transitions with the corresponding transitions from A2.
The final states of the NFA will be those states where the original final states of A0 are reached after the substitution process.
Explanation: Since the language L0{a↦L1,b↦L2} is obtained by substituting the strings in L1 and L2 for a and b in the strings of L0, the NFA needs to simulate this substitution process by transitioning to the corresponding states in A1 and A2 based on the input letter.
We need to track the states of Ai, Aj, and Ak simultaneously.
The DFA will have states (qi,qj,qk), where qi∈Qi, qj∈Qj, and qk∈Qk.
The initial state is (qi0,qj0,qk0).
The transition function will be defined as:
(qi,qj,qk)a(δi(qi,a),qj,δk(qk,wLi)) for all wLi∈Li.
(qi,qj,qk)b(qi,δj(qj,b),δk(qk,wLj)) for all wLj∈Lj.
The final states are those where the third component is a final state in Fk.
This DFA ensures that as we read w, we keep track of the corresponding states in Ai, Aj, and Ak to ensure the substitution process results in strings that belong to Lk.