# 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, Σ, Γ, δ, q0, F) where

1. Q is a finite set of states,
2. Σ is a finite input alphabet,
3. Γ is a finite stack alphabet,
4. δ: Q × Σε × Γε → (Q × Γε) ∪ {∅} is the transition function,
5. q0 ∈ Q is the start state, and
6. 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 = {wwR | {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.