Sum of symbol values in wff written in polish notation. So I am currently dealing with a problem like this:

If we count $\rightarrow , \land , \lor$ and $\leftrightarrow$ each as $+1$ , each statement letter as $-1$ and $\lnot$ as $0$ , prove that an expression $\mathscr B$ in this parenthesis-free notation is a statement form if and only if $(i)$ the sum of the symbols of $\mathscr B$ is $-1$ and $(ii)$ the sum of symbols in any proper initial segment of $\mathscr B$ is nonnegative.

So , if A = "an expression $\mathscr B$ in this parenthesis-free notation is a statement form"
We have to show the following wff to be true,
$$A \leftrightarrow ((i) \land (ii))$$
Here , I assume that "parenthesis free notation" is just polish notation
I was able to prove that $A \rightarrow (i)$ the same way wff are defined with a recursive algorithm (Not sure if mine was valid though because it is polish notation). But couldn't figure out How to prove $A \leftarrow (i)$ .
I have no idea How to prove something like $A \leftrightarrow (ii)$ with a recursive approch because there is also proper initial segments imvolving . At this point , proving $A \leftrightarrow ((i) \land (ii))$ seems to be far for me.
Is there something beyond recursion that I need?
 A: The forward implication is indeed proved by induction. It’s clear that $(i)$ and $(ii)$ hold for a single statement letter. If they hold for a statement form $\varphi$, it’s easy to see that they hold for $\neg\varphi$:

*

*The sum of the symbols is unchanged by prefixing $\neg$.

*Every proper initial segment of $\neg\varphi$ is of the form $\neg\sigma$, where $\sigma$ is empty or a proper initial segment of $\varphi$. If $\sigma$ is empty, the sum is $0$, and if not, the sum is the same as that of $\sigma$ and so is non-negative.

Now suppose that $(i)$ and $(ii)$ hold for statement forms $\varphi$ and $\psi$, and let $\diamondsuit$ be one of the binary connectives $\to$, $\land$, $\lor$, and $\leftrightarrow$; we want to show that $\diamondsuit\varphi\psi$ satisfies $(i)$ and $(ii)$. The sum of the symbols in $\diamondsuit\varphi\psi$ is $1+(-1)+(-1)=-1$, so $\diamondsuit\varphi\psi$ satisfies $(ii)$. Now consider a proper initial segment $\diamondsuit\sigma$ of $\diamondsuit\varphi\psi$.

*

*If $\sigma$ is empty, the sum of the segment is $1$.

*If $\sigma$ is a proper initial segment of $\varphi$, its sum is non-negative, so the sum of $\diamondsuit\sigma$ is positive.

*If $\sigma=\varphi$, the sum of $\diamondsuit\sigma$ is $1+(-1)=0$.

*If $\sigma=\varphi\tau$, where $\tau$ is a proper initial segment of $\psi$, the sum of $\diamondsuit\varphi$ is $0$, and the sum of $\tau$ is non-negative, so the sum of $\diamondsuit\sigma$ is also non-negative.

Thus, $\diamondsuit\varphi\psi$ satisfies $(i)$. This shows that every statement form satisfies $(i)$ and $(ii)$.
For the other direction you cannot hope to prove that $(i)$ implies $A$: it’s the conjunction of $(i)$ and $(ii)$ that implies $A$. This can be proved by induction on the length of the string of symbols. I’ll sketch the argument, leaving many of the details to you.

*

*Show that $\sigma$ satisfies $(i)$ and $(ii)$ and has length $1$, it must be a single statement letter and hence a statement form.

Now assume that $\sigma$ has at least two symbols and that every shorter string that satisfies $(i)$ and $(ii)$ is a statement form. There are three possibilities for the first symbol of $\sigma$.

*

*Show that if $\sigma$ satisfies $(i)$ and $(ii)$, its first symbol cannot be a statement letter.

*Show that if $\sigma=\neg\tau$, then $\tau$ satisfies $(i)$ and $(ii)$. The induction hypothesis then implies that $\tau$ is a statement form, and that in turn implies that $\sigma$ is a statement form.

The third possibility is that $\sigma=\diamondsuit\tau$; this is the hardest case.

*

*Show that $\sigma$ must have a proper initial segment whose symbols sum to $0$; you’ll use the fact that $\sigma$ satisfies $(i)$.

Let $\diamondsuit\varphi$ be the shortest such segment.

*

*Verify that $\varphi$ satisfies $(i)$ and $(ii)$ and conclude that it must be a statement form. (Why?)

*Let $\psi$ be the remainder of $\sigma$, so that $\sigma=\diamondsuit\varphi\psi$. Verify that $\psi$ also satisfies $(i)$ and $(ii)$ and so must be a statement form, and conclude that $\sigma$ is a statement form.

By induction, therefore, every string of symbols satisfying $(i)$ and $(ii)$ is a statement form.
