First note that a substring which is itself a logical formula must coincide with a subtree of the formula syntax tree of the surrounding logical formula. Indeed, a logical formula can begin only at a logical variable, a negation symbol or an opening parenthesis. Every such position in a valid logical formula is the start of one of its parsed subtrees. If is the logical formula at that subtree and is another logical formula starting at the same position, one is an initial segment of the other; prefix-freeness of fully parenthesized formulas from the preceding part forces .
Now consider a final subformula. For a logical variable, it can only be the whole logical formula. For a binary logical implication , every proper subtree is contained in or and finishes before the final closing parenthesis of the whole expression. It therefore cannot be a final substring of the whole. The only remaining possible outer formation is negation. Thus
The second alternative is a necessary possibility, not a claim that every negated logical formula has every one of its subformulas as a suffix.
The whole logical formula is a subformula of itself, and any subformula of remains a contiguous substring after placing a negation symbol in front of .
Conversely, a subformula occurrence starting at the first symbol of is an initial subformula, so equals the whole logical formula by prefix-freeness of fully parenthesized formulas. An occurrence starting later lies wholly inside the following string , and is therefore a subformula of . Consequently
Here records distinct logical formulas; multiple occurrences of the same logical formula do not create different elements of this set.
A subformula beginning at the first opening parenthesis equals the whole logical formula by prefix-freeness of fully parenthesized formulas. Every other subformula is the logical formula of a proper syntax subtree, by the parsing argument in part (iii). The two children of the root are precisely and , so such a subtree lies entirely inside one of those children. In particular no logical formula substring can begin in and cross the principal logical implication symbol into .
Conversely, each subformula of either child is visibly a substring of the whole expression, as is the whole expression itself. Thus
Together these cases identify the substring definition of a subformula with its usual syntax-tree definition.
In the grammar , no logical formula is a proper initial segment of another. A recursive parser reads one variable, or a negation followed by one formula, or a parenthesized pair of formulas separated by implication. Structural induction shows that this parser consumes precisely one whole formula. Its deterministic stopping position proves prefix-freeness. Consequently any formula substring in a valid formula coincides with the formula of a syntax subtree.