Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Claim 4.13 (Main Claim): the auxiliary languages are regular

Proved
MSKleene.main_claim

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

formal-languagesmany-sorted-algebratree-automatauniversal-algebra

The auxiliary languages are regular (Claim 4.13 (Main Claim)).

In the recognition context of the proof of Proposition 4.10: for every u∈Su\in Su∈S, every C⊆NC\subseteq NC⊆N, every K⊆NK\subseteq NK⊆N with K≤NK\le NK≤N, and every l∈nul\in n_{u}l∈nu​, there exists a regular expression Ru(C,K,l)∈TReg(S,Σ,Z)(Z)uR_{u}(C,K,l)\in\mathrm{T}_{\mathrm{Reg}(S,\Sigma,Z)}(Z)_{u}Ru​(C,K,l)∈TReg(S,Σ,Z)​(Z)u​ with {Ru(C,K,l)}uZ♯=Lu(C,K,l)\{R_{u}(C,K,l)\}^{Z\sharp}_{u}=L_{u}(C,K,l){Ru​(C,K,l)}uZ♯​=Lu​(C,K,l); that is, the languages Lu(C,K,l)L_{u}(C,K,l)Lu​(C,K,l) are uuu-regular. Proved by induction on the budget size ∥∥K∥∥=∑sks\|\|K\|\|=\sum_{s}k_{s}∥∥K∥∥=∑s​ks​.

Preamble
import Definitions.Def_MSKleene_AuxLang
Formal statement
namespace MSKleene

/-- **Main Claim** (Claim 4.13).

In the recognition context `ctx` of the proof of Proposition 4.10, for every
sort `u`, every set `C ⊆ N` of leaf-admissible states, every sortwise budget
`K ≤ N`, and every target state `l ∈ N_u`, the auxiliary language
`L_u(C,K,l)` is `u`-regular over `Z`: there is a regular expression `R` of type
`u` over `(S,Σ,Z)` with `{R}^{Z♯}_u = L_u(C,K,l)`. -/
theorem main_claim {S : Type} [Finite S] (sig : Signature S) (X : SSet S)
    (hsig : SigFinite sig) (hX : SFinite X) (ctx : KleeneCtx sig X) (u : S)
    (C : (s : S) → Set (Fin (ctx.n s))) (K : S → ℕ) (hK : ∀ s, K s ≤ ctx.n s)
    (l : Fin (ctx.n u)) :
    ∃ R : RegExpr sig ctx.Z u,
      interpExpr sig ctx.Z u R = ctx.auxLang u C K 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.main_claim

Fix a type SSS of sorts that is finite ([Finite S][\text{Finite }S][Finite S]; note that some sort u∈Su\in Su∈S is provided, so SSS is inhabited in any instance). A signature Σ\SigmaΣ assigns to every arity word w∈S∗w\in S^{*}w∈S∗ (a finite list of sorts) and every result sort s∈Ss\in Ss∈S a type Σw,s\Sigma_{w,s}Σw,s​ of operation symbols; a sorted variable family XXX assigns to every sort sss a type XsX_sXs​. The hypotheses hsig\mathrm{hsig}hsig and hX\mathrm{hX}hX assert respectively that the total collection ∑w,sΣw,s\sum_{w,s}\Sigma_{w,s}∑w,s​Σw,s​ of all operation symbols is finite and that the total collection ∑sXs\sum_{s}X_s∑s​Xs​ of all variables is finite. A Kleene context ctx\mathrm{ctx}ctx over (Σ,X)(\Sigma,X)(Σ,X) consists of three pieces of data: a function n ⁣:S→Nn\colon S\to\mathbb{N}n:S→N; for every symbol σ∈Σw,s\sigma\in\Sigma_{w,s}σ∈Σw,s​ an interpreting map Nopσ ⁣:∏iFin(nwi)→Fin(ns)\mathrm{Nop}_\sigma\colon \prod_{i}\mathrm{Fin}(n_{w_i})\to \mathrm{Fin}(n_s)Nopσ​:∏i​Fin(nwi​​)→Fin(ns​) (so the tuple of finite sets (Fin(ns))s∈S\big(\mathrm{Fin}(n_s)\big)_{s\in S}(Fin(ns​))s∈S​, with these operations, forms a Σ\SigmaΣ-algebra N\mathcal NN); and a variable assignment fgen\mathrm{fgen}fgen sending each x∈Xsx\in X_sx∈Xs​ to an element fgens(x)∈Fin(ns)\mathrm{fgen}_s(x)\in\mathrm{Fin}(n_s)fgens​(x)∈Fin(ns​). Write Zs:=Xs⊕Fin(ns)Z_s := X_s \oplus \mathrm{Fin}(n_s)Zs​:=Xs​⊕Fin(ns​) for the disjoint union (this is ctx.Z), with left injection ι1 ⁣:Xs↪Zs\iota_1\colon X_s\hookrightarrow Z_sι1​:Xs​↪Zs​ and right injection ι2 ⁣:Fin(ns)↪Zs\iota_2\colon \mathrm{Fin}(n_s)\hookrightarrow Z_sι2​:Fin(ns​)↪Zs​. Let Ts\mathcal T_sTs​ denote the set of Σ\SigmaΣ-terms of sort sss with variables drawn from ZZZ: each such term is either var(z)\mathrm{var}(z)var(z) for some z∈Zsz\in Z_sz∈Zs​, or σ(t1,…,tk)\sigma(t_1,\dots,t_k)σ(t1​,…,tk​) for a symbol σ∈Σw,s\sigma\in\Sigma_{w,s}σ∈Σw,s​ and terms ti∈Twit_i\in\mathcal T_{w_i}ti​∈Twi​​. There is a canonical evaluation homomorphism h ⁣:Ts→Fin(ns)h\colon \mathcal T_s\to \mathrm{Fin}(n_s)h:Ts​→Fin(ns​) determined by

h(var(ι1x))=fgens(x),h(var(ι2m))=m,h(σ(t1,…,tk))=Nopσ(h(t1),…,h(tk)),h(\mathrm{var}(\iota_1 x)) = \mathrm{fgen}_s(x),\qquad h(\mathrm{var}(\iota_2 m)) = m,\qquad h(\sigma(t_1,\dots,t_k)) = \mathrm{Nop}_\sigma\big(h(t_1),\dots,h(t_k)\big),h(var(ι1​x))=fgens​(x),h(var(ι2​m))=m,h(σ(t1​,…,tk​))=Nopσ​(h(t1​),…,h(tk​)),

and for a sort‑tagged term Q=(s,q)Q=(s,q)Q=(s,q) we write hVal(Q):=h(q)∈N\mathrm{hVal}(Q) := h(q)\in\mathbb{N}hVal(Q):=h(q)∈N (the underlying natural number of the element of Fin(ns)\mathrm{Fin}(n_s)Fin(ns​)).

The theorem's remaining inputs are: a distinguished sort u∈Su\in Su∈S; a family CCC assigning to every sort sss a subset Cs⊆Fin(ns)C_s\subseteq \mathrm{Fin}(n_s)Cs​⊆Fin(ns​); a function K ⁣:S→NK\colon S\to\mathbb{N}K:S→N; a hypothesis hK\mathrm{hK}hK stating Ks≤nsK_s\le n_sKs​≤ns​ for every sort sss (this is satisfiable, e.g. by K≡0K\equiv 0K≡0, and KKK enters the conclusion only through auxLang\mathrm{auxLang}auxLang below); and a distinguished element l∈Fin(nu)l\in \mathrm{Fin}(n_u)l∈Fin(nu​) (whose existence forces nu≥1n_u\ge 1nu​≥1; for any sort ttt with nt=0n_t=0nt​=0 one necessarily has Ct=∅C_t=\varnothingCt​=∅ and Kt=0K_t=0Kt​=0). Call a variable-occurrence condition CCC-admissible for a term: every variable appearing at a leaf that has the form ι2(m)\iota_2(m)ι2​(m) at sort ttt satisfies m∈Ctm\in C_tm∈Ct​, while leaves of the form ι1(x)\iota_1(x)ι1​(x) are unconstrained (formally Term.varsIn (ctx.inXC C), using Sum.elim\mathrm{Sum.elim}Sum.elim to send ι1\iota_1ι1​‑variables to True\mathrm{True}True and ι2(m)\iota_2(m)ι2​(m) at sort ttt to m∈Ctm\in C_tm∈Ct​). Let proper subterm\mathrm{proper\ subterm}proper subterm mean the strict, transitive closure of the immediate‑subterm relation, where QQQ is an immediate subterm of RRR iff RRR's term is an application σ(t1,…,tk)\sigma(t_1,\dots,t_k)σ(t1​,…,tk​) (over the plain signature Σ\SigmaΣ) and QQQ's term is one of the tit_iti​ (at the corresponding sort); and call a sort‑tagged term minimal if it has no immediate subterm at all — i.e. it is either a variable or an application of a symbol to the empty argument list. Then auxLangu(C,K,l)\mathrm{auxLang}_u(C,K,l)auxLangu​(C,K,l) is the subset of Tu\mathcal T_uTu​ consisting of exactly those terms PPP such that:

  1. PPP is CCC-admissible (every ι2(m)\iota_2(m)ι2​(m)-variable occurring anywhere in PPP, at whatever sort ttt, has m∈Ctm\in C_tm∈Ct​);
  2. for every sort‑tagged term Q=(sQ,q)Q=(s_Q,q)Q=(sQ​,q) that is a proper subterm of (u,P)(u,P)(u,P), that is not minimal (so qqq is an application with at least one argument), and that is itself CCC-admissible, one has
hVal(Q)  <  KsQ;\mathrm{hVal}(Q) \;<\; K_{s_Q};hVal(Q)<KsQ​​;

(if PPP is a variable or a nullary application this condition is vacuous); 3. h(P)=lh(P) = lh(P)=l in Fin(nu)\mathrm{Fin}(n_u)Fin(nu​).

Next, the regular signature Σ^\widehat\SigmaΣ over ZZZ has, at arity (w,s)(w,s)(w,s), the following operation symbols: base(σ)\mathrm{base}(\sigma)base(σ) for each σ∈Σw,s\sigma\in\Sigma_{w,s}σ∈Σw,s​; a symbol 0s\mathbf 0_s0s​ of arity ([ ],s)([\,],s)([],s); a symbol iters(z)\mathrm{iter}_s(z)iters​(z) of arity ([s],s)([s],s)([s],s) for each z∈Zsz\in Z_sz∈Zs​; a symbol pluss\mathrm{plus}_spluss​ of arity ([s,s],s)([s,s],s)([s,s],s); and a symbol substt,s(z)\mathrm{subst}_{t,s}(z)substt,s​(z) of arity ([t,s],s)([t,s],s)([t,s],s) for each z∈Ztz\in Z_tz∈Zt​. A regular expression of sort uuu, RegExpr sig ctx.Z u, is a term of sort uuu over Σ^\widehat\SigmaΣ whose variables are drawn from ZZZ. Its interpretation ⟦R⟧⊆Ts\llbracket R\rrbracket \subseteq \mathcal T_s[[R]]⊆Ts​ (this is interpExpr sig ctx.Z s, the unique homomorphic extension into the powerset Σ\SigmaΣ-algebra whose carrier at sort sss is P(Ts)\mathcal P(\mathcal T_s)P(Ts​), sending each generator var(z)\mathrm{var}(z)var(z) to the singleton {var(z)}\{\mathrm{var}(z)\}{var(z)}) is defined recursively by:

⟦var(z)⟧={var(z)},⟦0s⟧=∅,⟦pluss(R1,R2)⟧=⟦R1⟧∪⟦R2⟧,\llbracket \mathrm{var}(z)\rrbracket = \{\mathrm{var}(z)\},\qquad \llbracket \mathbf 0_s\rrbracket = \varnothing,\qquad \llbracket \mathrm{plus}_s(R_1,R_2)\rrbracket = \llbracket R_1\rrbracket \cup \llbracket R_2\rrbracket,[[var(z)]]={var(z)},[[0s​]]=∅,[[pluss​(R1​,R2​)]]=[[R1​]]∪[[R2​]], ⟦base(σ)(R1,…,Rk)⟧={ σ(t1,…,tk)  ∣  ti∈⟦Ri⟧ for each i },\llbracket \mathrm{base}(\sigma)(R_1,\dots,R_k)\rrbracket = \big\{\, \sigma(t_1,\dots,t_k) \;\big|\; t_i\in \llbracket R_i\rrbracket \text{ for each } i \,\big\},[[base(σ)(R1​,…,Rk​)]]={σ(t1​,…,tk​)​ti​∈[[Ri​]] for each i}, ⟦substt,s(z)(R1,R2)⟧=⋃P∈⟦R2⟧P[z:=⟦R1⟧],\llbracket \mathrm{subst}_{t,s}(z)(R_1,R_2)\rrbracket = \bigcup_{P\in \llbracket R_2\rrbracket} P\big[z := \llbracket R_1\rrbracket\big],[[substt,s​(z)(R1​,R2​)]]=P∈[[R2​]]⋃​P[z:=[[R1​]]], ⟦iters(z)(R1)⟧=⋃i∈NIi,where L=⟦R1⟧,  I0={var(z)},  Ii+1=Ii∪⋃P∈LP[z:=Ii].\llbracket \mathrm{iter}_s(z)(R_1)\rrbracket = \bigcup_{i\in\mathbb{N}} I_i,\quad\text{where } L=\llbracket R_1\rrbracket,\ \ I_0=\{\mathrm{var}(z)\},\ \ I_{i+1}=I_i\cup \bigcup_{P\in L} P\big[z := I_i\big].[[iters​(z)(R1​)]]=i∈N⋃​Ii​,where L=[[R1​]],  I0​={var(z)},  Ii+1​=Ii​∪P∈L⋃​P[z:=Ii​].

Here P[z:=M]P[z:=M]P[z:=M] denotes the set of all terms obtained from PPP by replacing each occurrence of the specific variable zzz (matched by both its sort and its identity in ZtZ_tZt​) independently by an arbitrary term of MMM, leaving every other variable and every operation symbol unchanged (the nondeterministic substitution homomorphism substHom). The claim of the theorem is that, under all the hypotheses above, there exists a regular expression R∈RegExpr Σ Z uR\in\texttt{RegExpr}\ \Sigma\ Z\ uR∈RegExpr Σ Z u such that

⟦R⟧  =  auxLangu(C,K,l)\llbracket R\rrbracket \;=\; \mathrm{auxLang}_u(C,K,l)[[R]]=auxLangu​(C,K,l)

as subsets of Tu\mathcal T_uTu​ — i.e. the language auxLangu(C,K,l)\mathrm{auxLang}_u(C,K,l)auxLangu​(C,K,l) is exactly the interpretation of some regular expression over Σ^\widehat\SigmaΣ with variables in ZZZ. The existential is plain (∃\exists∃, not ∃!\exists!∃!): no uniqueness of RRR is asserted, and the finiteness hypotheses [Finite S][\text{Finite }S][Finite S], hsig\mathrm{hsig}hsig, hX\mathrm{hX}hX, together with hK\mathrm{hK}hK, are assumed but do not otherwise appear in the concluding equation.

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