8
Deterministic Context Free Languages Because the Nondeterministic CFLs are too wild and free.

Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

DeterministicContext Free Languages

Because the Nondeterministic CFLs are too wild and free.

Page 2: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

DCFLs OverviewWhat are they?

● Deterministic Variant of CFLs

● Recognize a smaller subset of languages than

CFLs

● Are NOT equivalent with CFLs (which is in

contrast to the NFA/DFA relationship)

● They are the most specialized, most difficult,

and most technical topic introduced thus far.

Why do they exist?

● Nondeterminism is computationally

expensive.

● Essential tool for parsers.

Let the hand-waving commence.

Page 3: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

ExamplesCFL Examples

1. {ww

r

| w ∈ Σ*}

2. {0n1n

| n ≥ 0}

3. {ai bj ck

| i, j, k ≥ 0 and

i =j or i =k}

DCFL Examples

1. {wzw

r

| w ∈ (Σ-{z})*}

2. {0n1n

| n ≥ 0}

3. {1ai bj ck

| i, j, k ≥ 0 and i =j } ∪{2ai bj ck

| i, j, k ≥ 0 and i =k}

Page 4: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

PDA VS DPDAPDA

M = (Q, Σ, Γ, δ, q

0

, F), where Q, Σ, Γ, and F are

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. q

0

∈ Q is the start state, and

6. F ⊆ Q is the set of accept states.

DPDA

M = (Q, Σ, Γ, δ, q

0

, F), where Q, Σ, Γ, and F are

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. q

0

∈ Q is the start state, and

6. F ⊆ Q is the set of accept states.

δ must satisfy the condition that:

∀ q ∈ Q, a ∈ Σ, and x ∈ Γ, exactly one of

δ(q, a, x), δ(q, a, ε), δ(q, ε, x), δ(q, ε, ε),

is not ∅.

Page 5: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

Lemmas and Theorems1. Every DPDA has an equivalent DPDA that always reads the entire input string.

a. Used to simplify technical discussions of later proofs.

2. The class of DCFLs is closed under complementation.

a. Implies some CFLs are not DCFLs.

b. Example: A = {ai bj ck

| i, j, k ≥ 0 and i ≠j or i ≠k} is a CFL, but complement isn’t, thus is not a DCFL.

3. DCFL’s aren’t closed under union, intersection, star, and reversal.

4. A is a DCFL iff A⊣ is a DCFL.

a. Deals with endmarked inputs and endmarked languages.

b. Essential for proving equivalence of DPDAs and DCFGs.

Page 6: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

Other Important IdeasDK Test

● The Pumping Lemma for DPDAs, just

without pumping.

● Requires bottom-up grammar parsing,

building DFAs for grammar rules, and a

blood sacrifice.

LR(K) Grammars

● Introduce lookahead.

● Requires more Theorems

● Make DPDAs more managable

● Allow for linear time processing of most

programming languages!

I’m Watching...

Page 7: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

Subject OverviewInsert some joke about seeing the

forest and trees and stuff...

NFA

DFA

RegEx

--------------

Pumping

Lemma 1

PDA

CFG

--------------

Pumping

Lemma 2

Turing Machines

Page 8: Deterministic Context Free Languagescpennycu/2019/assets/fall/TOC/12...DCFLs Overview What are they? Deterministic Variant of CFLs Recognize a smaller subset of languages than CFLs

Subject OverviewInsert some joke about seeing the

forest and trees and stuff...

NFA/DFA

RegEx

--------------

Pumping

Lemma 1

PDA/CFG

--------------

Pumping Lemma 2

Turing Machines

DPDA/DCFG

--------------

DK-Test

Is making fun of this tree a knock on wood?