Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Recognizable and sss-recognizable languages

Definition
MSKleene_Recognizable

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

formal-languagesmany-sorted-algebratree-automatauniversal-algebra

Recognizability for subsets of a many-sorted Σ\SigmaΣ-algebra (Definitions 2.28, 2.55).

A full SSS-sorted subset L of A is recognizable (IsRecognizable) when there are a finite Σ\SigmaΣ-algebra B, a homomorphism f : A → B, and an SSS-sorted subset M of B with f⁻¹[M] = L sortwise. For a single sort s, a language L ⊆ A_s is sss-recognizable (sRecognizable) when there are a finite B, a homomorphism f, and M ⊆ B_s with f_s⁻¹[M] = L.

Recognizable A and RecS A s collect these. The mission goal concerns RecS (freeAlgebra sig X) s, i.e. Recs(TΣ(X))\mathrm{Rec}_s(\mathbf{T}_\Sigma(X))Recs​(TΣ​(X)).

Formalization Note A Σ\SigmaΣ-algebra is finite (Algebra.Finite) when the disjoint union of its carrier is finite; with S finite this is equivalent to every component being finite.

Definition code
/-
Recognizability for subsets of a many-sorted `Σ`-algebra (Definitions 2.28, 2.55).

A subset is **recognizable** when it is the sortwise preimage of a subset of a
*finite* `Σ`-algebra under a homomorphism; **`s`-recognizable** is the same at a
single sort `s`. `Rec_s(𝐓_Σ(X))` is the object of interest for the mission goal.
-/
import Definitions.Def_MSKleene_Core
import Mathlib.Data.Set.Basic

namespace MSKleene

universe u

variable {S : Type u} {sig : Signature S}

/-- A `Σ`-algebra is finite when the disjoint union of its carrier is finite
(Definition 2.31). -/
def Algebra.Finite (B : Algebra sig) : Prop := SFinite B.carrier

/-- `L` (a full `S`-sorted subset of `A`) is **recognizable**: there are a
finite `Σ`-algebra `B`, a homomorphism `f : A → B`, and an `S`-sorted subset
`M` of `B` with `f⁻¹[M] = L` sortwise (Definition 2.28). -/
def IsRecognizable (A : Algebra sig) (L : SSub A.carrier) : Prop :=
  ∃ B : Algebra sig, B.Finite ∧
    ∃ (f : Hom A B) (M : SSub B.carrier), ∀ s, f.toFun s ⁻¹' (M s) = L s

/-- `L ⊆ A_s` is **`s`-recognizable**: there are a finite `Σ`-algebra `B`, a
homomorphism `f : A → B`, and `M ⊆ B_s` with `f_s⁻¹[M] = L` (Definition 2.55). -/
def sRecognizable (A : Algebra sig) (s : S) (L : Set (A.carrier s)) : Prop :=
  ∃ B : Algebra sig, B.Finite ∧
    ∃ (f : Hom A B) (M : Set (B.carrier s)), f.toFun s ⁻¹' M = L

/-- `Rec(A)` — the set of recognizable `S`-sorted subsets of `A`. -/
def Recognizable (A : Algebra sig) : Set (SSub A.carrier) :=
  { L | IsRecognizable A L }

/-- `Rec_s(A)` — the set of `s`-recognizable languages of `A` at sort `s`. -/
def RecS (A : Algebra sig) (s : S) : Set (Set (A.carrier s)) :=
  { L | sRecognizable A s L }

end MSKleene
Source
Gong, Ruiz Mora, Sanmartín Vich, Cosme Llópez, "A Kleene theorem for free many-sorted algebras", 2026, https://arxiv.org/abs/1808.08217 (predecessor CVCL20)
Read-back

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

Algebra.Finite

This declaration is parametrized implicitly by a universe level, a type SSS whose elements are called sorts, and a signature sig\mathrm{sig}sig over SSS (a signature assigns to each pair consisting of a list www of sorts and a single sort sss a type sig w s\mathrm{sig}\,w\,ssigws, whose elements are the operation symbols of input arity www and output sort sss). Given an algebra BBB for sig\mathrm{sig}sig — a structure providing a carrier family s↦Bss \mapsto B_ss↦Bs​ that assigns a type to every sort, together with an interpretation of each operation symbol as a function from tuples of carrier elements (of the sorts listed in www) to BsB_sBs​ — the definition Algebra.Finite B is the proposition that the dependent sum (total space) Σs:S Bs\Sigma_{s : S}\, B_sΣs:S​Bs​, whose elements are the pairs (s,x)(s, x)(s,x) with s:Ss : Ss:S a sort and xxx an element of BsB_sBs​, is a finite type in the sense of Mathlib's Finite predicate (i.e. it admits a bijection with {0,1,…,n−1}\{0, 1, \dots, n-1\}{0,1,…,n−1} for some natural number nnn). This is a single finiteness condition on the disjoint union of all carriers taken together; it does not by itself assert that SSS is finite, nor that each individual BsB_sBs​ is finite, and it holds, for example, whenever every BsB_sBs​ is empty, irrespective of the cardinality of SSS.

IsRecognizable

Parametrized implicitly by a universe level, a sort type SSS, and a signature sig\mathrm{sig}sig on SSS. Its inputs are an algebra AAA for sig\mathrm{sig}sig (a carrier family s↦Ass \mapsto A_ss↦As​ together with operation interpretations) and a family LLL assigning to each sort sss a subset Ls⊆AsL_s \subseteq A_sLs​⊆As​. The proposition IsRecognizable A L asserts that there exists an algebra BBB for sig\mathrm{sig}sig such that:

  1. the total space Σs:S Bs\Sigma_{s : S}\, B_sΣs:S​Bs​ (pairs (s,x)(s, x)(s,x) with x∈Bsx \in B_sx∈Bs​) is a finite type in Mathlib's Finite sense; and
  2. there exist a homomorphism f:A→Bf : A \to Bf:A→B and a family MMM assigning to each sort sss a subset Ms⊆BsM_s \subseteq B_sMs​⊆Bs​, such that for every sort sss the preimage
fs−1(Ms)  =  { a∈As∣fs(a)∈Ms }f_s^{-1}(M_s) \;=\; \{\, a \in A_s \mid f_s(a) \in M_s \,\}fs−1​(Ms​)={a∈As​∣fs​(a)∈Ms​}

is equal, as a subset of AsA_sAs​, to LsL_sLs​.

Here a homomorphism f:A→Bf : A \to Bf:A→B consists of a family of maps fs:As→Bsf_s : A_s \to B_sfs​:As​→Bs​ (one per sort) together with a proof that for every operation symbol σ∈sig w s\sigma \in \mathrm{sig}\,w\,sσ∈sigws and every argument tuple args\mathrm{args}args of sorts www, fs(A.op σ args)=B.op σ (f applied componentwise to args)f_s\big(A.\mathrm{op}\,\sigma\,\mathrm{args}\big) = B.\mathrm{op}\,\sigma\,\big(f \text{ applied componentwise to } \mathrm{args}\big)fs​(A.opσargs)=B.opσ(f applied componentwise to args). No surjectivity of fff is required, and MMM is an arbitrary family of subsets of the carriers of BBB (no closure or saturation condition). The equality in clause 2 is required at every sort simultaneously, using the same BBB, fff, and MMM; if SSS is empty this universal condition over sorts is vacuous, so the statement then reduces to the mere existence of a finite algebra BBB with a homomorphism A→BA \to BA→B.

sRecognizable

Parametrized implicitly by a universe level, a sort type SSS, and a signature sig\mathrm{sig}sig on SSS. Its inputs are an algebra AAA for sig\mathrm{sig}sig, one fixed sort s:Ss : Ss:S, and a single subset L⊆AsL \subseteq A_sL⊆As​ of the carrier of AAA at that sort (not a family over all sorts). The proposition sRecognizable A s L asserts that there exists an algebra BBB for sig\mathrm{sig}sig such that:

  1. the total space Σt:S Bt\Sigma_{t : S}\, B_tΣt:S​Bt​ is a finite type in Mathlib's Finite sense; and
  2. there exist a homomorphism f:A→Bf : A \to Bf:A→B and a single subset M⊆BsM \subseteq B_sM⊆Bs​ (at the same fixed sort sss) such that
fs−1(M)  =  { a∈As∣fs(a)∈M }  =  L,f_s^{-1}(M) \;=\; \{\, a \in A_s \mid f_s(a) \in M \,\} \;=\; L,fs−1​(M)={a∈As​∣fs​(a)∈M}=L,

an equality of subsets of AsA_sAs​.

The homomorphism f:A→Bf : A \to Bf:A→B is a full homomorphism (a map ft:At→Btf_t : A_t \to B_tft​:At​→Bt​ for every sort ttt, satisfying the operation-compatibility condition for every operation symbol), but only its component fsf_sfs​ at the single sort sss is constrained by clause 2; the behaviour of fff and the choice of subsets at all other sorts are otherwise unconstrained. No surjectivity of fff is required.

Recognizable

Parametrized implicitly by a universe level, a sort type SSS, and a signature sig\mathrm{sig}sig on SSS. Given an algebra AAA for sig\mathrm{sig}sig, Recognizable A is defined to be the set of all families LLL — where a family assigns to each sort sss a subset Ls⊆AsL_s \subseteq A_sLs​⊆As​ — such that IsRecognizable A L holds; that is, { L∣there exists a finite algebra B, a homomorphism f:A→B, and a family of subsets M of B with fs−1(Ms)=Ls for every sort s }\{\, L \mid \text{there exists a finite algebra } B, \text{ a homomorphism } f : A \to B, \text{ and a family of subsets } M \text{ of } B \text{ with } f_s^{-1}(M_s) = L_s \text{ for every sort } s \,\}{L∣there exists a finite algebra B, a homomorphism f:A→B, and a family of subsets M of B with fs−1​(Ms​)=Ls​ for every sort s}. The ambient type is the collection of all such sort-indexed families of subsets of AAA's carriers, and Recognizable A is the sub-collection of those that satisfy the recognizability condition spelled out under IsRecognizable.

RecS

Parametrized implicitly by a universe level, a sort type SSS, and a signature sig\mathrm{sig}sig on SSS. Given an algebra AAA for sig\mathrm{sig}sig and one fixed sort s:Ss : Ss:S, RecS A s is defined to be the set of all subsets L⊆AsL \subseteq A_sL⊆As​ such that sRecognizable A s L holds; that is, { L∣there exists a finite algebra B, a homomorphism f:A→B, and a subset M⊆Bs with fs−1(M)=L }\{\, L \mid \text{there exists a finite algebra } B, \text{ a homomorphism } f : A \to B, \text{ and a subset } M \subseteq B_s \text{ with } f_s^{-1}(M) = L \,\}{L∣there exists a finite algebra B, a homomorphism f:A→B, and a subset M⊆Bs​ with fs−1​(M)=L}. The ambient type is the collection of all subsets of the carrier AsA_sAs​, and RecS A s is the sub-collection of those subsets that are recognizable at the single sort sss in the sense spelled out under sRecognizable.

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