kleene star
{{Short description|Unary operation on string sets}}
{{Use dmy dates|date=September 2022}}
In mathematical logic and theoretical computer science, the Kleene star (or Kleene operator or Kleene closure) is a unary operation on a set {{mvar|V}} to generate a set {{mvar|V*}} of all finite-length strings that are composed of zero or more repetitions of members from {{mvar|V}}. It was named after American mathematician Stephen Cole Kleene, who first introduced and widely used it to characterize automata for regular expressions. In mathematics, it is more commonly known as the free monoid construction.
Definition
Given a set ,
define
: (the set consists only of the empty string),
:
and define recursively the set
: for each
is called the -th power of , it is a shorthand for the concatenation of by itself times. That is, can be understood to be the set of all strings that can be represented as the concatenation of members from .
The definition of Kleene star on is{{cite book |last1=Fletcher |first1=Peter |last2=Hoyle |first2=Hughes |last3=Patty |first3=C. Wayne |date=1991 |title=Foundations of Discrete Mathematics |publisher=Brooks/Cole |isbn=0534923739 |page=656 |quote=The Kleene closure L* of L is defined to be .}}
:
Kleene plus
In some formal language studies, (e.g. AFL theory) a variation on the Kleene star operation called the Kleene plus is used. The Kleene plus omits the term in the above union. In other words, the Kleene plus on is
:
or
Examples
Example of Kleene star applied to a set of strings:
: {"ab","c"}* = { ε, "ab", "c", "abab", "abc", "cab", "cc", "ababab", "ababc", "abcab", "abcc", "cabab", "cabc", "ccab", "ccc", ...}.
Example of Kleene star applied to a set of strings without the prefix property:
: {"a","ab","b"}* = { ε, "a", "ab", "b", "aa", "aab", "aba", "abab", "abb", "ba", "bab", "bb", ...};
e.g. the string "aab" can be obtained in several different ways. The Sardinas-Patterson algorithm can be used to check for a given V whether any member of V* can be obtained in more than one way.
Example of Kleene and Kleene plus applied to a set of characters:
: {"a", "b", "c"}* = { ε, "a", "b", "c", "aa", "ab", "ac", "ba", "bb", "bc", "ca", "cb", "cc", "aaa", "aab", ...}.
: {"a", "b", "c"}+ = { "a", "b", "c", "aa", "ab", "ac", "ba", "bb", "bc", "ca", "cb", "cc", "aaa", "aab", ...}.
Properties
- If is any finite or countably infinite set, then is a countably infinite set.{{cite web |author=Nayuki Minase |date=10 May 2011 |title=Countable sets and Kleene star |work=Project Nayuki |url=http://www.nayuki.io/page/countable-sets-and-kleene-star |access-date=11 January 2012}} As a result, each formal language over a finite or countably infinite alphabet is countable, since it is a subset of the countably infinite set .
- , which means that the Kleene star operator is an idempotent unary operator, as for every .
- , if is either the empty set ∅ or the singleton set .
Generalization
Strings form a monoid with concatenation as the binary operation and ε the identity element. In addition to strings, the Kleene star is defined for any monoid.
More precisely, let (M, ⋅) be a monoid, and S ⊆ M. Then S* is the smallest submonoid of M containing S; that is, S* contains the neutral element of M, the set S, and is such that if x,y ∈ S*, then x⋅y ∈ S*.
Furthermore, the Kleene star is generalized by including the *-operation (and the union) in the algebraic structure itself by the notion of complete star semiring.{{cite book |last1=Droste |first1=M. |last2=Kuich |first2=W. |date=2009 |title=Handbook of Weighted Automata |url=https://archive.org/details/handbookweighted00dros |url-access=limited |chapter=Chapter 1: Semirings and Formal Power Series |series=Monographs in Theoretical Computer Science |publisher=Springer |doi=10.1007/978-3-642-01492-5_1 |isbn=978-3-642-01491-8 |page=[https://archive.org/details/handbookweighted00dros/page/n23 9]}}
See also
Notes
{{reflist|group=note|refs=
It is called "strings" for historical reasons, since Kleene invented it in the context of automata theory, but the idea has been generalized such that each symbol in a string is not necessarily a single character {{Crossreference|selfref=no|(see {{Section link|#Generalization}})}}.
}}
References
{{Reflist}}
Further reading
- {{cite book |last1=Hopcroft |first1=John E. |author-link1=John Hopcroft |last2=Ullman |first2=Jeffrey D. |author-link2=Jeffrey Ullman |date=1979 |title=Introduction to Automata Theory, Languages, and Computation |title-link=Introduction to Automata Theory, Languages, and Computation |edition=1st |publisher=Addison-Wesley}}