Lemma 3.18: the collapse lemma
ProvedMSKleene.collapse_lemmaThe collapse lemma (Lemma 3.18).
Let be a -algebra and a homomorphism from to ; let , . For every and every with there exist and such that: (1) ; (2) ; (3) for every , and ; (4) for every with : (a) it is not the case that both and , and (b) there exists with and .
import Definitions.Def_MSKleene_SubstFam import Definitions.Def_MSKleene_Subterm
namespace MSKleene
/-- **The collapse lemma** (Lemma 3.18).
Let `g : T_Σ(X) → A` be a homomorphism, `z ∈ X_u`, and `R ∈ T_Σ(X)_s` a
non-minimal term. Then there are a term `P` and a family `qs` for the
occurrences of `z` in `P` such that:
1. `R = ⟨z/qs⟩(P)`;
2. `g_s(P) = g_s(R)`;
3. every `qs α` is a proper subterm of `R` with `g_u(qs α) = g_u(z)`;
4. every proper non-minimal subterm `M` of `P` (a) does not have both sort `u`
and `g`-image `g_u(z)`, and (b) has a proper non-minimal subterm `N` of `R`
of the same sort with `g(N) = g(M)`. -/
theorem collapse_lemma {S : Type} (sig : Signature S) (X : SSet S)
(A : Algebra sig) (g : Hom (freeAlgebra sig X) A) {u : S} (z : X u) {s : S}
(R : Term sig X s) (hR : ¬ Min (⟨s, R⟩ : STerm sig X)) :
∃ (P : Term sig X s) (qs : Fin (Term.occ z P) → Term sig X u),
R = substFam z P qs
∧ g.toFun s P = g.toFun s R
∧ (∀ α, SubtermLT (⟨u, qs α⟩ : STerm sig X) ⟨s, R⟩
∧ g.toFun u (qs α) = g.toFun u (Term.var z))
∧ (∀ M : STerm sig X, SubtermLT M ⟨s, P⟩ → ¬ Min M →
(¬ ∃ h : M.1 = u, g.toFun u (h ▸ M.2) = g.toFun u (Term.var z))
∧ (∃ N : STerm sig X, SubtermLT N ⟨s, R⟩ ∧ ¬ Min N
∧ ∃ h : N.1 = M.1, g.toFun M.1 (h ▸ N.2) = g.toFun M.1 M.2)) := by
sorry
end MSKleeneRead-back
What the Lean code literally says, in plain math · claude-sonnet-5
Let be a type of sorts and an -sorted signature (for each arity and result sort , a type of operation symbols). Let be an -sorted family of variable types (a type for each sort ). Let be a -algebra (a carrier family together with an interpretation of every operation symbol on argument tuples), and let be a homomorphism from the free/term algebra — whose sort- carrier is the inductive type of terms of sort over (a term is either a variable with , or an application of a symbol to a length-matched vector of argument terms) — into . Write for the sort- component of . The statement also fixes an implicit sort , a variable , an implicit sort , and a term .
An -term is a dependent pair of a sort and a term ; write for its two components. Call an immediate subterm of when is an application of some symbol to an argument vector one of whose entries is exactly (at the matching sort ). Write for the transitive closure of "immediate subterm" (one or more such steps; strictly proper — reflexivity is not included). Call minimal, , if it has no immediate subterm, i.e. its term component is a variable or a symbol applied to the empty argument vector (a constant). The hypothesis is : is an application of an operation symbol to a nonempty argument vector (it has at least one immediate subterm).
For , let be the number of leaf positions of that are exactly the variable (a leaf of sort counts iff and ). Given a family indexed by those occurrences, let be the term obtained from by replacing, in left-to-right depth-first traversal order, the -th occurrence of the variable by for , and leaving every other leaf of unchanged. Throughout, an expression written denotes transported along a proof of an equality of sorts, so that it can be read at the target sort.
Claim. There exist a term and a family such that all of the following hold:
-
: the given term is exactly with each of its occurrences of the variable replaced, in traversal order, by the corresponding , all other leaves of preserved. (If , then is the empty family and this clause reads .)
-
: and have the same image under at sort .
-
For every index , both:
- — the inserted term is a strictly proper subterm of ; and
- — has the same -image at sort as the one-variable term .
(This clause is vacuous when .)
-
For every -term such that (a strictly proper subterm of ) and ( is an operation symbol applied to a nonempty argument vector), both:
- (a) There is no proof of for which . Equivalently: it is not the case that 's sort is and , read at sort , has the same -image at sort as the variable term .
- (b) There exists an -term with (a strictly proper subterm of ), ( is an operation symbol applied to a nonempty argument vector), and a proof of (so and have the same sort) such that — i.e. , read at 's sort, has the same -image at that sort as .
The four clauses are conjoined under the single existential over . Degenerate readings the quantifiers admit: is allowed, forcing in clause 1 and emptying clause 3; the universally quantified in clause 4 ranges only over strictly-proper non-minimal subterms of , so if has no such subterm (e.g. is a variable, a constant, or an application all of whose arguments are variables/constants) clause 4 is vacuously satisfied.
Confirmed by the mission captain (proposal self-audit).