Recognizable and -recognizable languages
DefinitionMSKleene_RecognizableRecognizability for subsets of a many-sorted -algebra (Definitions 2.28, 2.55).
A full -sorted subset L of A is recognizable (IsRecognizable) when there are a finite -algebra B, a homomorphism f : A → B, and an -sorted subset M of B with f⁻¹[M] = L sortwise. For a single sort s, a language L ⊆ A_s is -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. .
Formalization Note A -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.
/-
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
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 whose elements are called sorts, and a signature over (a signature assigns to each pair consisting of a list of sorts and a single sort a type , whose elements are the operation symbols of input arity and output sort ). Given an algebra for — a structure providing a carrier family 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 ) to — the definition Algebra.Finite B is the proposition that the dependent sum (total space) , whose elements are the pairs with a sort and an element of , is a finite type in the sense of Mathlib's Finite predicate (i.e. it admits a bijection with for some natural number ). This is a single finiteness condition on the disjoint union of all carriers taken together; it does not by itself assert that is finite, nor that each individual is finite, and it holds, for example, whenever every is empty, irrespective of the cardinality of .
IsRecognizable
Parametrized implicitly by a universe level, a sort type , and a signature on . Its inputs are an algebra for (a carrier family together with operation interpretations) and a family assigning to each sort a subset . The proposition IsRecognizable A L asserts that there exists an algebra for such that:
- the total space (pairs with ) is a finite type in Mathlib's
Finitesense; and - there exist a homomorphism and a family assigning to each sort a subset , such that for every sort the preimage
is equal, as a subset of , to .
Here a homomorphism consists of a family of maps (one per sort) together with a proof that for every operation symbol and every argument tuple of sorts , . No surjectivity of is required, and is an arbitrary family of subsets of the carriers of (no closure or saturation condition). The equality in clause 2 is required at every sort simultaneously, using the same , , and ; if is empty this universal condition over sorts is vacuous, so the statement then reduces to the mere existence of a finite algebra with a homomorphism .
sRecognizable
Parametrized implicitly by a universe level, a sort type , and a signature on . Its inputs are an algebra for , one fixed sort , and a single subset of the carrier of at that sort (not a family over all sorts). The proposition sRecognizable A s L asserts that there exists an algebra for such that:
- the total space is a finite type in Mathlib's
Finitesense; and - there exist a homomorphism and a single subset (at the same fixed sort ) such that
an equality of subsets of .
The homomorphism is a full homomorphism (a map for every sort , satisfying the operation-compatibility condition for every operation symbol), but only its component at the single sort is constrained by clause 2; the behaviour of and the choice of subsets at all other sorts are otherwise unconstrained. No surjectivity of is required.
Recognizable
Parametrized implicitly by a universe level, a sort type , and a signature on . Given an algebra for , Recognizable A is defined to be the set of all families — where a family assigns to each sort a subset — such that IsRecognizable A L holds; that is, . The ambient type is the collection of all such sort-indexed families of subsets of '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 , and a signature on . Given an algebra for and one fixed sort , RecS A s is defined to be the set of all subsets such that sRecognizable A s L holds; that is, . The ambient type is the collection of all subsets of the carrier , and RecS A s is the sub-collection of those subsets that are recognizable at the single sort in the sense spelled out under sRecognizable.
Confirmed by the mission captain (proposal self-audit).