Number of 'a' is twice the number of 'b's.
Exact Grammar:
S = (a|b)* where N_a(S)=2*N_b(S)
N_a(X) means Number of 'a's in X. etc.
At any point in time, the stack can either be all 'a's or all 'b's. Why? because, there are no transitions of a/xxbxx or b/xxaxx.
Case 1: Stack is all 'a's.
You can see cycle will be of the form:
a(a*b)+ , if last we take the transition L,a/L in (2->1)
a(a*b)+a, if last we take the transition a,Z0/Z0 in (2->1). and the last 'a' will not pop anything from stack.
in each cycle, the number of 'a's popped are two. and number of cycle is same as number of 'b' (except when a,Z0/Z0 occured at the last)
we'll take the last transition L,a/L iff number of 'a' is even before last 'b'
we'll take the last transition a,Z0/Z0 iff number of 'a' is odd before last 'b'. a,Z0/Z0 accepts one more 'a'
Thus,
A1=a(a*b)+a where N_a(A1)=2*N_b(A1), N_a(A1) is even
A2=a(a*b)+ where N_a(A2)=2*N_b(A2), N_a(A2) is even
This will reduce to:
A=a(a|b)+ where N_a(A)=2*N_b(A), N_a(A) is even
(we'll be state 1, and stack empty)
Case 2: Stack is all 'b's.
Similarly, you can see that each cycle will be of the form: b*ab*a.
and in each cycle, exactly one 'b' will be popped off.
Whenever a 'b' is accepted, a 'b' is pushed onto the stack.
Thus when the stack is empty, and we're back to state 1, number of times the cycle is taken is equal to number of 'b's we accepted/pushed onto stack.Thus,
B=b(b*ab*a)^n where N_b(B)=n
But you can see, n = N_a(B)/2. Thus,
B=b(b*ab*a)+ where N_a(B)=2*N_b(B)
This will reduce to:
B=b(b|a)+ where N_a(B)=2*N_b(B)
And since there are only two possible paths (A or B), and the cycle can be taken 0 or 1 times,
Thus,
S=(A|B)*
A=a(a|b)+ where N_a(A)=2*N_b(A)
B=b(b|a)+ where N_a(B)=2*N_b(B)
This will reduce to:
S=((a|b)+)* where N_a(S)=2*N_b(S)
which will reduce to:
S=(a|b)* where N_a(S)=2*N_b(S)
Q.E.D.