We want the language L ={w | |#0-#1| = |#2-#3|}

There are 4 possible values that the absolute value can have: (#0-#1>0 and #2-#3>0), or (#0-#1<0 and #2-#3>0) or ()… or ….().

Each one is a CFL - let's take (#0-#1>0 and #2-#3>0) for example.

Than the language L1 is {w | #0-#1 = #2-#3} = {w | (#0+#3)-(#1+#2) = 0}.

We saw in the last recitation how to build a PDA that accepts this language, using positive block (A) and a negative block (B).

The only difference is that in L1 every 0 and every 3 raise the result of the subtraction by one, and every 1 and every 2 subtracts one from the result.

The same is true for all other three cases.

So L is a CFL.

Can someone please explain why the language described in question 9 of the midterm above is a CFG?

Thanks a lot!

]]>