Parsing, Substitution, and Substitutability
Every recursion on first-order syntax rests on unique readability. A parenthesis-counting function proves that terms and formulas decompose in exactly one way, and a parsing algorithm recovers the decomposition.
╌╌╌╌
Defining a function by recursion on a string presumes the string decomposes in exactly one way. The value of a term, satisfaction, and free occurrence are all defined this way, and each would be ill-posed if a single expression admitted two decompositions returning different answers. Unique readability is the theorem that rules this out. A parsing algorithm recovers the decomposition of any string, and the substitution operation together with its substitutability side condition supply the quantifier axiom the deductive calculus needs.
Counting to read terms
Terms use Polish notation: a function symbol precedes its arguments, with no parentheses or commas. The tool for analyzing such strings is a weight function that scores how many terms a symbol still needs behind it.
Because no symbol is a sequence of others, the extension is unambiguous, and was chosen as the unique symbol-weighting for which whole terms score .
Two consequences restrict where a term can begin and end inside a longer string.
Reading as a running total left to right, the count dips below throughout a term and reaches only at the very last symbol.
The parsing algorithm
The counting lemmas turn into a procedure that both decides whether an expression is a term and, if so, builds its unique formation tree. It grows a tree downward, splitting each compound expression at its leading function symbol into the arguments that symbol requires.
- 1place at the root as the only vertex
- 2repeat
- 3if every minimal vertex holds a single symbol then
- 4return the treeeach such symbol is a variable or constant
- 5select a minimal vertex whose expression has two or more symbols
- 6let be its first symbol
- 7if is not an -place function symbol with then reject
- 8create child vertices below it
- 9for each child in turn do
- 10scan the remaining symbols until the shortest string with
- 11if the expression ends before such is found then reject
- 12label the child with and remove from the front of the remainder
- 13until the tree is complete
The split is forced. At each function symbol we take the first string with : a shorter string would not yet be a term, and a longer one would contain as a proper initial segment that is already a complete term, contradicting the corollary above. No step ever had a second option, so the decomposition is unique.
Parsing formulas
Formulas use parentheses, so extends to the remaining symbols by the same
how many things must follow
principle — counting right parentheses, terms, or
formulas as the objects still required.
with for an -place predicate symbol. The same three lemmas recur with the same proofs: every wff scores , and every proper initial segment of a wff scores below , so no proper initial segment of a formula is a formula.
Parsing formulas mirrors parsing terms, with atomic formulas at the leaves. A non-atomic wff begins with (one subformula follows) or with a left parenthesis, after which the next symbol is (one subformula) or the start of an implication (two subformulas, split by counting parentheses or by ). Both methods locate the split uniquely.
Every recursion on wffs depends on this theorem.
With freeness established, the recursion theorem guarantees that the value of a term, the satisfaction relation, and the free-variable function are each well defined.
Substitution
The deductive calculus will need to instantiate a universally quantified
variable: from infer with in place of .
That replacement is an operation on syntax, defined by recursion.
The quantifier clause is the point: a prefix shields its variable, so substitution stops at bound occurrences and touches only free ones. Thus , and — the free becomes , the bound one does not.
Substitutability
Blind substitution can go wrong. Let be , true in any structure with two or more elements (there is something unequal to ). Instantiating with the term produces
which is false in every structure. The substituted landed inside the and was captured, turning a satisfiable formula into a contradiction. The axiom is only sound when this cannot happen.
The condition guarantees that no variable of is captured by a quantifier
it passes under. Special cases: is always substitutable for itself, and any
whose variables do not occur in is substitutable. Note a
terminology trap: even when is not substitutable, the expression
is still formed by replacing free with ; substitutable
names a property, not a precondition for writing the symbol.
The substitution lemma
Substitution is a syntactic operation; its semantic meaning is a change of assignment. The link is proved first for terms, then for formulas.
Substituting for inside the term has the same value as leaving alone and instead reassigning to the value of .
The two routes from a formula-and-assignment to a truth value agree: substitute the term and then evaluate, or reassign the variable and then evaluate the original.
Where the syntax is used
Each result here is invoked by name later; the table records where.
| Result | Guarantees | Used in |
|---|---|---|
| unique readability | recursions are well defined | value of a term, satisfaction, free variables |
| parsing algorithm | structure is effectively recoverable | decidability of is a wff |
| substitution | instantiate a quantifier | quantifier axiom of the calculus |
| substitutability | no variable capture | soundness of that axiom |
| substitution lemma | syntax matches semantics | soundness and completeness |
Syntax, structures, satisfaction, definability, and substitution together fix the language of first-order logic as a mathematical object. A deductive calculus built over it defines a purely syntactic notion of proof; the substitution lemma is what makes that notion match logical consequence in the soundness and completeness theorems.
╌╌ END ╌╌