First-Order Languages and Structures/Parsing, Substitution, and Substitutability

Lesson 3.41,618 words

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.

Running total of across the term ( a two-place function symbol); every proper initial segment stays below the dashed threshold, which the count reaches only at the final symbol, so no prefix is itself a term.

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.

Algorithm:ParseTerm(ε)\textsc{ParseTerm}(\varepsilon) — build the formation tree of a term, or reject
  1. 1
    place ε\varepsilon at the root as the only vertex
  2. 2
    repeat
  3. 3
    if every minimal vertex holds a single symbol then
  4. 4
    return the tree
    each such symbol is a variable or constant
  5. 5
    select a minimal vertex whose expression has two or more symbols
  6. 6
    let ff be its first symbol
  7. 7
    if ff is not an nn-place function symbol with n>0n > 0 then reject
  8. 8
    create nn child vertices below it
  9. 9
    for each child in turn do
  10. 10
    scan the remaining symbols until the shortest string tt with K(t)=1K(t) = 1
  11. 11
    if the expression ends before such tt is found then reject
  12. 12
    label the child with tt and remove tt from the front of the remainder
  13. 13
    until 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.

Decomposition of ; the outermost operation is the implication, recovered by the counting rule, and each subformula decomposes the same way down to the atomic leaves.

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.

Substituting for in rewrites only the free occurrence; the occurrence bound by is shielded and left unchanged.

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.

Capture: substituting the term for in pushes under the quantifier, which binds it; the term's variable is swallowed and the meaning is destroyed.

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.

The substitution lemma as a commuting square: satisfying under (top route) and satisfying under the reassignment (bottom route) always give the same truth value, provided is substitutable for in .

Where the syntax is used

Each result here is invoked by name later; the table records where.

ResultGuaranteesUsed in
unique readabilityrecursions are well definedvalue of a term, satisfaction, free variables
parsing algorithmstructure is effectively recoverabledecidability of is a wff
substitution instantiate a quantifierquantifier axiom of the calculus
substitutabilityno variable capturesoundness of that axiom
substitution lemmasyntax matches semanticssoundness 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 ╌╌