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.
If an a occurs after a b, choose nonempty substitutions for both; the result contains a b before an a and is not in L′. Two occurrences of b fail in the same way. Thus there is at most one b, and it must be last. Conversely, every substitution of ar or arb has the form aMbN with M≥N. Hence the required expression is
We construct an NFA accepting
L0{a↦L1,b↦L2} by replacing each transition of A0 with an automaton for the language substituted for its label.
For every a-transition qaδ0(q,a) of A0, take a private copy of A1, add an ϵ-transition from q to its initial state, and add an ϵ-transition from every accepting state of that copy to δ0(q,a). Symbolically,
qϵq1,0L1F1ϵδ0(q,a).
Do the same for every b-transition, using a private copy of A2:
qϵq2,0L2F2ϵδ0(q,b).
The initial state is q0,0 and the accepting states are F0. A path through a copy reads one word of L1 or L2, so simulating a word of L0 reads precisely one of its substitutions. Hence the NFA accepts exactly
L0{a↦L1,b↦L2}.
Each relation is computable by a product automaton A0×A1 or
A0×A2.
Use the DFA with state set 2Q0, initial state {q0,0}, and transition
Sc{q∣∃p∈S:(p,q)∈Rc}(c∈{a,b}).
Its accepting states are the subsets S⊆F0. After reading w, the current subset is exactly the set of states reachable in A0 by all words in
w{a↦L1,b↦L2}; hence the acceptance condition is precisely the required inclusion in L0.