|
|
Line 1: |
Line 1: |
| {{for|natural language that is regulated|List of language regulators}}
| | == 他の人を入れて == |
| {{Cleanup|date=December 2008}}
| |
| In [[theoretical computer science]] and [[formal language theory]], a '''regular language''' is a [[formal language]] that can be expressed using a [[regular expression]]. (Note that the "regular expression" features provided with many programming languages are [[Regular_expression#Patterns_for_non-regular_languages|augmented with features]] that make them capable of recognizing languages that can not be expressed by the formal regular expressions (''as formally defined below'').)
| |
|
| |
|
| Alternatively, a regular language can be defined as a language recognized by a [[finite automaton]].
| | 'その後、単純な上、私や追跡、または車では、巣を横たわっ後に発見、犯罪を犯し始め、犯人は1曹操は、車を見るために巣を横たわって、この時点で懸念を聞いて停止し、確かにそれらのタイラント車のブラインドです見張り、私は、車の中で2山賊を押さゆう風水は、従事する人々にショックが唖然曹操「ビッグバン」ので、それは、彼を助けるために切望していた [http://www.dmwai.com/webalizer/kate-spade-7.html ケイトスペード バッグ 新作].... [http://www.dmwai.com/webalizer/kate-spade-0.html ケイトスペード バッグ 激安]..、その後、曹操の方法は、アウトハンギングフロントフードを開くために彼を目覚め、彼の銀行カードを押収したとパスワードの入力を要求 [http://www.dmwai.com/webalizer/kate-spade-8.html 財布 ケイトスペード]......調子で言う、間違って再び刺すためのナイフを押す [http://www.dmwai.com/webalizer/kate-spade-7.html ケイトスペード バッグ 新作]......大丈夫、それらの人はお金が、死の恐怖を持っており、確かに最終的には正直に教えてください」。<br>他の人を入れて<br>はちょうど犯罪を犯すの通常の過程をプレイするよう、より魅了聞いたが、裁判官に多くのものを追加し、私は犯罪を続けた:<br><br>」とすべての車のクーラーをケリが [http://www.dmwai.com/webalizer/kate-spade-9.html バッグ ケイトスペード]......私は公然とこのように、いくつかの8タイラント数のライセンスを行って歩いた[OK]を、あなたは被害者を航海することができ、最高の手と足のために上に置く、単に通過でああ、交通警察が停止していないが、私がしなければならない、単に被害者注入にそれをスローする場所を見つける |
| | 相关的主题文章: |
| | <ul> |
| | |
| | <li>[http://www.zensekiren.jp/cgi-bin/zensekisijbbs.cgi http://www.zensekiren.jp/cgi-bin/zensekisijbbs.cgi]</li> |
| | |
| | <li>[http://www.zgzmjsw.com/plus/feedback.php?aid=12 http://www.zgzmjsw.com/plus/feedback.php?aid=12]</li> |
| | |
| | <li>[http://aiyingfang.cn/bbs/showtopic-886770.aspx http://aiyingfang.cn/bbs/showtopic-886770.aspx]</li> |
| | |
| | </ul> |
|
| |
|
| In the [[Chomsky hierarchy]], regular languages are defined to be the languages that are generated by Type-3 grammars ([[regular grammar]]s).
| | == 'あなた人がこのニルヴァーナをかじる == |
|
| |
|
| Regular languages are very useful in input [[parsing]] and [[programming language]] design.
| | 罪の叫び [http://www.dmwai.com/webalizer/kate-spade-1.html ケイトスペード リボン バッグ]。<br><br>'あなた人がこのニルヴァーナをかじる?'マウスは怒って大声で尋ねた [http://www.dmwai.com/webalizer/kate-spade-15.html ケイトスペード クラッチバッグ]。<br><br>'あなたは親切好きあなたのように立つと思われる土壌の力、 [http://www.dmwai.com/webalizer/kate-spade-12.html kate spade 長財布]。の'私は犯罪に呪う。<br><br>失礼、そのいくつかの神秘的なスリの周りの注目を集めているが、密かに彼らのために喜んでいたとき、誰かの気晴らしですが、意外にそれは外の会場から駆けつけ、で大きなうめき声を泣いていた [http://www.dmwai.com/webalizer/kate-spade-8.html ケイトスペード ハンドバッグ]。「私の弟ナ、Qingeさて、あなたはニルヴァーナに行く、なぜこれほど......遠吠え遠吠えサンウ......あなたは死んだ人が私に行うことになってすることができますね......」<br><br>サウンドがこの赤ちゃんに催涙が来た鼻を見て、本当に家族のための同情とても悲しげだったホールを通して鳴り響いハウリング、ストレート泣い4を怖がらせた。確かに家族はすべての無限の同情の目に、彼を見て、ここにすべての人が死亡している [http://www.dmwai.com/webalizer/kate-spade-7.html ケイトスペードのバッグ]。<br><br>瞬間を歩いた入院患者に通じる廊下にフラッシュ、また振り返ったときに、いくつかのスリが1に手を伸ばしたことが、犯罪ウインクを見るために、罪が消えるよりも多くのマウスを移動し始めたリアンリアン涙白髪の中年の女性。<br><br>突然彼 |
| | | 相关的主题文章: |
| ==Formal definition==
| | <ul> |
| The collection of regular languages over an alphabet Σ is defined recursively as follows:
| | |
| * The empty language Ø is a regular language.
| | <li>[http://www.csp-shop.de/cgi-bin/cshop/front/shop_main.cgi http://www.csp-shop.de/cgi-bin/cshop/front/shop_main.cgi]</li> |
| * For each ''a'' ∈ Σ (''a'' belongs to Σ), the [[Singleton (mathematics)|singleton]] language {''a''} is a regular language.
| | |
| * If ''A'' and ''B'' are regular languages, then ''A'' ∪ ''B'' (union), ''A'' • ''B'' (concatenation), and ''A''* ([[Kleene star]]) are regular languages.
| | <li>[http://tpu-tcc.com/waza/bbs/cbbs.cgi http://tpu-tcc.com/waza/bbs/cbbs.cgi]</li> |
| * No other languages over Σ are regular.
| | |
| | | <li>[http://www.yy0536.com/plus/feedback.php?aid=704 http://www.yy0536.com/plus/feedback.php?aid=704]</li> |
| See [[Regular_expression#Formal_language_theory|regular expression]] for its syntax and semantics. Note that the above cases are in effect the defining rules of regular expression.
| | |
| | | </ul> |
| ;Examples
| |
| All finite languages are regular; in particular the [[empty string]] language {ε} = Ø* is regular. Other typical examples include the language consisting of all strings over the alphabet {''a'', ''b''} which contain an even number of ''a''s, or the language consisting of all strings of the form: several ''a''s followed by several ''b''s.
| |
| | |
| A simple example of a language that is not regular is the set of strings <math>\{a^nb^n\,\vert\; n\ge 0\}</math>.<ref>Eilenberg (1974), p. 16 (Example II, 2.8) and p. 25 (Example II, 5.2).</ref> Intuitively, it cannot be recognized with a finite automaton, since a finite automaton has finite memory and it cannot remember the exact number of a's. Techniques to prove this fact rigorously are given below.
| |
| | |
| ==Equivalence to other formalisms==
| |
| A regular language satisfies the following equivalent properties:
| |
| * it is the language accepted by a [[nondeterministic finite automaton]]
| |
| * it is the language accepted by a [[deterministic finite automaton]]
| |
| * it is the language accepted by an [[alternating finite automaton]]
| |
| * it can be generated by a [[regular grammar]]
| |
| * it can be generated by a [[prefix grammar]]
| |
| * it can be accepted by a read-only [[Turing machine]]
| |
| * it can be defined in [[monadic predicate calculus|monadic]] [[second-order logic]] ([[Büchi-Elgot-Trakhtenbrot theorem]]<ref>M. Weyer: Chapter 12 - Decidability of S1S and S2S, p. 219, Theorem 12.26. In: Erich Grädel, Wolfgang Thomas, Thomas Wilke (Eds.): Automata, Logics, and Infinite Games: A Guide to Current Research. Lecture Notes in Computer Science 2500, Springer 2002.</ref>)
| |
| * it is recognized by some finite [[monoid]], meaning it is the [[preimage]] of a subset of a finite monoid under a homomorphism from the free monoid on its alphabet (see [[Myhill–Nerode theorem]]).
| |
| | |
| The above properties are sometimes used as alternative definition of regular languages.
| |
| | |
| == Closure properties ==
| |
| The regular languages are [[closure (mathematics)|closed]] under the various operations, that is, if the languages ''K'' and ''L'' are regular, so is the result of the following operations:
| |
| | |
| * the set theoretic Boolean operations: [[union (set theory)|union]] <math>K \cup L</math>, [[intersection (set theory)|intersection]] <math>K \cap L</math>, and [[complement (set theory)|complement]] <math>\bar{L}</math>. From this also [[relative complement]] <math>K-L</math> follows.<ref name=Sal28>Salomaa (1981) p.28</ref>
| |
| * the regular operations: [[union (set theory)|union]] <math>K \cup L</math>, [[concatenation]] <math>K\circ L</math>, and [[Kleene star]] <math>L^*</math>.<ref name=Sal27>Salomaa (1981) p.27</ref>
| |
| * the [[abstract family of languages|trio]] operations: [[string homomorphism]], inverse string homomorphism, and intersection with regular languages. As a consequence they are closed under arbitrary [[finite state transducer|finite state transductions]], like [[right quotient|quotient]] <math>K / L</math> with a regular language. Even more, regular languages are closed under quotients with ''arbitrary'' languages: If L is regular then L/K is regular for any K.
| |
| * the reverse (or mirror image) <math>L^R</math>.
| |
| | |
| ==Deciding whether a language is regular==
| |
| [[Image:Chomsky-hierarchy.svg|thumb|250px|Regular language in classes of Chomsky hierarchy.]]
| |
| | |
| To locate the regular languages in the [[Chomsky hierarchy]], one notices that every regular language is [[Context free language|context-free]]. The converse is not true: for example the language consisting of all strings having the same number of ''a''<nowiki>'</nowiki>s as ''b''<nowiki>'</nowiki>s is context-free but not regular. To prove that a language such as this is not regular, one often uses the [[Myhill–Nerode theorem]] or the [[pumping lemma]] among other methods.<ref>[http://cs.stackexchange.com/questions/1031/how-to-prove-that-a-language-is-not-regular How to prove that a language is not regular?]</ref>
| |
| | |
| There are two purely algebraic approaches to define regular languages. If:
| |
| * Σ is a finite alphabet,
| |
| * Σ* denotes the [[free monoid]] over Σ consisting of all strings over Σ,
| |
| * ''f'' : Σ* → ''M'' is a [[monoid homomorphism]] where ''M'' is a ''finite'' monoid,
| |
| * ''S'' is a subset of ''M''
| |
| then the set <math>\{ w \in \Sigma^* \, | \, f(w) \in S \}</math> is regular. Every regular language arises in this fashion.
| |
| | |
| If ''L'' is any subset of Σ*, one defines an [[equivalence relation]] ~ (called the [[syntactic relation]]) on Σ* as follows: ''u'' ~ ''v'' is defined to mean
| |
| :''uw'' ∈ ''L'' if and only if ''vw'' ∈ ''L'' for all ''w'' ∈ Σ*
| |
| The language ''L'' is regular if and only if the number of equivalence classes of ~ is finite (A proof of this is provided in the article on the [[syntactic monoid]]). When a language is regular, then the number of equivalence classes is equal to the number of states of the [[DFA minimization|minimal deterministic finite automaton]] accepting ''L''.
| |
| | |
| A similar set of statements can be formulated for a monoid <math>M\subset\Sigma^*</math>. In this case, equivalence over ''M'' leads to the concept of a [[recognizable language]].
| |
| | |
| == Complexity results ==
| |
| | |
| In [[computational complexity theory]], the [[complexity class]] of all regular languages is sometimes referred to as '''REGULAR''' or '''REG''' and equals [[DSPACE]](O(1)), the [[decision problem]]s that can be solved in constant space (the space used is independent of the input size). '''REGULAR''' ≠ [[AC0|'''AC'''<sup>0</sup>]], since it (trivially) contains the parity problem of determining whether the number of 1 bits in the input is even or odd and this problem is not in '''AC'''<sup>0</sup>.<ref>M. Furst, J. B. Saxe, and M. Sipser. Parity, circuits, and the polynomial-time hierarchy. Math. Systems Theory, 17:13–27, 1984.</ref> On the other hand, '''REGULAR''' does not contain '''AC'''<sup>0</sup>, because the nonregular language of [[palindrome]]s, or the nonregular language <math>\{0^n 1^n : n \in \mathbb N\}</math> can both be recognized in '''AC'''<sup>0</sup>.<ref>{{cite book|last1=Cook|first1=Stephen|last2=Nguyen|first2=Phuong|title=Logical foundations of proof complexity|year=2010|publisher=Association for Symbolic Logic|location=Ithaca, NY|isbn=0-521-51729-X|pages=75|edition=1. publ.}}</ref>
| |
| | |
| If a language is ''not'' regular, it requires a machine with at least [[Big O notation|Ω]](log log ''n'') space to recognize (where ''n'' is the input size).<ref>J. Hartmanis, P. L. Lewis II, and R. E. Stearns. Hierarchies of memory-limited computations. ''Proceedings of the 6th Annual IEEE Symposium on Switching Circuit Theory and Logic Design'', pp. 179–190. 1965.</ref> In other words, DSPACE([[Big O notation|o]](log log ''n'')) equals the class of regular languages. In practice, most nonregular problems are solved by machines taking at least [[logarithmic space]].
| |
| | |
| ==Subclasses==
| |
| Important subclasses of regular languages include
| |
| * Finite languages - those containing only a finite number of words. These are regular languages, as one can create a [[regular expression]] that is the [[Union (set theory)|union]] of every word in the language.
| |
| * [[Star-free language]]s, those that can be described by a regular expression constructed from the empty symbol, letters, concatenation and all [[boolean operators]] including [[Complement (set theory)|complementation]] but not the [[Kleene star]]: this class includes all finite languages.<ref>{{cite book|editor=Jörg Flum, Erich Grädel, Thomas Wilke|title=Logic and automata: history and perspectives|year=2008|publisher=Amsterdam University Press|isbn=978-90-5356-576-6|url=http://www.lsv.ens-cachan.fr/Publis/PAPERS/PDF/DG-WT08.pdf|chapter=First-order definable languages|author=Volker Diekert, Paul Gastin|unused_data=chapter}}</ref>
| |
| * '''Cyclic languages''', satisfying the conditions <math>uv \in L \Leftrightarrow vu \in L</math> and <math>w \in L \Leftrightarrow w^n \in L</math>.<ref name=Honkala>{{cite journal | zbl=0675.68034 | last=Honkala | first=Juha | title=A necessary condition for the rationality of the zeta function of a regular language | journal=Theor. Comput. Sci. | volume=66 | number=3 | pages=341–347 | year=1989 }}</ref>
| |
| | |
| ==The number of words in a regular language==
| |
| Let <math>s_L(n)</math> denote the number of words of length <math>n</math> in <math>L</math>. The [[ordinary generating function]] for ''L'' is the [[formal power series]]
| |
| | |
| :<math>S_L(z) = \sum_{n \ge 0} s_L(n) z^n \ . </math>
| |
| | |
| The generating function of a language ''L'' is a [[rational function]] if ''L'' is regular.<ref name=Honkala/> Hence for any regular language <math>L</math> there exist an integer constant <math>n_0</math>, complex constants <math>\lambda_1,\,\ldots,\,\lambda_k</math> and complex polynomials <math>p_1(x),\,\ldots,\,p_k(x)</math>
| |
| such that for every <math>n \geq n_0</math> the number <math>s_L(n)</math> of words of length <math>n</math> in <math>L</math> is
| |
| <math>s_L(n)=p_1(n)\lambda_1^n+\dotsb+p_k(n)\lambda_k^n</math>.<ref>Flajolet & Sedgweick, section V.3.1, equation (13).</ref><ref>[http://cs.stackexchange.com/a/1048/55 Proof of theorem for irreducible DFAs]</ref><ref>http://cs.stackexchange.com/a/11333/683 Proof of theorem for arbitrary DFAs</ref><ref>[http://cs.stackexchange.com/q/1045/55 Number of words of a given length in a regular language]</ref> | |
| | |
| Thus, non-regularity of certain languages <math>L'</math> can be proved by counting the words of a given length in
| |
| <math>L'</math>. Consider, for example, the [[Dyck language]] of strings of balanced parentheses. The number of words of length <math>2n</math>
| |
| in the Dyck language is equal to the [[Catalan number]] <math>C_n\sim\frac{4^n}{n^{3/2}\sqrt{\pi}}</math>, which is not of the form <math>p(n)\lambda^n</math>,
| |
| witnessing the non-regularity of the Dyck language. Care must be taken since some of the eigenvalues <math>\lambda_i</math> could have the same magnitude. For example, the number of words of length <math>n</math> in the language of all even binary words is not of the form <math>p(n)\lambda^n</math>, but the number of words of even or odd length are of this form; the corresponding eigenvalues are <math>2,-2</math>. In general, for every regular language there exists a constant <math>d</math> such that for all <math>a</math>, the number of words of length <math>dm+a</math> is asymptotically <math>C_a m^{p_a} \lambda_a^m</math>.<ref>Flajolet & Sedgewick (2002, Theorem V.3)</ref>
| |
| | |
| The ''zeta function'' of a language ''L'' is<ref name=Honkala/>
| |
| | |
| :<math>\zeta_L(z) = \exp \left({ \sum_{n \ge 0} s_L(n) \frac{z^n}{n} }\right) \ . </math> | |
| | |
| The zeta function of a regular language is not in general rational, but that of a cyclic language is.<ref>{{cite journal | zbl=0797.68092 | last1=Berstel | first1=Jean | last2=Reutenauer | first1=Christophe | title=Zeta functions of formal languages | journal=Trans. Am. Math. Soc. | volume=321 | number=2 | pages=533–546 | year=1990 }}</ref>
| |
| | |
| ==Generalizations==
| |
| The notion of a regular language has been generalized to infinite words (see [[ω-automaton|ω-automata]]) and to trees (see [[tree automaton]]).
| |
| | |
| ==See also==
| |
| * [[Pumping lemma for regular languages]]
| |
| * [[Union of two regular languages]]
| |
| * [[Rational language]]
| |
| | |
| == References ==
| |
| | |
| {{Refbegin}}
| |
| | |
| * {{cite book |last1=Eilenberg |first1=Samuel |authorlink1=Samuel Eilenberg |title=Automata, Languages, and Machines. Volume A |url= |edition= |series=Pure and Applied Mathematics |volume=58 |year=1974 |publisher=Academic Press |location=New York |isbn= |zbl=0317.94045 }}
| |
| * {{cite book | first=Arto | last=Salomaa | authorlink=Arto Salomaa | title=Jewels of Formal Language Theory | publisher=Pitman Publishing | isbn=0-273-08522-0 | year=1981 | zbl=0487.68064 }}
| |
| * {{cite book | first=Michael | last=Sipser | authorlink = Michael Sipser | year = 1997 | title = [[Introduction to the Theory of Computation]] | publisher = PWS Publishing | isbn = 0-534-94728-X | zbl=1169.68300 }} Chapter 1: Regular Languages, pp. 31–90. Subsection "Decidable Problems Concerning Regular Languages" of section 4.1: Decidable Languages, pp. 152–155.
| |
| * Philippe Flajolet and Robert Sedgewick, ''[http://algo.inria.fr/flajolet/Publications/FlSe02.ps.gz Analytic Combinatorics: Symbolic Combinatorics.]'' Online book, 2002.
| |
| | |
| {{Refend}}
| |
| {{Reflist}}
| |
| | |
| ==External links==
| |
| * {{CZoo|Class REG|R#reg}}
| |
| | |
| {{Formal languages and grammars}}
| |
| | |
| [[Category:Formal languages]]
| |
| [[Category:Automata theory]]
| |