In
mathematics, a Kleene algebra ( ; named after
Stephen Cole Kleene
Stephen Cole Kleene ( ; January 5, 1909 – January 25, 1994) was an American mathematician. One of the students of Alonzo Church, Kleene, along with Rózsa Péter, Alan Turing, Emil Post, and others, is best known as a founder of the branch of ...
) is an idempotent (and thus partially ordered)
semiring
In abstract algebra, a semiring is an algebraic structure similar to a ring, but without the requirement that each element must have an additive inverse.
The term rig is also used occasionally—this originated as a joke, suggesting that rigs ar ...
endowed with a
closure operator In mathematics, a closure operator on a set ''S'' is a function \operatorname: \mathcal(S)\rightarrow \mathcal(S) from the power set of ''S'' to itself that satisfies the following conditions for all sets X,Y\subseteq S
:
Closure operators are de ...
.
It generalizes the operations known from
regular expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s.
Definition
Various inequivalent definitions of Kleene algebras and related structures have been given in the literature. Here we will give the definition that seems to be the most common nowadays.
A Kleene algebra is a
set
Set, The Set, SET or SETS may refer to:
Science, technology, and mathematics Mathematics
*Set (mathematics), a collection of elements
*Category of sets, the category whose objects and morphisms are sets and total functions, respectively
Electro ...
''A'' together with two
binary operations + : ''A'' × ''A'' → ''A'' and · : ''A'' × ''A'' → ''A'' and one function
* : ''A'' → ''A'', written as ''a'' + ''b'', ''ab'' and ''a''
* respectively, so that the following axioms are satisfied.
*
Associativity
In mathematics, the associative property is a property of some binary operations, which means that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement ...
of + and ·: ''a'' + (''b'' + ''c'') = (''a'' + ''b'') + ''c'' and ''a''(''bc'') = (''ab'')''c'' for all ''a'', ''b'', ''c'' in ''A''.
*
Commutativity of +: ''a'' + ''b'' = ''b'' + ''a'' for all ''a'', ''b'' in ''A''
*
Distributivity
In mathematics, the distributive property of binary operations generalizes the distributive law, which asserts that the equality
x \cdot (y + z) = x \cdot y + x \cdot z
is always true in elementary algebra.
For example, in elementary arithmeti ...
: ''a''(''b'' + ''c'') = (''ab'') + (''ac'') and (''b'' + ''c'')''a'' = (''ba'') + (''ca'') for all ''a'', ''b'', ''c'' in ''A''
*
Identity element
In mathematics, an identity element, or neutral element, of a binary operation operating on a set is an element of the set that leaves unchanged every element of the set when the operation is applied. This concept is used in algebraic structures su ...
s for + and ·: There exists an element 0 in ''A'' such that for all ''a'' in ''A'': ''a'' + 0 = 0 + ''a'' = ''a''. There exists an element 1 in ''A'' such that for all ''a'' in ''A'': ''a''1 = 1''a'' = ''a''.
*
Annihilation
In particle physics, annihilation is the process that occurs when a subatomic particle collides with its respective antiparticle to produce other particles, such as an electron colliding with a positron to produce two photons. The total energy ...
by 0: ''a''0 = 0''a'' = 0 for all ''a'' in ''A''.
The above axioms define a
semiring
In abstract algebra, a semiring is an algebraic structure similar to a ring, but without the requirement that each element must have an additive inverse.
The term rig is also used occasionally—this originated as a joke, suggesting that rigs ar ...
. We further require:
* + is
idempotent
Idempotence (, ) is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application. The concept of idempotence arises in a number of pl ...
: ''a'' + ''a'' = ''a'' for all ''a'' in ''A''.
It is now possible to define a
partial order
In mathematics, especially order theory, a partially ordered set (also poset) formalizes and generalizes the intuitive concept of an ordering, sequencing, or arrangement of the elements of a set. A poset consists of a set together with a bina ...
≤ on ''A'' by setting ''a'' ≤ ''b''
if and only if
In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false.
The connective is b ...
''a'' + ''b'' = ''b'' (or equivalently: ''a'' ≤ ''b'' if and only if there exists an ''x'' in ''A'' such that ''a'' + ''x'' = ''b''; with any definition, ''a'' ≤ ''b'' ≤ ''a'' implies ''a'' = ''b''). With this order we can formulate the last four axioms about the operation
*:
* 1 + ''a''(''a''
*) ≤ ''a''
* for all ''a'' in ''A''.
* 1 + (''a''
*)''a'' ≤ ''a''
* for all ''a'' in ''A''.
* if ''a'' and ''x'' are in ''A'' such that ''ax'' ≤ ''x'', then ''a''
*''x'' ≤ ''x''
* if ''a'' and ''x'' are in ''A'' such that ''xa'' ≤ ''x'', then ''x''(''a''
*) ≤ ''x''
Intuitively, one should think of ''a'' + ''b'' as the "union" or the "least upper bound" of ''a'' and ''b'' and of ''ab'' as some multiplication which is
monotonic
In mathematics, a monotonic function (or monotone function) is a function between ordered sets that preserves or reverses the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of ord ...
, in the sense that ''a'' ≤ ''b'' implies ''ax'' ≤ ''bx''. The idea behind the star operator is ''a''
* = 1 + ''a'' + ''aa'' + ''aaa'' + ... From the standpoint of
programming language theory, one may also interpret + as "choice", · as "sequencing" and
* as "iteration".
Examples
Let Σ be a finite set (an "alphabet") and let ''A'' be the set of all
regular expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s over Σ. We consider two such regular expressions equal if they describe the same
language
Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of ...
. Then ''A'' forms a Kleene algebra. In fact, this is a
free Kleene algebra in the sense that any equation among regular expressions follows from the Kleene algebra axioms and is therefore valid in every Kleene algebra.
Again let Σ be an alphabet. Let ''A'' be the set of all
regular language
In theoretical computer science and formal language theory, a regular language (also called a rational language) is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to ...
s over Σ (or the set of all
context-free language
In formal language theory, a context-free language (CFL) is a language generated by a context-free grammar (CFG).
Context-free languages have many applications in programming languages, in particular, most arithmetic expressions are generated by ...
s over Σ; or the set of all
recursive language
In mathematics, logic and computer science, a formal language (a set of finite sequences of symbols taken from a fixed alphabet) is called recursive if it is a recursive subset of the set of all possible finite sequences over the alphabet of the ...
s over Σ; or the set of ''all'' languages over Σ). Then the
union
Union commonly refers to:
* Trade union, an organization of workers
* Union (set theory), in mathematics, a fundamental operation on sets
Union may also refer to:
Arts and entertainment
Music
* Union (band), an American rock group
** ''Un ...
(written as +) and the
concatenation
In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalisations of concatenat ...
(written as ·) of two elements of ''A'' again belong to ''A'', and so does the
Kleene star
In mathematical logic and computer science, the Kleene star (or Kleene operator or Kleene closure) is a unary operation, either on sets of strings or on sets of symbols or characters. In mathematics,
it is more commonly known as the free monoid ...
operation applied to any element of ''A''. We obtain a Kleene algebra ''A'' with 0 being the
empty set and 1 being the set that only contains the
empty string
In formal language theory, the empty string, or empty word, is the unique string of length zero.
Formal theory
Formally, a string is a finite, ordered sequence of characters such as letters, digits or spaces. The empty string is the special cas ...
.
Let ''M'' be a
monoid
In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0.
Monoid ...
with identity element ''e'' and let ''A'' be the set of all
subsets of ''M''. For two such subsets ''S'' and ''T'', let ''S'' + ''T'' be the union of ''S'' and ''T'' and set ''ST'' = . ''S''
* is defined as the submonoid of ''M'' generated by ''S'', which can be described as ∪ ''S'' ∪ ''SS'' ∪ ''SSS'' ∪ ... Then ''A'' forms a Kleene algebra with 0 being the empty set and 1 being . An analogous construction can be performed for any small
category
Category, plural categories, may refer to:
Philosophy and general uses
*Categorization, categories in cognitive science, information science and generally
* Category of being
* ''Categories'' (Aristotle)
* Category (Kant)
* Categories (Peirce) ...
.
The
linear subspaces of a unital
algebra over a field form a Kleene algebra. Given linear subspaces ''V'' and ''W'', define ''V'' + ''W'' to be the sum of the two subspaces, and 0 to be the trivial subspace . Define , the
linear span of the product of vectors from ''V'' and ''W'' respectively. Define , the span of the unit of the algebra. The closure of ''V'' is the
direct sum of all powers of ''V''.
Suppose ''M'' is a set and ''A'' is the set of all
binary relations on ''M''. Taking + to be the union, · to be the composition and
* to be the
reflexive transitive closure
In mathematics, a subset of a given set is closed under an operation of the larger set if performing that operation on members of the subset always produces a member of that subset. For example, the natural numbers are closed under addition, but n ...
, we obtain a Kleene algebra.
Every
Boolean algebra
In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas i ...
with operations
and
turns into a Kleene algebra if we use
for +,
for · and set ''a''
* = 1 for all ''a''.
A quite different Kleene algebra can be used to implement the
Floyd–Warshall algorithm
In computer science, the Floyd–Warshall algorithm (also known as Floyd's algorithm, the Roy–Warshall algorithm, the Roy–Floyd algorithm, or the WFI algorithm) is an algorithm for finding shortest paths in a directed weighted graph with p ...
, computing the
shortest path's length for every two vertices of a
weighted directed graph, by
Kleene's algorithm In theoretical computer science, in particular in formal language theory, Kleene's algorithm transforms a given nondeterministic finite automaton (NFA) into a regular expression.
Together with other conversion algorithms, it establishes the equival ...
, computing a regular expression for every two states of a
deterministic finite automaton
In the theory of computation, a branch of theoretical computer science, a deterministic finite automaton (DFA)—also known as deterministic finite acceptor (DFA), deterministic finite-state machine (DFSM), or deterministic finite-state autom ...
.
Using the
extended real number line, take ''a'' + ''b'' to be the minimum of ''a'' and ''b'' and ''ab'' to be the ordinary sum of ''a'' and ''b'' (with the sum of +∞ and −∞ being defined as +∞). ''a''
* is defined to be the real number zero for nonnegative ''a'' and −∞ for negative ''a''. This is a Kleene algebra with zero element +∞ and one element the real number zero.
A weighted directed graph can then be considered as a deterministic finite automaton, with each transition labelled by its weight.
For any two graph nodes (automaton states), the regular expressions computed from Kleene's algorithm evaluates, in this particular Kleene algebra, to the shortest path length between the nodes.
Properties
Zero is the smallest element: 0 ≤ ''a'' for all ''a'' in ''A''.
The sum ''a'' + ''b'' is the
least upper bound
In mathematics, the infimum (abbreviated inf; plural infima) of a subset S of a partially ordered set P is a greatest element in P that is less than or equal to each element of S, if such an element exists. Consequently, the term ''greatest lo ...
of ''a'' and ''b'': we have ''a'' ≤ ''a'' + ''b'' and ''b'' ≤ ''a'' + ''b'' and if ''x'' is an element of ''A'' with ''a'' ≤ ''x'' and ''b'' ≤ ''x'', then ''a'' + ''b'' ≤ ''x''. Similarly, ''a''
1 + ... + ''a''
''n'' is the least upper bound of the elements ''a''
1, ..., ''a''
''n''.
Multiplication and addition are monotonic: if ''a'' ≤ ''b'', then
* ''a'' + ''x'' ≤ ''b'' + ''x'',
* ''ax'' ≤ ''bx'', and
* ''xa'' ≤ ''xb''
for all ''x'' in ''A''.
Regarding the star operation, we have
* 0
* = 1 and 1
* = 1,
* ''a'' ≤ ''b'' implies ''a''
* ≤ ''b''
* (monotonicity),
* ''a''
''n'' ≤ ''a''
* for every
natural number
In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country").
Numbers used for counting are called ''cardinal ...
''n'', where ''a''
''n'' is defined as ''n''-fold multiplication of ''a'',
* (''a''
*)(''a''
*) = ''a''
*,
* (''a''
*)
* = ''a''
*,
* 1 + ''a''(''a''
*) = ''a''
* = 1 + (''a''
*)''a'',
* ''ax'' = ''xb'' implies (''a''
*)''x'' = ''x''(''b''
*),
* ((''ab'')
*)''a'' = ''a''((''ba'')
*),
* (''a''+''b'')
* = ''a''
*(''b''(''a''
*))
*, and
* ''pq'' = 1 = ''qp'' implies ''q''(''a''
*)''p'' = (''qap'')
*.
If ''A'' is a Kleene algebra and ''n'' is a natural number, then one can consider the set M
''n''(''A'') consisting of all ''n''-by-''n''
matrices
Matrix most commonly refers to:
* ''The Matrix'' (franchise), an American media franchise
** ''The Matrix'', a 1999 science-fiction action film
** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
with entries in ''A''.
Using the ordinary notions of matrix addition and multiplication, one can define a unique
*-operation so that M
''n''(''A'') becomes a Kleene algebra.
History
Kleene introduced regular expressions and gave some of their algebraic laws.
Although he didn't define Kleene algebras, he asked for a decision procedure for equivalence of regular expressions.
Redko proved that no finite set of ''equational'' axioms can characterize the algebra of regular languages.
Salomaa gave complete axiomatizations of this algebra, however depending on problematic inference rules.
The problem of providing a complete set of axioms, which would allow derivation of all equations among regular expressions, was intensively studied by
John Horton Conway
John Horton Conway (26 December 1937 – 11 April 2020) was an English mathematician active in the theory of finite groups, knot theory, number theory, combinatorial game theory and coding theory. He also made contributions to many branches ...
under the name of ''regular algebras'', however, the bulk of his treatment was infinitary.
In 1981,
Kozen gave a complete infinitary equational deductive system for the algebra of regular languages.
In 1994, he gave the
above finite axiom system, which uses unconditional and conditional equalities (considering ''a'' ≤ ''b'' as an abbreviation for ''a'' + ''b'' = ''b''), and is equationally complete for the algebra of regular languages, that is, two regular expressions ''a'' and ''b'' denote the same language only if ''a'' = ''b'' follows from the
above axioms.
[ — An earlier version appeared as: ]
Generalization (or relation to other structures)
Kleene algebras are a particular case of
closed semirings, also called
quasi-regular semirings or
Lehmann semirings, which are semirings in which every element has at least one quasi-inverse satisfying the equation: ''a''* = ''aa''* + 1 = ''a''*''a'' + 1. This quasi-inverse is not necessarily unique.
In a Kleene algebra, ''a''* is the least solution to the
fixpoint
A fixed point (sometimes shortened to fixpoint, also known as an invariant point) is a value that does not change under a given transformation. Specifically, in mathematics, a fixed point of a function is an element that is mapped to itself by th ...
equations: ''X'' = ''aX'' + 1 and ''X'' = ''Xa'' + 1.
Closed semirings and Kleene algebras appear in
algebraic path problems, a generalization of the
shortest path
In graph theory, the shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized.
The problem of finding the shortest path between ...
problem.
See also
*
Action algebra
*
Algebraic structure
*
Kleene star
In mathematical logic and computer science, the Kleene star (or Kleene operator or Kleene closure) is a unary operation, either on sets of strings or on sets of symbols or characters. In mathematics,
it is more commonly known as the free monoid ...
*
Regular expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
*
Star semiring
*
Valuation algebra
The term "information algebra" refers to mathematical techniques of information processing. Classical information theory goes back to Claude Shannon. It is a theory of information transmission, looking at communication and storage. However, it has ...
Notes and references
*
Further reading
* {{cite book, author=Peter Höfner, title=Algebraic Calculi for Hybrid Systems, url=https://books.google.com/books?id=40vn5XIMAtwC, year=2009, publisher=BoD – Books on Demand, isbn=978-3-8391-2510-6, pages=10–13 The introduction of this book reviews advances in the field of Kleene algebra made in the last 20 years, which are not discussed in the article above.
Algebraic structures
Algebraic logic
Formal languages
Many-valued logic