Skip to content

Language Semiring

RegEx notation looks a lot like ring expressions.

Tags: reference, computer science

I actually wrote this blog post a couple months ago but only decided to shape it up for posting today: june 18th.


In my computation theory class, after defining a regular expression, we also defined operations $\cdot$ and $\cup$. These operations would take a set of words in a regular language and construct yet another set of words. Interestingly, there were some special sets that make this look like a ring:

This makes it almost a ring with:

$$ 0 \coloneqq \emptyset \\ 1 := \{ \epsilon \} \\ + \coloneqq \cup \\ \times := \cdot $$

For some given alphabet $\Sigma$, one has to prove that:

  1. $(\Sigma^*, +) \in \mathbf{Ab}$
  2. $(\Sigma^*, \times) \in \mathbf{Mon}$
  3. $A \times (B + C) = A \times B + A \times C$

However, we immediately run into some problems. Since $\cup$ is closed and commutative, then $+$ is also closed and commutative. Previously we saw that $\emptyset$ acts as an identity element, so in order to prove (1.) it suffices to show that every set $A$ has an inverse $A'$ such that $A \cup A' = \emptyset$ (there are inverses). For non-empty sets $A$ or $B$, this is false. So this cannot be a group and therefore cannot be Abelian either. Not only is this not a group, every element can have more than identity. So, $A + A = A \cup A = A$.

Now we know that $(\Sigma^*, +)$ is a commutative monoid. This makes $(\Sigma^*, +, \cdot)$ a semiring.

Generalization

Since this doesn’t really use the structure of regular languages to prove that it is a semiring, then we can further generalize this. As it turns out, $(\mathbf{Set}, \cup, \times_\sim)$ is a semiring. So, of course a subset of $\mathbf{Set}$ that is closed under $\cup$ and $\times$ would also be a semiring.