Proof of bijection between Pi-Shapes of size 2n+2 and Motzkin of size n

Starting from the grammar for the pi-shapes:

  S -> [T]S | epsilon
  T -> [T][T]S | epsilon

The system translate into a system of equations on the generating functions, thanks to the DSV method:

>    Sys1:={S=z^2*S*T+1,T=z^4*S*T^2+1};

Sys1 := {S = z^2*S*T+1, T = z^4*S*T^2+1}

>    Sol1:=allvalues(solve(Sys1,{S,T}));

Sol1 := {T = 1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/z^2/(1+z^2), S = (1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/z^2/(1+z^2)+1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/(1+z^2)-1-z^2)/z^2/(-1+1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))...
Sol1 := {T = 1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/z^2/(1+z^2), S = (1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/z^2/(1+z^2)+1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))/(1+z^2)-1-z^2)/z^2/(-1+1/2*(1+z^2+(1-2*z^2-3*z^4)^(1/2))...

Now we choose the solution for S(z) having positive coefficients, thus:

>    Res1 := simplify(rhs(Sol1[2][2]));

Res1 := 1/z^2*(2*z^4+z^2-1+(1-2*z^2-3*z^4)^(1/2))/(z^2-1+(1-2*z^2-3*z^4)^(1/2))

>    series(simplify(Res1),z,35);

series(1+1*z^2+1*z^4+2*z^6+4*z^8+9*z^10+21*z^12+51*z^14+127*z^16+323*z^18+835*z^20+2188*z^22+5798*z^24+15511*z^26+41835*z^28+O(z^30),z,30)

Starting from the grammar for the pi-shapes:

  M -> [M]M | .M | epsilon
The system translate into a system of equations, that we solve:

>    Sys2:={M=z^2*M^2+z*M+1};

Sys2 := {M = z^2*M^2+z*M+1}

>    Sol2:=solve(Sys2,{M});

Sol2 := {M = -1/2*(z-1-(-3*z^2-2*z+1)^(1/2))/z^2}, {M = -1/2*(z-1+(-3*z^2-2*z+1)^(1/2))/z^2}

Once again, we pick the solution whose coefficients are positive in a taylor expansion around z=0

>    Res2 := rhs(Sol2[2][1]);

Res2 := -1/2*(z-1+(-3*z^2-2*z+1)^(1/2))/z^2

>    series(simplify(Res2),z,35);

series(1+1*z+2*z^2+4*z^3+9*z^4+21*z^5+51*z^6+127*z^7+323*z^8+835*z^9+2188*z^10+5798*z^11+15511*z^12+41835*z^13+113634*z^14+310572*z^15+853467*z^16+2356779*z^17+6536382*z^18+18199284*z^19+50852019*z^20+...
series(1+1*z+2*z^2+4*z^3+9*z^4+21*z^5+51*z^6+127*z^7+323*z^8+835*z^9+2188*z^10+5798*z^11+15511*z^12+41835*z^13+113634*z^14+310572*z^15+853467*z^16+2356779*z^17+6536382*z^18+18199284*z^19+50852019*z^20+...
series(1+1*z+2*z^2+4*z^3+9*z^4+21*z^5+51*z^6+127*z^7+323*z^8+835*z^9+2188*z^10+5798*z^11+15511*z^12+41835*z^13+113634*z^14+310572*z^15+853467*z^16+2356779*z^17+6536382*z^18+18199284*z^19+50852019*z^20+...

The resulting generating functions, although having very different expressions, turn out to be equivalent upon substitution of z with z^2 in that of Motzkin followed by a z^2 multiplication.

>    simplify(Res1-1-z^2*subs(z=z^2,Res2));

0

Thus the n-th coefficients of the generating function for the Motzkin words is equal to the 2n+2-th coefficient of that of the pi-shapes