WFF of PropLog is Balanced

Theorem
Every WFF of propositional calculus has the same number of left brackets as right brackets.

A string with the same number of left as right brackets is (in this context) referred to as balanced.

Proof
Let:
 * $$l \left({\mathbf{Q}}\right)$$ denote the number of left brackets in a string $$\mathbf{Q}$$;
 * $$r \left({\mathbf{Q}}\right)$$ denote the number of right brackets in a string $$\mathbf{Q}$$.

The only WFFs of PropCalc of Length 1‎ are elements of the alphabet and the symbols $$\bot$$ and $$\top$$.

None of these consist of brackets.

So every WFF $$\mathbf{D}$$ of length $$1$$ have $$l \left({\mathbf{D}}\right) = r \left({\mathbf{D}}\right) = 0$$.

So every WFF of length $$1$$ is balanced.

Now, suppose all strings of length $$k$$ and less are balanced.

Let $$\mathbf{A}$$ be a WFF of length $$k+1$$.

There are two cases:


 * $$\mathbf{A} = \neg \mathbf{B}$$, where $$\mathbf{B}$$ is a WFF of length $$k$$ and hence balanced.

So $$\mathbf{A}$$ contains the same brackets as $$\mathbf{B}$$ and so must itself be balanced.


 * $$\mathbf{A} = \left({\mathbf{B} \circ \mathbf{C}}\right)$$ where $$\circ$$ is one of the binary connectives.

Then:
 * $$l \left({\mathbf{A}}\right) = l \left({\mathbf{B}}\right) + l \left({\mathbf{C}}\right) + 1$$;
 * $$r \left({\mathbf{A}}\right) = r \left({\mathbf{B}}\right) + r \left({\mathbf{C}}\right) + 1$$.

Now, $$\mathbf{B}$$ and $$\mathbf{C}$$ are both shorter than $$k+1$$ and are therefore balanced.

So $$l \left({\mathbf{B}}\right) = r \left({\mathbf{B}}\right)$$ and $$l \left({\mathbf{C}}\right) = r \left({\mathbf{C}}\right)$$

It follows that $$l \left({\mathbf{A}}\right) = r \left({\mathbf{A}}\right)$$ and so $$\mathbf{A}$$ is balanced.

We assumed that all WFFs of length $$k$$ and less are balanced, and demonstrated that as a consequence all WFFs of length $$k+1$$ are balanced.

The result follows by strong induction.