Corollary 3.17: homomorphism invariance under state-preserving substitution
ProvedMSKleene.subst_invHomomorphism invariance under state-preserving substitution (Corollary 3.17).
Let be a -algebra and a homomorphism from to . Let , , , and a family in with for every . Then .
import Definitions.Def_MSKleene_SubstFam
namespace MSKleene
/-- **Homomorphism invariance under state-preserving substitution**
(Corollary 3.17).
If `g : T_Σ(X) → A` is a homomorphism, `z ∈ X_u`, `P ∈ T_Σ(X)_s`, and the family
`qs` substituted for the occurrences of `z` in `P` satisfies `g_u(qs α) = g_u(z)`
for every `α`, then `g_s(⟨z/qs⟩(P)) = g_s(P)`. -/
theorem subst_inv {S : Type} (sig : Signature S) (X : SSet S) (A : Algebra sig)
(g : Hom (freeAlgebra sig X) A) {u s : S} (z : X u) (P : Term sig X s)
(qs : Fin (Term.occ z P) → Term sig X u)
(hq : ∀ α, g.toFun u (qs α) = g.toFun u (Term.var z)) :
g.toFun s (substFam z P qs) = g.toFun s P := by
sorry
end MSKleeneRead-back
What the Lean code literally says, in plain math · claude-sonnet-5
The theorem, stated in a namespace MSKleene, concerns many-sorted universal algebra. Fix a type of sorts (here , i.e. in the lowest universe). A signature over assigns to each list of argument sorts and each result sort a type of operation symbols. An -sorted set is a family of types indexed by ; think of as the variables of sort . A -algebra consists of a carrier family () together with, for every symbol , an operation sending a tuple of arguments of sorts to an element of . The terms of sort are built inductively: either for some , or where and is a tuple of terms whose sorts are exactly the entries of . These terms form the carrier of the free algebra on , whose operations are just term formation.
The statement fixes:
- a signature over , an -sorted set , and a -algebra ;
- a homomorphism from the free algebra on to ; concretely supplies maps for all , and these commute with every operation symbol (applying to equals applying 's -operation to the componentwise -images of );
- implicit sorts ;
- a variable of sort ;
- a term of sort .
Let be the occurrence count of in : traversing , it counts each leaf whose sort equals and for which (after the identification of sorts) ; leaves that are a different variable, or a variable of a sort other than , contribute , and the count is additive over the argument tuples of every -node.
The statement further fixes a family
of replacement terms, all of sort (indexed by ), and assumes the hypothesis
i.e. sends every replacement term to the very same element of that it assigns to the one‑variable term .
Write for the family substitution: form the list , then traverse from left to right (each -node's arguments processed in order, recursively), and at the -th encountered occurrence of (for ) replace that leaf by the current head of the list, passing the remaining tail forward; non-matching leaves and all operation nodes are left in place. Because the list has exactly entries and there are exactly matching occurrences, every replacement term is used once and in occurrence order, and the leftover list is empty; the result term is returned (the unused tail is discarded). In the internal definition, if the list were ever exhausted at a matching occurrence that leaf would be kept unchanged, but that branch does not arise here since the lengths coincide.
The conclusion asserted (its proof is omitted) is the equality in
applying the homomorphism to the term obtained from by replacing its occurrences of with the terms yields the same element of as applying to itself.
Edge cases folded into the quantifiers: is an arbitrary homomorphism, not necessarily the canonical evaluation map; no finiteness or decidability hypotheses are imposed on , , or . If (in particular if does not occur in , or occurs only at sorts ), then the index type is empty, is the empty family, the hypothesis holds vacuously, returns unchanged, and the conclusion is the trivial identity . If with , then and the conclusion is exactly the instance of .
Confirmed by the mission captain (proposal self-audit).