The bit-parallel simulation accepts exactly the language of the expression full
This proof shows: correctness, termination.
Let G be the Glushkov automaton of r, with states 0,…,k, moves (p,sym(q),q) for q∈Follow(p), and accepting set F. By the correctness of the Glushkov automaton, G accepts exactly L(r). Identify a set D⊆{0,…,k} with the integer ∑p∈D2p, so that ∣ is union, & is intersection, and bit p of the integer is set if and only if p∈D. For a set D write Φ(D)=⋃p∈DFollow(p), and for a symbol c write δ(D,c)={q:(p,c,q) is a move of G for some p∈D}.
Lemma 1 (homogeneity). δ(D,c)=Φ(D)∩B[c], where B[c]={q≥1:sym(q)=c} is the set built at line L2.
Proof. A move (p,c,q) exists if and only if q∈Follow(p) and sym(q)=c. The positions in a Follow set are at least 1, and sym(q)=c for q≥1 means q∈B[c]. So q∈δ(D,c) if and only if q∈Φ(D) and q∈B[c]. □
Lemma 2 (tables). After line L5, for each chunk j and each v with 0≤v<2b, Tj[v]=Φ({jb+i:bit i of v is set}), with Follow(p)=∅ for p>k.
Proof. By induction on v. For v=0, Tj[0]=0=Φ(∅). For v>0, let i be the index of the lowest set bit of v and v′=v−2i<v. Line L5 sets Tj[v]=Tj[v′]∣Follow(jb+i), where Follow(p)=∅ for p>k. By induction Tj[v′]=Φ(S′) for the set S′ of v′, and the set of v is S′∪{jb+i}, so Tj[v]=Φ(S′)∪Follow(jb+i)=Φ(S′∪{jb+i}). □
Lemma 3 (one step). For every D⊆{0,…,k} and symbol c, lines L8 and L9 compute δ(D,c).
Proof. For j=0,…,g−1, the value (D≫jb)&(2b−1) is the integer vj whose bit i is set if and only if jb+i∈D, so by Lemma 2, Tj[vj]=Φ(Dj) with Dj=D∩{jb,…,jb+b−1}. Since gb≥k+1, the sets D0,…,Dg−1 cover D, and Φ distributes over union, so E=Φ(D0)∪⋯∪Φ(Dg−1)=Φ(D) at line L8. Line L9 gives E∩B[c]=δ(D,c) by Lemma 1. □
Invariant. After line L9 in round i, D=δ∗({0},y1⋯yi), the set of states of G that some run on y1⋯yi from state 0 reaches.
Proof. Before the loop, D={0}=δ∗({0},ε) by line L6. If D=δ∗({0},y1⋯yi−1) before round i, Lemma 3 gives δ(D,yi)=δ∗({0},y1⋯yi) after line L9. □
Termination. Line L5 runs g(2b−1) rounds, the loop at line L7 at most n rounds, and each round does g lookups. So the algorithm stops.
Theorem. BITPARALLEL(r,y,b) returns true if and only if y∈L(r).
Proof. If line L10 returns false in round i, then δ∗({0},y1⋯yi)=∅ by the invariant; then δ∗({0},y)=δ∗(∅,yi+1⋯yn)=∅ contains no accepting state, and y∈/L(G)=L(r). Otherwise the loop ends with D=δ∗({0},y), and line L11 returns true if and only if this set meets F, that is, if and only if G accepts y, that is, if and only if y∈L(r). ■
The search variant. With D←δ(D,yi)∪{0} in round i, and D={0} at the start, the same induction shows that after round i, D=⋃s=0iδ∗({0},ys+1⋯yi): the runs that started before round i are advanced by Lemma 3, and the added state 0 is the run of the empty suffix, with s=i. So D meets F after round i if and only if some ys+1⋯yi with 0≤s≤i is in L(r).