Deterministic Context-Free Language

Overview

A deterministic pushdown automaton (DPDA) is a 6-tuple Q,Σ,Γ,δ,q0,F, where Q, Σ, Γ, and F are all finite sets, and

  1. Q is the set of states,
  2. Σ is the input alphabet,
  3. Γ is the stack alphabet,
  4. δ:Q×Σϵ×Γϵ(Q×Γϵ){} is the transition function,
  5. q0Q is the start state, and
  6. FQ is the set of accept states.

For every qQ, aΣ, and xΓ, exactly one of the values is not :

A language is called deterministic context-free if a DPDA recognizes it.

DPDAs are often described with two different acceptance modes: by final state and by empty stack. We assume acceptance by final state. Acceptance by empty stack is strictly less powerful, only recognizing prefix-free DCFLs.

Deterministic CFG

A deterministic context-free grammar (DCFG) is a CFG such that every valid string has a forced handle.

If we restrict our attention to prefix-free languages, they are equivalent to DPDAs in their descriptive power. By adding an endmarker to a language, we ensure the resulting language is prefix-free.

Dotted Rules

A dotted rule is a rule in a CFG augmented with a dot () between two of the symbols found on its RHS. For example, rule Bu1u2uk containing k symbols has k+1 dotted rules:

Bu1u2ukBu1u2ukBu1u2uk

DK-Test

Every CFG G has a corresponding NFA and DFA, typically denoted K and DK respectively, that can identify handles. That is, K and DK accept input w if and only if w is the prefix of some valid string v=wy and w ends with a handle of v. DK is constructed from K using the standard power set construction.

K's states correspond to the dotted rules of G. It has a special start state with an ϵ-move to S0u for every rule involving start variable S0. Subsequent transitions are of one of two forms:

The accept states are all Bu corresponding to a completed rule. They have no outgoing transitions.

Generalizations of the DK-test can be used to determine if a grammar is an LR(k) grammar or not. This is known as a DK-test with lookahead k or just DKk-test.

LR Grammar

An LR(k) grammar is a context-free grammar such that the handle of every valid string is forced by lookahead k.

LR(1) grammars are equivalent to DPDAs in power. For every k>1, an LR(k) grammar can be converted to a DPDA and hence is also equivalent to LR(1). For this reason, If k is omitted, it is assumed k=1.

Closure Operations

Let A and B be deterministic context free languages over alphabet Σ. Such languages are closed under the following:

Furthermore, the intersection of a DCFL with a regular language is deterministic context-free.

Powered by Forestry.md