Deterministic context-free language explained

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.[1] 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.[2]

Properties

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

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

L

) is the subset of all strings having a proper prefix that also belongs to

L

.

L

) is the subset of all strings that do not have a proper prefix in

L

.

L

) is the subset of all strings that are not the prefix of a longer string in

L

.

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

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(2.378) time, where is the length of the string. On the other hand, deterministic context-free languages can be accepted in O time by an LR parser.[5] This is very important for computer language translation because many computer languages belong to this class of languages.

See also

Notes and References

  1. Book: Hopcroft, John . John Hopcroft . Jeffrey Ullman . Jeffrey Ullman . . 1979 . Addison-Wesley . 233 .
  2. Book: Hopcroft, John . John Hopcroft . Rajeev Motwani . Rajeev Motwani . Jeffrey Ullman . Jeffrey Ullman . . 2001 . Addison-Wesley . 249–253 .
  3. 10.1145/800135.804426 . 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 . 338–345 . Atlanta . April 30 – May 2, 1979 . Cook . Stephen A.. Stephen A. Cook.
  4. Book: Formal Languages and Applications. Hoogeboom. Hendrik. Springer-Verlag Berlin Heidelberg. 2004. 978-3-642-53554-3. 128. Engelfriet. Joost.
  5. Knuth . D. E. . Donald Knuth . On the translation of languages from left to right . 10.1016/S0019-9958(65)90426-2 . . 8 . 6 . 607–639 . July 1965 . free .