Let ⊗ be an operation recursively defined on strings of the
same length such that
ϵ⊗ϵxa⊗yb=ϵ=(x⊗y)abso that the action of ⊗ on two strings "interleaves" the two strings.
For example, ab⊗12=a1b2.
Similarly, for languages A,B⊆Σ∗, let
A⊗B={x⊗y:x∈A,y∈B,∣x∣=∣y∣}be the set of all string obtained from interleaving a string in A with a string in B.
Note that ⊗ is bijective, so each string in A⊗B is uniquely
defined by its operands.
Proposition: If A and B are regular, then A⊗B is regular.
Proof. As A and B are regular, let MA=(QA,Σ,δA,sA,FA)
and MB=(Qb,Σ,δB,sB,FB) be DFAs such that
L(MA)=A and L(MB)=B. Define the DFA
N=(QA×QB×{L,R},Σ,δN,(sA,sB,L),FA×FB×{L})where δN is defined as follows:
δN((qA,qB,L),a)δN((qA,qB,R),a)=(δA(qA,a),qB,R)=(qA,δA(qB,a),L)We want to show that L(N)=A⊗B. First, we prove the lemma
δN^((sA,sB,L),x⊗y)=(δA^(sA,x),δB^(sB,y),L)for all x,y∈Σ∗ such that
∣x∣=∣y∣ by induction.
Basis. We have
δN^((qA,qB,L),ϵ)=(qA,qB,L)=(δA^(qA,ϵ),δB^(qB,ϵ),L),so the induction hypothesis holds for ϵ.
Induction step. Suppose the induction hypothesis (I.H.) holds for some
x,y∈Σ∗ with ∣x∣=∣y∣. For a,b∈Σ, we have
δN^((qA,qB,L),xa⊗yb)=δN^((qA,qB,L),(x⊗y)ab)=δN^(δN^((qA,qB,L),x⊗y),ab)=δN^((δA^(sA,x),δB^(sB,y),L),ab)=δN(δN((δA^(sA,x),δB^(sB,y),L),a),b)=δN((δA(δA^(sA,x),a),δB^(sB,y),R),b)=δN((δA^(sA,xa),δB^(sB,y),R),b)=(δA^(sA,xa),δB(δB^(sB,y),b),L)=(δA^(sA,xa),δB^(sB,yb),L)(def of ⊗)(def of δN^)(I.H.)(def of δN^)(def of δN)(def of δN^)(def of δN)(def of δN^),so the I.H. for x and y implies the I.H. for xa and yb.
From the lemma, we have
x⊗y∈A⊗B⟺x⊗y∈L(MA)⊗L(MB)⟺x∈A and y∈B⟺δA^(sA,x)∈FA and δB^(sB,y)∈FB⟺(δA^(sA,x),δB^(sB,y),L)∈FA×FB×{L}⟺δN^((sA,sB,L),x⊗y)∈FA×FB×{L}⟺x⊗y∈L(N)Hence, A⊗B=L(N), so A⊗B is regular.