A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.wikipedia.org/wiki/Kleene_star below:

Kleene star - Wikipedia

From Wikipedia, the free encyclopedia

Unary operation on string sets

In formal language theory, the Kleene star (or Kleene operator or Kleene closure) refer to two related unary operations, that can be applied either to an alphabet of symbols or to a formal language, a set of strings (finite sequences of symbols).

The Kleene star operator on an alphabet V generates the set V* of all finite-length strings over V,[note 1] that is, finite sequences whose elements belong to V; in mathematics, it is more commonly known as the free monoid construction. The Kleene star operator on a language L generates another language L*, the set of all strings that can be obtained as a concatenation of zero or more members of L. In both cases, repetitions are allowed.

The Kleene star operators are named after American mathematician Stephen Cole Kleene, who first introduced and widely used it to characterize automata for regular expressions.

Given an alphabet V {\displaystyle V} , define

V 0 = { ε } {\displaystyle V^{0}=\{\varepsilon \}} (the set consists only of the empty string),
V 1 = V , {\displaystyle V^{1}=V,}

and define recursively the set

V i + 1 = { w v : w ∈ V i  and  v ∈ V } {\displaystyle V^{i+1}=\{wv:w\in V^{i}{\text{ and }}v\in V\}} for each i > 0 , {\displaystyle i>0,}

where w v {\displaystyle wv} denotes the string obtained by appending the single character v {\displaystyle v} to the end of w {\displaystyle w} . Here, V i {\displaystyle V^{i}} can be understood to be the set of all strings of length exactly i {\displaystyle i} , with characters from V {\displaystyle V} .

The definition of Kleene star on V {\displaystyle V} is[1]

V ∗ = ⋃ i ≥ 0 V i = V 0 ∪ V 1 ∪ V 2 ∪ V 3 ∪ V 4 ∪ ⋯ . {\displaystyle V^{*}=\bigcup _{i\geq 0}V^{i}=V^{0}\cup V^{1}\cup V^{2}\cup V^{3}\cup V^{4}\cup \cdots .}

Given a language L {\displaystyle L} (any finite or infinite set of strings), define

L 0 = { ε } {\displaystyle L^{0}=\{\varepsilon \}} (the language consisting only of the empty string),
L 1 = L , {\displaystyle L^{1}=L,}

and define recursively the set

L i + 1 = { w v : w ∈ V i  and  v ∈ L } {\displaystyle L^{i+1}=\{wv:w\in V^{i}{\text{ and }}v\in L\}} for each i > 0 , {\displaystyle i>0,}

where w v {\displaystyle wv} denotes the string obtained by concatenating w {\displaystyle w} and v {\displaystyle v} . Here, V i {\displaystyle V^{i}} can be understood to be the set of all strings that can be obtained by concatenating exactly i {\displaystyle i} strings from L {\displaystyle L} , allowing repetitions.

The definition of Kleene star on L {\displaystyle L} is[2]

L ∗ = ⋃ i ≥ 0 L i = L 0 ∪ L 1 ∪ L 2 ∪ L 3 ∪ L 4 ∪ ⋯ . {\displaystyle L^{*}=\bigcup _{i\geq 0}L^{i}=L^{0}\cup L^{1}\cup L^{2}\cup L^{3}\cup L^{4}\cup \cdots .}

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 V 0 {\displaystyle V^{0}} or L 0 {\displaystyle L^{0}} term in the above unions. In other words, the Kleene plus on V {\displaystyle V} is

V + = ⋃ i ≥ 1 V i = V 1 ∪ V 2 ∪ V 3 ∪ ⋯ , {\displaystyle V^{+}=\bigcup _{i\geq 1}V^{i}=V^{1}\cup V^{2}\cup V^{3}\cup \cdots ,}

or

V + = V ∗ V . {\displaystyle V^{+}=V^{*}V.} [note 2]

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", ...};
In this example, the string "aab" can be obtained in two 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 (following the C programming language convention where a character is denoted by single quotes and a string is denoted by double quotes):

{'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", ...}.

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 SM. 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,yS*, then xyS*.

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.[3]

  1. ^ 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 (see § Generalization).
  2. ^ This equation holds because every member of V+ can be generated by first picking a member from V*, and then picking a member from V for appending. This two-step process does not generate ε since the second step never pick an ε.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4