Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Lemma 3.25: substitution composition inclusion

Proved
MSKleene.subst_comp

by Cosme · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

formal-languagesmany-sorted-algebratree-automatauniversal-algebra

Substitution composition inclusion (Lemma 3.25).

Let u,s∈Su,s\in Su,s∈S, z∈Xuz\in X_{u}z∈Xu​, L,L′⊆TΣ(X)uL,L'\subseteq\mathrm{T}_{\Sigma}(X)_{u}L,L′⊆TΣ​(X)u​, and K⊆TΣ(X)sK\subseteq\mathrm{T}_{\Sigma}(X)_{s}K⊆TΣ​(X)s​. Then ( ⁣z(zL)u♯p(L′) ⁣)s♯p(K)⊆( ⁣zL ⁣)s♯p ⁣(( ⁣zL′ ⁣)s♯p(K))\left(\!\begin{smallmatrix}z\\\left(\!\begin{smallmatrix}z\\L\end{smallmatrix}\!\right)^{\sharp\mathsf{p}}_{u}(L')\end{smallmatrix}\!\right)^{\sharp\mathsf{p}}_{s}(K)\subseteq\left(\!\begin{smallmatrix}z\\L\end{smallmatrix}\!\right)^{\sharp\mathsf{p}}_{s}\!\left(\left(\!\begin{smallmatrix}z\\L'\end{smallmatrix}\!\right)^{\sharp\mathsf{p}}_{s}(K)\right)(z(zL​)u♯p​(L′)​)s♯p​(K)⊆(zL​)s♯p​((zL′​)s♯p​(K)).

Preamble
import Definitions.Def_MSKleene_Subst
Formal statement
namespace MSKleene

/-- **Substitution composition inclusion** (Lemma 3.25).

For `z ∈ X_u`, languages `L, L' ⊆ T_Σ(X)_u`, and `K ⊆ T_Σ(X)_s`,
`⟨z/⟨z/L⟩^♯ᵖ_u(L')⟩^♯ᵖ_s(K) ⊆ ⟨z/L⟩^♯ᵖ_s(⟨z/L'⟩^♯ᵖ_s(K))`. -/
theorem subst_comp {S : Type} (sig : Signature S) (X : SSet S) {u s : S}
    (z : X u) (L L' : Set (Term sig X u)) (K : Set (Term sig X s)) :
    substP z (substP z L u L') s K ⊆ substP z L s (substP z L' s K) := by
  sorry

end MSKleene
Source
Gong, Ruiz Mora, Sanmartín Vich, Cosme Llópez, "A Kleene theorem for free many-sorted algebras", 2026
Read-back

What the Lean code literally says, in plain math · claude-sonnet-5

Fix a type S of sorts in the lowest universe (S:Type0).\text{Fix a type } S \text{ of \textbf{sorts} in the lowest universe } (S : \mathrm{Type}_0).Fix a type S of sorts in the lowest universe (S:Type0​).

The data of the statement are: a signature sig:List S→S→Type\mathrm{sig} : \mathrm{List}\,S \to S \to \mathrm{Type}sig:ListS→S→Type, assigning to every input word w∈List Sw \in \mathrm{List}\,Sw∈ListS and output sort sss a type sig(w,s)\mathrm{sig}(w,s)sig(w,s) of operation symbols; an SSS-indexed family of variable types X:S→TypeX : S \to \mathrm{Type}X:S→Type; two implicit sorts u,s∈Su, s \in Su,s∈S; a single distinguished variable z∈Xuz \in X_uz∈Xu​ of sort uuu; two sets L,L′⊆Term(sig,X,u)L, L' \subseteq \mathrm{Term}(\mathrm{sig}, X, u)L,L′⊆Term(sig,X,u) of sort-uuu terms; and a set K⊆Term(sig,X,s)K \subseteq \mathrm{Term}(\mathrm{sig}, X, s)K⊆Term(sig,X,s) of sort-sss terms. Here Term(sig,X,t)\mathrm{Term}(\mathrm{sig}, X, t)Term(sig,X,t) is the type of sort-ttt terms, generated (mutually with sorted finite tuples of terms) by injecting a variable x∈Xtx \in X_tx∈Xt​ as a term and by applying an operation symbol σ∈sig(w,t)\sigma \in \mathrm{sig}(w,t)σ∈sig(w,t) to a length-www vector of terms of the matching sorts. For the variable z∈Xuz \in X_uz∈Xu​ and a set L⊆Term(sig,X,u)L \subseteq \mathrm{Term}(\mathrm{sig},X,u)L⊆Term(sig,X,u), define a nondeterministic substitution operator as follows: it is the (classically defined) algebra homomorphism from the term algebra into the power algebra of the term algebra — the algebra whose carrier at sort ttt is Set(Term(sig,X,t))\mathrm{Set}\big(\mathrm{Term}(\mathrm{sig},X,t)\big)Set(Term(sig,X,t)) and whose operation σ\sigmaσ sends a tuple of sets to the set of all σ\sigmaσ-applications formed by choosing one representative from each argument set independently — determined by the assignment that sends the variable zzz (of sort uuu) to the entire set LLL and sends every other variable yyy of any sort t′t't′ (whether t′≠ut' \neq ut′=u, or t′=ut' = ut′=u but y≠zy \neq zy=z, equality of variables being decided classically) to the singleton set {y}\{y\}{y}; writing subz,L(P)⊆Term(sig,X,t)\mathrm{sub}_{z,L}(P) \subseteq \mathrm{Term}(\mathrm{sig},X,t)subz,L​(P)⊆Term(sig,X,t) for the value of this homomorphism at a term P∈Term(sig,X,t)P \in \mathrm{Term}(\mathrm{sig},X,t)P∈Term(sig,X,t), it is concretely the set of all terms obtained from PPP by replacing each leaf occurrence of zzz independently by some element of LLL while leaving all other variables fixed and without recursing into the substituted terms, so that subz,L(P)={P}\mathrm{sub}_{z,L}(P) = \{P\}subz,L​(P)={P} when zzz does not occur in PPP, and subz,L(P)=∅\mathrm{sub}_{z,L}(P) = \varnothingsubz,L​(P)=∅ when zzz occurs in PPP but L=∅L = \varnothingL=∅. Then, for an explicitly given target sort sss and a set K⊆Term(sig,X,s)K \subseteq \mathrm{Term}(\mathrm{sig},X,s)K⊆Term(sig,X,s), set

subPz,Ls(K)  =  ⋃P∈Ksubz,L(P)  ⊆  Term(sig,X,s),\mathrm{subP}^{s}_{z,L}(K) \;=\; \bigcup_{P \in K} \mathrm{sub}_{z,L}(P) \;\subseteq\; \mathrm{Term}(\mathrm{sig},X,s),subPz,Ls​(K)=P∈K⋃​subz,L​(P)⊆Term(sig,X,s),

which is ∅\varnothing∅ when K=∅K = \varnothingK=∅; the sort uuu of the substituted variable is an implicit argument recovered from zzz, whereas the superscript sort is passed explicitly and pins down the common sort of the input set and of the result. The theorem asserts the single set inclusion

subP z, subPz,Lu(L′)s(K)  ⊆  subPz,Ls ⁣(subPz,L′s(K)),\mathrm{subP}^{s}_{\,z,\ \mathrm{subP}^{u}_{z,L}(L')}(K) \;\subseteq\; \mathrm{subP}^{s}_{z,L}\!\Big(\mathrm{subP}^{s}_{z,L'}(K)\Big),subPz, subPz,Lu​(L′)s​(K)⊆subPz,Ls​(subPz,L′s​(K)),

where on the left one first forms subPz,Lu(L′)=⋃P∈L′subz,L(P)⊆Term(sig,X,u)\mathrm{subP}^{u}_{z,L}(L') = \bigcup_{P \in L'} \mathrm{sub}_{z,L}(P) \subseteq \mathrm{Term}(\mathrm{sig},X,u)subPz,Lu​(L′)=⋃P∈L′​subz,L​(P)⊆Term(sig,X,u) (substituting zzz by elements of LLL throughout the members of L′L'L′, at target sort uuu) and then uses that set as the replacement set for a single substitution of zzz into the members of KKK; and on the right one first substitutes zzz by elements of L′L'L′ throughout the members of KKK (at sort sss) and then substitutes zzz by elements of LLL throughout the members of that intermediate result. In words: the set of terms produced by rewriting each occurrence of zzz in some element of KKK by a single element of the pre-composed set "L′L'L′ with zzz replaced by LLL" is contained in the set produced by two successive sweeps, first z:=L′z := L'z:=L′ over KKK and then z:=Lz := Lz:=L over the outcome. The quantified data LLL, L′L'L′, KKK (together with the sorts u,su, su,s, the variable zzz, the signature sig\mathrm{sig}sig, and the family XXX) are arbitrary, with no finiteness, nonemptiness, or occurrence hypotheses imposed; hence the degenerate cases K=∅K = \varnothingK=∅ (both sides equal ∅\varnothing∅), L′=∅L' = \varnothingL′=∅, and L=∅L = \varnothingL=∅ all fall under the claim, as does the case where members of LLL or L′L'L′ themselves contain the variable zzz (on the left such residual occurrences are left untouched by the outer single-pass substitution, whereas on the right they are exposed to the second substitution pass). The assertion is exactly this ⊆\subseteq⊆, not an equality and not the reverse inclusion.

Human review
  • Endorsed by Shuze Chen · Sep 9, 2026

  • Endorsed by Cosme · Sep 9, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me