Misplaced Pages

Deterministic context-free language: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 23:23, 6 February 2015 edit95.107.208.222 (talk) Properties← Previous edit Latest revision as of 11:07, 29 October 2022 edit undoDynamicdispatch (talk | contribs)246 editsm Description: automatons -> automataTags: Mobile edit Mobile app edit Android app edit 
(33 intermediate revisions by 25 users not shown)
Line 1: Line 1:
In ], '''deterministic context-free languages''' ('''DCFL''') are a ] of ]s. They are the context-free languages that can be accepted by a ]. DCFLs are always unambiguous, meaning that they admit an ], but any (non-empty) DCFLs also admits ambiguous grammars. There are non-deterministic unambiguous CFLs, so DCFLs form a proper subset of unambiguous CFLs. In ], '''deterministic context-free languages''' ('''DCFL''') are a ] of ]s. They are the context-free languages that can be accepted by a ]. DCFLs are always unambiguous, meaning that they admit an ]. There are non-deterministic unambiguous CFLs, so DCFLs form a proper subset of unambiguous CFLs.


DCFLs are of great practical interest, as they can be parsed in linear time, and various restricted forms of DCFGs admit simple practical parsers. They are thus widely used throughout computer science. DCFLs are of great practical interest, as they can be parsed in ], and various restricted forms of DCFGs admit simple practical parsers. They are thus widely used throughout computer science.


==Description== ==Description==


The notion of the DCFL is closely related to the ] (DPDA). It is where the language power of a ] is reduced if we make it deterministic; the pushdown automaton becomes unable to choose between different state transition alternatives and as a consequence cannot recognize all context-free languages.<ref>{{cite book | last = ] | first = John |author2=] | title = ] | year = 1979 | publisher = Addison-Wesley | page = 233 }}</ref> ]s do not always generate a DCFL. For example, the language of even-length ]s on the alphabet of 0 and 1 has the unambiguous context-free grammar S → 0S0 | 1S1 | ε. An arbitrary string of this language cannot be parsed without reading all its letters first which means that a pushdown automaton has to try alternative state transitions to accommodate for the different possible lengths of a semi-parsed string. <ref>{{cite book | last = ] | first = John | coauthors = ] & ] | title = ] 2nd edition | year = 2001 | publisher = Addison-Wesley | pages = 249–253 }}</ref> The notion of the DCFL is closely related to the ] (DPDA). It is where the language power of ] is reduced to if we make them deterministic; the pushdown automata become unable to choose between different state-transition alternatives and as a consequence cannot recognize all context-free languages.<ref>{{cite book | last = Hopcroft | author-link = John Hopcroft | first = John |author2=Jeffrey Ullman |author2-link=Jeffrey Ullman | title = ] | year = 1979 | publisher = Addison-Wesley | page = 233 }}</ref> ]s do not always generate a DCFL. For example, the language of even-length ]s on the alphabet of 0 and 1 has the unambiguous context-free grammar S → 0S0 | 1S1 | ε. An arbitrary string of this language cannot be parsed without reading all its letters first, which means that a pushdown automaton has to try alternative state transitions to accommodate for the different possible lengths of a semi-parsed string.<ref>{{cite book | last = Hopcroft | author-link = John Hopcroft | first = John |author2=Rajeev Motwani |author2-link=Rajeev Motwani |author3=Jeffrey Ullman |author3-link=Jeffrey Ullman | title = ] | year = 2001 | publisher = Addison-Wesley | pages = 249–253 }}</ref>


==Properties== ==Properties==


Deterministic context-free languages can be recognized by a ] in polynomial time and ](log<sub>2</sup> ''n'') space; as a corollary, '''DCFL''' is a subset of the complexity class ''']'''.<ref>S. A. Cook. Deterministic CFL's are accepted simultaneously in polynomial time and log squared space. Proceedings of ACM STOC'79, pp. 338&ndash;345. 1979.</ref> The set of deterministic context-free languages is not closed under ] but is closed under ]. Deterministic context-free languages can be recognized by a ] in polynomial time and ](log<sup>2</sup> ''n'') space; as a corollary, '''DCFL''' is a subset of the complexity class ''']'''.<ref>{{cite conference |doi=10.1145/800135.804426 |title=Deterministic CFL's are accepted simultaneously in polynomial time and log squared space |book-title=Proceedings of the eleventh annual ] - STOC '79 |pages=338–345 |location=Atlanta |date=April 30 May 2, 1979 |last=Cook |first=Stephen A.|authorlink = Stephen A. Cook}}</ref>

The set of deterministic context-free languages is closed under the following operations:<ref name="Formal Languages and Applications">{{Cite book|title=Formal Languages and Applications|last1=Hoogeboom|first1=Hendrik|publisher=Springer-Verlag Berlin Heidelberg|year=2004|isbn=978-3-642-53554-3|pages=128|last2=Engelfriet|first2=Joost}}</ref>
*]
*]
*] with a regular language
*pre: pre(<math> L </math>) is the subset of all strings having a proper prefix that also belongs to <math> L </math>.
*min: min(<math> L </math>) is the subset of all strings that do not have a proper prefix in <math> L </math>.
*max: max(<math> L </math>) is the subset of all strings that are not the prefix of a longer string in <math> L </math>.

The set of deterministic context-free language is ''not'' closed under the following operations:<ref name="Formal Languages and Applications"/>
*]
*]
*]
*]
*]
*]


==Importance== ==Importance==


The languages of this class have great practical importance in computer science as they can be parsed much more efficiently than nondeterministic context-free languages. The complexity of the program and execution time of a deterministic pushdown automaton is vastly less than that of a nondeterministic one. In the naive implementation, the latter must make copies of the stack every time a nondeterministic step occurs. The best known algorithm to test membership in any context-free language is ], taking O(''n''<sup>2.378</sup>) time, where n is the length of the string. On the other hand, deterministic context-free languages can be accepted in O(''n'') time by a ].<ref>{{cite doi|10.1016/S0019-9958(65)90426-2}}</ref> This is very important for ] translation because many computer languages belong to this class of languages. The languages of this class have great practical importance in computer science as they can be parsed much more efficiently than nondeterministic context-free languages. The complexity of the program and execution time of a deterministic pushdown automaton is vastly less than that of a nondeterministic one. In the naive implementation, the latter must make copies of the stack every time a nondeterministic step occurs. The best known algorithm to test membership in any context-free language is ], taking O({{var|n}}<sup>2.378</sup>) time, where {{var|n}} is the length of the string. On the other hand, deterministic context-free languages can be accepted in O({{var|n}}) time by an ].<ref>{{Cite journal | last1 = Knuth | first1 = D. E. | author-link = Donald Knuth | title = On the translation of languages from left to right | doi = 10.1016/S0019-9958(65)90426-2 | journal = ] | volume = 8 | issue = 6 | pages = 607–639 | date = July 1965 | doi-access = free }}</ref> This is very important for ] translation because many computer languages belong to this class of languages.


==See also== ==See also==
Line 22: Line 38:


==References== ==References==
{{Reflist}}
<references/>


{{Formal languages and grammars}} {{Formal languages and grammars}}

Latest revision as of 11:07, 29 October 2022

In formal language theory, deterministic context-free languages (DCFL) are a proper subset of context-free languages. They are the context-free languages that can be accepted by a deterministic pushdown automaton. DCFLs are always unambiguous, meaning that they admit an unambiguous grammar. There are non-deterministic unambiguous CFLs, so DCFLs form a proper subset of unambiguous CFLs.

DCFLs are of great practical interest, as they can be parsed in linear time, and various restricted forms of DCFGs admit simple practical parsers. They are thus widely used throughout computer science.

Description

The notion of the DCFL is closely related to the deterministic pushdown automaton (DPDA). It is where the language power of pushdown automata is reduced to if we make them deterministic; the pushdown automata become unable to choose between different state-transition alternatives and as a consequence cannot recognize all context-free languages. Unambiguous grammars do not always generate a DCFL. For example, the language of even-length palindromes on the alphabet of 0 and 1 has the unambiguous context-free grammar S → 0S0 | 1S1 | ε. An arbitrary string of this language cannot be parsed without reading all its letters first, which means that a pushdown automaton has to try alternative state transitions to accommodate for the different possible lengths of a semi-parsed string.

Properties

Deterministic context-free languages can be recognized by a deterministic Turing machine in polynomial time and O(log n) space; as a corollary, DCFL is a subset of the complexity class SC.

The set of deterministic context-free languages is closed under the following operations:

  • complement
  • inverse homomorphism
  • right quotient with a regular language
  • pre: pre( L {\displaystyle L} ) is the subset of all strings having a proper prefix that also belongs to L {\displaystyle L} .
  • min: min( L {\displaystyle L} ) is the subset of all strings that do not have a proper prefix in L {\displaystyle L} .
  • max: max( L {\displaystyle L} ) is the subset of all strings that are not the prefix of a longer string in L {\displaystyle L} .

The set of deterministic context-free language is not closed under the following operations:

Importance

The languages of this class have great practical importance in computer science as they can be parsed much more efficiently than nondeterministic context-free languages. The complexity of the program and execution time of a deterministic pushdown automaton is vastly less than that of a nondeterministic one. In the naive implementation, the latter must make copies of the stack every time a nondeterministic step occurs. The best known algorithm to test membership in any context-free language is Valiant's algorithm, taking O(n) time, where n is the length of the string. On the other hand, deterministic context-free languages can be accepted in O(n) time by an LR(k) parser. This is very important for computer language translation because many computer languages belong to this class of languages.

See also

References

  1. Hopcroft, John; Jeffrey Ullman (1979). Introduction to automata theory, languages, and computation. Addison-Wesley. p. 233.
  2. Hopcroft, John; Rajeev Motwani; Jeffrey Ullman (2001). Introduction to automata theory, languages, and computation 2nd edition. Addison-Wesley. pp. 249–253.
  3. Cook, Stephen A. (April 30 – May 2, 1979). "Deterministic CFL's are accepted simultaneously in polynomial time and log squared space". Proceedings of the eleventh annual ACM Symposium on Theory of Computing - STOC '79. Atlanta. pp. 338–345. doi:10.1145/800135.804426.
  4. ^ Hoogeboom, Hendrik; Engelfriet, Joost (2004). Formal Languages and Applications. Springer-Verlag Berlin Heidelberg. p. 128. ISBN 978-3-642-53554-3.
  5. Knuth, D. E. (July 1965). "On the translation of languages from left to right". Information and Control. 8 (6): 607–639. doi:10.1016/S0019-9958(65)90426-2.
Automata theory: formal languages and formal grammars
Chomsky hierarchyGrammarsLanguagesAbstract machines
  • Type-0
  • Type-1
  • Type-2
  • Type-3
Each category of languages, except those marked by a , is a proper subset of the category directly above it. Any language in each category is generated by a grammar and by an automaton in the category in the same line.
Category: