Unique Readability and a Parsing Algorithm
Parentheses keep a formula from being read two ways. The parenthesis lemmas and a top-down parsing algorithm recover a formula's structure and yield unique readability: every wff has exactly one formation tree, which is what makes the truth recursion well defined.
╌╌╌╌
The truth recursion assigns by climbing the formation tree of , which makes sense only if has one formation tree. It does: the parentheses in the definition of a wff leave no formula ambiguous.
Without parentheses, ambiguity is immediate. The string can be assembled two ways, as or as . Under , the two readings disagree — the first is (its conjunction has a false right conjunct), the second (its disjunction has a true left disjunct) — so would have no well-defined value. The parentheses in every exist to forbid exactly this.1
The parenthesis lemmas
Two facts about how parentheses distribute in a wff are used throughout. The first was proved in the formation lesson.
The consequence follows from the lemma with the parenthesis-balance lemma: a wff is balanced, but a proper initial segment is left-heavy, so a proper initial segment cannot be a wff.
The running count of unmatched left parentheses makes the lemma visual. Scan a wff left to right, adding at each and subtracting at each . The parenthesis-balance lemma says the count returns to at the end; the initial-segment lemma says it stays strictly positive at every proper initial segment along the way.
The parsing algorithm
The initial-segment lemma forces every choice a parser could make. The algorithm reads an expression and either rejects it or builds its formation tree from the top down, splitting each compound at its principal connective.
- 1place at the root; mark it the only vertex
- 2repeat
- 3if every minimal vertex holds a sentence symbol then
- 4return the treeis a wff
- 5select a minimal vertex whose expression is not a sentence symbol
- 6if the first symbol of is not "(" then reject
- 7if the second symbol of is "" then
- 8must be with an expression
- 9attach one child holding
- 10else
- 11scan from the left to the shortest with balanced and nonempty
- 12the next symbol must be a binary connectivethe principal connective
- 13the remainder must be with an expression
- 14attach children holding and
- 15until the tree is complete
Four observations establish correctness.1
- Termination. Each child holds a strictly shorter expression than its parent, so the tree depth is bounded by the length of .
- Forced choices. In the binary case the first constituent must be exactly : any shorter prefix is unbalanced (violating the parenthesis-balance lemma applied to a would-be constituent), and any longer one contains the balanced as a proper initial segment (violating the initial-segment lemma). The principal connective and the second constituent are then determined.
- Rejection is sound. If the algorithm rejects, the only possible attempt to build a tree has failed, so was no wff.
- Acceptance is sound. If it succeeds, working up the finished tree shows every vertex holds a wff, the root included.
Unique readability
Because every choice the parser makes is forced, it constructs the only possible tree for the given wff. This is the central syntactic fact of the language.
The language is unambiguous, and the parser exhibits the tree — what the truth
recursion needed. For any wff there is one tree; propagating values up
it assigns without ambiguity, and the resulting function meets
the recursion clauses. So exists, completing the half of the
unique-extension theorem left open under
truth assignments.
The general form of this unique readability licenses recursion
argument is the
recursion theorem.
The figure shows the two readings of : only the tree whose root is the conjunction is a legal parse, because the outermost matched pair of parentheses encloses with as its principal connective.
Polish notation
Parentheses are one way to avoid ambiguity; they are not the only way. Polish (prefix) notation writes the connective before its arguments and drops the parentheses entirely. In place of one writes , and the P-wffs are generated from the sentence symbols by
Polish notation is well suited to machine processing; compilers routinely convert input formulas into it. Its own unique readability theorem is proved in the first-order parsing lesson, where the parenthesis-free case reappears.
Omitting parentheses
For readability, some parentheses are dropped by convention when naming wffs, with precedence rules restoring them.
- Outermost parentheses are omitted: names .
- Negation binds tightest: is , not .
- Conjunction and disjunction bind tighter than the conditional and biconditional: is .
- Repeated connectives group to the right: is .
These abbreviations violate the strict naming rules on purpose; the license is harmless because only wffs are ever named, and each abbreviation restores to exactly one wff.
Footnotes
╌╌ END ╌╌