Measure-theoretic closure operator
Project: Topoi of automata
Contents
The density of a language is the probability that a random word belongs to it. For a class $\mathcal C$ of languages, a language is $\mathcal C$-measurable if the languages of $\mathcal C$ approximate it in density, from the inside and from the outside. For classes of regular languages, passing from $\mathcal C$ to the class of $\mathcal C$-measurable languages is a closure operator. We compare it with a second closure operator, which is defined by probabilistic independence, and we extend the density of regular languages to a $\sigma$-additive measure on the space of profinite words.
1. Definition§
Fix a finite alphabet $\Sigma$.
Definition 1.1 (Density)§
The density of a language $L\subseteq\Sigma^*$ is
when the limit exists. The $k$-th term is the fraction of the words of length $k$ that belong to $L$, and the density is the limit of the averages of these fractions.
Example 1.2 (Lengths)§
Let $L_n$ be the language of the words whose length is divisible by $n$. The fraction of the words of length $k$ in $L_n$ is $1$ if $n$ divides $k$ and $0$ otherwise, so $\delta(L_n)=\tfrac1n$. The table marks the lengths of the words in $L_2$, in $L_3$ and in $L_2\cap L_3=L_6$.
Definition 1.3 (Measurable language [SY25])§
For a class $\mathcal C$ of languages, a language $L$ is $\mathcal C$-measurable if the densities of the languages of $\mathcal C$ contained in $L$ and of the languages of $\mathcal C$ containing $L$ come arbitrarily close to each other:
Definition 1.4 (Measurable extension)§
The measurable extension $\mathrm{Ext}(\mathcal C)$ of a class $\mathcal C$ of languages is the class of $\mathcal C$-measurable languages.
Fact 1.5 (Closure operator [Sin21])§
For classes of regular languages, $\mathcal C\mapsto\mathrm{Ext}(\mathcal C)$ is a closure operator: it is monotone, contains $\mathcal C$ since regular languages have densities, and is idempotent since approximations compose.
See Sin'ya–Yuyama, Lemma 9, which attributes this to Sin'ya 2021.
Definition 1.6 (Double orthogonal)§
Two languages $L$ and $L'$ are independent, written $L\perp L'$, if $\delta(L\cap L')=\delta(L)\,\delta(L')$. For classes $\mathcal C$ and $\mathcal D$ of languages, we write $\mathcal C\perp\mathcal D$ if every language of $\mathcal C$ is independent of every language of $\mathcal D$. The orthogonal class of $\mathcal C$ is
and the double orthogonal of $\mathcal C$ is $\mathcal C^{\perp\perp}=(\mathcal C^\perp)^\perp$.
Remark 1.7 (Second closure operator)§
The double orthogonal $\mathcal C\mapsto\mathcal C^{\perp\perp}$ is another closure operator. This holds for every symmetric binary relation in place of $\perp$.
Example 1.8 (Independent lengths)§
In the example of lengths, $L_2\perp L_3$, because $\delta(L_2\cap L_3)=\tfrac16=\tfrac12\cdot\tfrac13$. In general $L_n\perp L_m$ if and only if $n$ and $m$ are coprime.
2. Properties§
The measurable extension is a closure operator, but it does not come from a topology. It is contained in the double orthogonal, and this gives a way to show that a language is not measurable.
Example 2.1 (Not topological)§
A closure operator that comes from a topology preserves binary unions; this is one of the Kuratowski closure axioms. The operator $\mathrm{Ext}$ does not. Let $\mathcal C$ and $\mathcal D$ be the classes of the regular languages of density $>\tfrac12$ and $<\tfrac12$, and let $L_n$ be the language of the words of length divisible by $n$. Then $L_2\in\mathrm{Ext}(\mathcal C\cup\mathcal D)$ but $L_2\notin\mathrm{Ext}(\mathcal C)\cup\mathrm{Ext}(\mathcal D)$.
Proof§
We have $L_2\setminus L_{3^k}\subseteq L_2\subseteq L_2\cup L_{3^k}$, and these two regular languages have the densities $\tfrac12\mp\tfrac1{2\cdot 3^k}$, since $L_2\perp L_{3^k}$. So the first lies in $\mathcal D$, the second lies in $\mathcal C$, and $L_2$ is $(\mathcal C\cup\mathcal D)$-measurable. But no language of $\mathcal C$ is contained in $L_2$, and no language of $\mathcal D$ contains $L_2$.
Proposition 2.2 (Orthogonality)§☆
For every class $\mathcal C$ of languages, $\mathcal C^\perp=\mathrm{Ext}(\mathcal C)^\perp$: a language that is independent of every language of $\mathcal C$ is independent of every $\mathcal C$-measurable language. Hence $\mathrm{Ext}(\mathcal C)\subseteq\mathcal C^{\perp\perp}$.
Proof§
Let $L\in\mathcal C^\perp$ and $L'\in\mathrm{Ext}(\mathcal C)$. If $K\subseteq L'\subseteq K'$ with $K,K'\in\mathcal C$, then $\delta(L\cap L')$ is squeezed between $\delta(L)\delta(K)$ and $\delta(L)\delta(K')$, so $\delta(L\cap L')=\delta(L)\delta(L')$. Hence $\mathrm{Ext}(\mathcal C)\subseteq\mathrm{Ext}(\mathcal C)^{\perp\perp}=\mathcal C^{\perp\perp}$.
Corollary 2.3 (Independent classes)§☆
If $\mathcal C\perp\mathcal D$ and $L$ is both $\mathcal C$- and $\mathcal D$-measurable, then $L\perp L$, so $\delta(L)\in\{0,1\}$.
Proof§
Apply the orthogonality result twice. Since $\mathcal D\subseteq\mathcal C^\perp=\mathrm{Ext}(\mathcal C)^\perp$ and $L\in\mathrm{Ext}(\mathcal C)$, we get $L\in\mathcal D^\perp=\mathrm{Ext}(\mathcal D)^\perp$. As $L\in\mathrm{Ext}(\mathcal D)$, this gives $L\perp L$, that is, $\delta(L)=\delta(L\cap L)=\delta(L)^2$.
Example 2.4 (Star-free and group languages)§
The star-free languages and the group languages are independent classes [SY25, Theorem 18]. So a language of density strictly between $0$ and $1$ is not measurable for both classes.
Profinite words§
The density is finitely additive, but it is not a $\sigma$-additive measure on $\Sigma^*$: the set $\Sigma^*$ is countable and every single word has density $0$. The free profinite monoid $\widehat{\Sigma^*}$, whose Boolean algebra of clopen subsets is the Boolean algebra of regular languages, is not countable, and on it the density becomes a $\sigma$-additive probability measure.
Proposition 2.5 (Canonical measure)§☆
There is a unique Borel probability measure $\hat\delta$ on the free profinite monoid $\widehat{\Sigma^*}$ with $\hat\delta(C)=\delta(C\cap\Sigma^*)$ for every clopen subset $C$. Let $S\subseteq\widehat{\Sigma^*}$ be a subset with null boundary, that is, whose boundary $\overline S\setminus\mathrm{Int}(S)$ is contained in a set of measure $0$. Then the language $S\cap\Sigma^*$ is measurable for the class of regular languages, and $\delta(S\cap\Sigma^*)=\hat\delta(S)$.
See Corollary 4.1.1 and Proposition 4.2.5 of the note on language measurability.
Proof§
The density is a finitely additive probability measure on the countable Boolean algebra of regular languages. Finitely additive measures on a countable Boolean algebra correspond to Borel measures on its Stone space, which here is $\widehat{\Sigma^*}$. The claim on subsets with null boundary is Proposition 4.2.5 of the note.
3. Open questions§
Question 3.1 (Ext and double orthogonal)§
How far apart are $\mathrm{Ext}(\mathcal C)$ and $\mathcal C^{\perp\perp}$? The double orthogonal should be the closed subspace generated by $\mathcal C$ in $L^2(\widehat{\Sigma^*},\hat\delta)$.
4. Related concepts§
5. References§
- [Hor26] Ryuya Hora, A note on language measurability, draft (2026).
- [HS26] Ryuya Hora and Ryoma Sin'ya, Measure-theoretic closure operators on formal languages, PPL 2026.
- [Sin21] Ryoma Sin'ya, Carathéodory extensions of subclasses of regular languages, DLT 2021, Lecture Notes in Computer Science 12811 (2021), 355–367.
- [SY25] Ryoma Sin'ya and Takao Yuyama, Measure-theoretic aspects of star-free and group languages, arXiv:2506.14134.