Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Proposition 3.33: recognizability closed under iteration

Proved
MSKleene.rec_iter

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

formal-languagesmany-sorted-algebratree-automatauniversal-algebra

Recognizability closed under iteration (Proposition 3.33).

Assume SSS finite. Let s∈Ss\in Ss∈S and z∈Xsz\in X_{s}z∈Xs​. If L∈Recs(TΣ(X))L\in\mathrm{Rec}_{s}(\mathbf{T}_{\Sigma}(X))L∈Recs​(TΣ​(X)) then L⋆z∈Recs(TΣ(X))L^{\star z}\in\mathrm{Rec}_{s}(\mathbf{T}_{\Sigma}(X))L⋆z∈Recs​(TΣ​(X)). (From CVCL20, Prop. 3.25.)

Preamble
import Definitions.Def_MSKleene_Recognizable
import Definitions.Def_MSKleene_Iteration
Formal statement
namespace MSKleene

/-- **Iteration preserves recognizability** (Proposition 3.33; from CVCL20).

With `S` finite: for `z ∈ X_s`, if `L ⊆ T_Σ(X)_s` is `s`-recognizable then so is
its `z`-iteration `L^{⋆z}`. -/
theorem rec_iter {S : Type} [Finite S] (sig : Signature S) (X : SSet S) {s : S}
    (z : X s) (L : Set (Term sig X s)) (hL : sRecognizable (freeAlgebra sig X) s L) :
    sRecognizable (freeAlgebra sig X) s (iterate z L) := 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

Read-back of MSKleene.rec_iter

Fix a type SSS of sorts that is assumed to be a finite type, together with an SSS-sorted signature sig\mathrm{sig}sig — a family assigning to every finite list of sorts w∈List(S)w\in\mathrm{List}(S)w∈List(S) and every sort s′∈Ss'\in Ss′∈S a type sig w s′\mathrm{sig}\,w\,s'sigws′ of operation symbols of arity www and result sort s′s's′ (this family is not assumed finite) — and an SSS-sorted set of variables XXX, i.e. a family assigning to each sort s′s's′ a type X s′X\,s'Xs′ (also not assumed finite). Let Term(sig,X)\mathrm{Term}(\mathrm{sig},X)Term(sig,X) be the SSS-sorted set of well-sorted first-order terms: for each s′s's′, Term(sig,X) s′\mathrm{Term}(\mathrm{sig},X)\,s'Term(sig,X)s′ is generated by var(x)\mathrm{var}(x)var(x) for x∈X s′x\in X\,s'x∈Xs′ and by app(σ,t⃗ )\mathrm{app}(\sigma,\vec t\,)app(σ,t) for σ∈sig w s′\sigma\in\mathrm{sig}\,w\,s'σ∈sigws′ and t⃗\vec tt a vector of terms whose sorts match www. Let F:=freeAlgebra(sig,X)\mathcal F:=\mathrm{freeAlgebra}(\mathrm{sig},X)F:=freeAlgebra(sig,X) be the algebra over sig\mathrm{sig}sig whose carrier at each sort s′s's′ is Term(sig,X) s′\mathrm{Term}(\mathrm{sig},X)\,s'Term(sig,X)s′ and whose interpretation of a symbol σ\sigmaσ is the term-forming map t⃗↦app(σ,t⃗ )\vec t\mapsto\mathrm{app}(\sigma,\vec t\,)t↦app(σ,t).

The theorem takes an implicit sort s∈Ss\in Ss∈S, an explicit distinguished variable z∈X sz\in X\,sz∈Xs (so X sX\,sXs is inhabited), and an explicit set L⊆Term(sig,X) sL\subseteq\mathrm{Term}(\mathrm{sig},X)\,sL⊆Term(sig,X)s of terms of sort sss. Call a set KKK of elements of Acarrier s′A_{\mathrm{carrier}}\,s'Acarrier​s′ s′s's′-recognizable in an algebra AAA over sig\mathrm{sig}sig when there exists an algebra BBB over the same signature sig\mathrm{sig}sig such that the dependent sum ∑t∈SBcarrier t\sum_{t\in S}B_{\mathrm{carrier}}\,t∑t∈S​Bcarrier​t (the disjoint union of all its carrier sets over all sorts) is a finite type, and there exist a homomorphism f:A→Bf:A\to Bf:A→B — a sort-indexed family of maps ft:Acarrier t→Bcarrier tf_t:A_{\mathrm{carrier}}\,t\to B_{\mathrm{carrier}}\,tft​:Acarrier​t→Bcarrier​t satisfying fs′(A.op(σ,a⃗ ))=B.op(σ,(f applied componentwise to a⃗))f_{s'}\big(A.\mathrm{op}(\sigma,\vec a\,)\big)=B.\mathrm{op}\big(\sigma,(f\text{ applied componentwise to }\vec a)\big)fs′​(A.op(σ,a))=B.op(σ,(f applied componentwise to a)) for every symbol σ\sigmaσ — and a subset M⊆Bcarrier s′M\subseteq B_{\mathrm{carrier}}\,s'M⊆Bcarrier​s′, such that

fs′−1(M)=K,i.e. K={ a:fs′(a)∈M }  exactly (set equality, not inclusion).f_{s'}^{-1}(M)=K,\qquad\text{i.e. } K=\{\,a : f_{s'}(a)\in M\,\}\ \text{ exactly (set equality, not inclusion).}fs′−1​(M)=K,i.e. K={a:fs′​(a)∈M}  exactly (set equality, not inclusion).

The single hypothesis hLhLhL states that LLL is sss-recognizable in F\mathcal FF in precisely this sense; if no such B,f,MB,f,MB,f,M exist for LLL, the hypothesis is false and the theorem asserts nothing about that LLL.

Next, let P(F)\mathcal P(\mathcal F)P(F) be the power algebra: the algebra over sig\mathrm{sig}sig whose carrier at sort ttt is the powerset P(Term(sig,X) t)\mathcal P\big(\mathrm{Term}(\mathrm{sig},X)\,t\big)P(Term(sig,X)t) and whose interpretation of a symbol σ∈sig w t\sigma\in\mathrm{sig}\,w\,tσ∈sigwt sends a tuple of argument-sets (K1,…,Kn)(K_1,\dots,K_n)(K1​,…,Kn​) to { app(σ,(u1,…,un)):uj∈Kj for every j }\{\,\mathrm{app}(\sigma,(u_1,\dots,u_n)) : u_j\in K_j\text{ for every }j\,\}{app(σ,(u1​,…,un​)):uj​∈Kj​ for every j}. Let h:=substHom(z,L)h:=\mathrm{substHom}(z,L)h:=substHom(z,L) be the homomorphism F→P(F)\mathcal F\to\mathcal P(\mathcal F)F→P(F) obtained as the evaluation homomorphism induced by the variable assignment ρ\rhoρ that sends the distinguished variable zzz to the set LLL and sends every other variable yyy (every y∈X sy\in X\,sy∈Xs with y≠zy\ne zy=z, and every variable of every sort t≠st\ne st=s) to the singleton {var(y)}\{\mathrm{var}(y)\}{var(y)}. Unfolding term evaluation, for a term PPP of sort ttt the set ht(P)⊆Term(sig,X) th_t(P)\subseteq\mathrm{Term}(\mathrm{sig},X)\,tht​(P)⊆Term(sig,X)t is computed by structural recursion: hs(var(z))=Lh_s(\mathrm{var}(z))=Lhs​(var(z))=L; ht(var(y))={var(y)}h_t(\mathrm{var}(y))=\{\mathrm{var}(y)\}ht​(var(y))={var(y)} for any other variable yyy; and ht(app(σ,(P1,…,Pn)))={ app(σ,(u1,…,un)):uj∈hsj(Pj) }h_t(\mathrm{app}(\sigma,(P_1,\dots,P_n)))=\{\,\mathrm{app}(\sigma,(u_1,\dots,u_n)) : u_j\in h_{s_j}(P_j)\,\}ht​(app(σ,(P1​,…,Pn​)))={app(σ,(u1​,…,un​)):uj​∈hsj​​(Pj​)}. Equivalently, ht(P)h_t(P)ht​(P) is the set of all terms obtained from PPP by replacing each occurrence of zzz, independently, by some term of LLL; in particular if zzz does not occur in PPP then ht(P)={P}h_t(P)=\{P\}ht​(P)={P}, and if L=∅L=\varnothingL=∅ then hs(var(z))=∅h_s(\mathrm{var}(z))=\varnothinghs​(var(z))=∅. For a set KKK of terms of sort sss define

substP(z,L,s,K)  :=  ⋃P∈Khs(P)(so substP(z,L,s,∅)=∅).\mathrm{substP}(z,L,s,K)\;:=\;\bigcup_{P\in K}h_s(P)\qquad(\text{so }\mathrm{substP}(z,L,s,\varnothing)=\varnothing).substP(z,L,s,K):=P∈K⋃​hs​(P)(so substP(z,L,s,∅)=∅).

Define the iteration stages by recursion on i∈Ni\in\mathbb Ni∈N:

iterStage(z,L,0)={var(z)},iterStage(z,L,i+1)=iterStage(z,L,i) ∪ substP(z,L,s,iterStage(z,L,i)),\mathrm{iterStage}(z,L,0)=\{\mathrm{var}(z)\},\qquad \mathrm{iterStage}(z,L,i+1)=\mathrm{iterStage}(z,L,i)\ \cup\ \mathrm{substP}\big(z,L,s,\mathrm{iterStage}(z,L,i)\big),iterStage(z,L,0)={var(z)},iterStage(z,L,i+1)=iterStage(z,L,i) ∪ substP(z,L,s,iterStage(z,L,i)),

and set

iterate(z,L)  :=  ⋃i∈NiterStage(z,L,i).\mathrm{iterate}(z,L)\;:=\;\bigcup_{i\in\mathbb N}\mathrm{iterStage}(z,L,i).iterate(z,L):=i∈N⋃​iterStage(z,L,i).

Thus stage 000 is the singleton {var(z)}\{\mathrm{var}(z)\}{var(z)}; each next stage keeps everything from the previous stage and adds every term obtained by substituting members of LLL for occurrences of zzz in terms already present; and iterate(z,L)\mathrm{iterate}(z,L)iterate(z,L) is the union of all these (nondecreasing) stages over every natural number iii, including i=0i=0i=0 (so var(z)∈iterate(z,L)\mathrm{var}(z)\in\mathrm{iterate}(z,L)var(z)∈iterate(z,L) always, and iterate(z,∅)={var(z)}\mathrm{iterate}(z,\varnothing)=\{\mathrm{var}(z)\}iterate(z,∅)={var(z)}).

Conclusion. Under all of the above, iterate(z,L)\mathrm{iterate}(z,L)iterate(z,L) is sss-recognizable in F\mathcal FF: there exist an algebra BBB over the signature sig\mathrm{sig}sig whose total carrier ∑t∈SBcarrier t\sum_{t\in S}B_{\mathrm{carrier}}\,t∑t∈S​Bcarrier​t is a finite type, a homomorphism f:F→Bf:\mathcal F\to Bf:F→B, and a subset M⊆Bcarrier sM\subseteq B_{\mathrm{carrier}}\,sM⊆Bcarrier​s such that

fs−1(M)=iterate(z,L)(exact set equality).f_s^{-1}(M)=\mathrm{iterate}(z,L)\qquad\text{(exact set equality).}fs−1​(M)=iterate(z,L)(exact set equality).

The witnessing algebra BBB is constrained only to be over the same signature sig\mathrm{sig}sig and to have finite total carrier; it need not be related to XXX, to F\mathcal FF, or to the algebra witnessing hLhLhL in any other way.

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