CFG and PDA for the set of strings in $\{a, b, c\}^∗$ such that the number of b’s is equal to the sum of number of a’s and c’s
For the PDA, I think you use the stack to track the number of A plus the number of C minus the number of B seen so far, using both positive and negative tokens:

If the stack is empty and you see an A or a C, you push a &quot;+1&quot; token.
If the stack is empty and you see a B, you push a &quot;-1&quot; token.
If the stack is not empty and you see the kind of token that's already on there (e.g. you have a +1 token and you see an A or a C), then you push another of the same token.
If the stack is not empty and you see the wrong kind of token (e.g. there's a &quot;-1&quot; token on the stack and you see an A or a C), you pop one token.

Depending on your formalisation of PDA you may want to start off by pushing a &quot;zero&quot; token in order to check whether the stack is &quot;logically empty&quot; or not.
The stack keeps the invariant that there can never be both a &quot;+1&quot; and a &quot;-1&quot; token on it at the same time.
The word is in the language if and only if the stack is (logically) empty at the end of the string.