# Chapter 2: Context-Free Languages

## For Your Enjoyment

- Grammar specification for Python.

## Chapter 2.4, Deterministic Context-Free Languages

### Deterministic Pushdown Automaton

A DPDA is a 6-tuple (Q, Σ, Γ, δ, q_{0}, F)
where

- Q is a finite set of states,
- Σ is a finite input alphabet,
- Γ is a finite stack alphabet,
- δ: Q × Σ
_{ε} ×
Γ_{ε} → (Q × Γ_{ε})
∪ {∅} is the transition function,
- q
_{0} ∈ Q is the start state, and
- F ⊆ Q is the finite set of accept states

A PDA is **deterministic** if it has at most one possible
move in any configuration.

### Deterministic Context-Free Language

The language of a DPDA is called a DCFL.

### Active Learning Problems

- Create a DPDA for A = {strings of balanced brackets over {[,]}* }
or make an argument as to why it is not possible.
- Create a DPDA for B = {ww
^{R} | {0,1}* } or make
an argument as to why it is not possible.

## More About Nondeterministic Context-Free Languages

### Properties

- CFLs are closed under union.
- CFLS are closed under concatenation.
- CFLs are closed under the Kleene star operation.
- CFLS are NOT closed under intersection.
- CFLS are NOT closed under complementation.

### Lecture Problem

Describe a general procedure for creating a CFG that
captures the union of two CFGs.

### Active Learning Problems

- Describe a general procedure for creating a CFG that
captures the concatenation of two CFGs.
- Make a convincing argument that CFGs are not closed under intersection.
- Make a convincing argument that CFGs are not closed under complementation.