Context Free Languages and Grammars Lecture 7 Wednesday, February - - PowerPoint PPT Presentation

context free languages and grammars
SMART_READER_LITE
LIVE PREVIEW

Context Free Languages and Grammars Lecture 7 Wednesday, February - - PowerPoint PPT Presentation

Algorithms & Models of Computation CS/ECE 374 B, Spring 2020 Context Free Languages and Grammars Lecture 7 Wednesday, February 12, 2020 L A T EXed: January 19, 2020 04:15 Miller, Hassanieh (UIUC) CS374 1 Spring 2020 1 / 44 Regular


slide-1
SLIDE 1

Algorithms & Models of Computation

CS/ECE 374 B, Spring 2020

Context Free Languages and Grammars

Lecture 7

Wednesday, February 12, 2020

L

AT

EXed: January 19, 2020 04:15 Miller, Hassanieh (UIUC) CS374 1 Spring 2020 1 / 44

slide-2
SLIDE 2

Regular Languages

Regular expressions allow us to describe/express a class of languages compactly and precisely. Equivalence with DFAs show the following: given any regular expression r there is a very efficient algorithm for solving the language recognition problem for L(r): given w ∈ Σ∗ is w ∈ L(r)?

Miller, Hassanieh (UIUC) CS374 2 Spring 2020 2 / 44

slide-3
SLIDE 3

Regular Languages

Regular expressions allow us to describe/express a class of languages compactly and precisely. Equivalence with DFAs show the following: given any regular expression r there is a very efficient algorithm for solving the language recognition problem for L(r): given w ∈ Σ∗ is w ∈ L(r)? In fact the running time of the algorithm is linear in |w|.

Miller, Hassanieh (UIUC) CS374 2 Spring 2020 2 / 44

slide-4
SLIDE 4

Regular Languages

Regular expressions allow us to describe/express a class of languages compactly and precisely. Equivalence with DFAs show the following: given any regular expression r there is a very efficient algorithm for solving the language recognition problem for L(r): given w ∈ Σ∗ is w ∈ L(r)? In fact the running time of the algorithm is linear in |w|. Disadvantage of regular expressions/languages:

Miller, Hassanieh (UIUC) CS374 2 Spring 2020 2 / 44

slide-5
SLIDE 5

Regular Languages

Regular expressions allow us to describe/express a class of languages compactly and precisely. Equivalence with DFAs show the following: given any regular expression r there is a very efficient algorithm for solving the language recognition problem for L(r): given w ∈ Σ∗ is w ∈ L(r)? In fact the running time of the algorithm is linear in |w|. Disadvantage of regular expressions/languages: too simple and cannot express interesting features such as balanced parenthesis that we need in programming languages. No recursion allowed even in limited form.

Miller, Hassanieh (UIUC) CS374 2 Spring 2020 2 / 44

slide-6
SLIDE 6

Language classes: Chomsky Hierarchy

Generative models for languages based on grammars.

Regular Context Free Context Sensitive Recursively Enumerable All

Miller, Hassanieh (UIUC) CS374 3 Spring 2020 3 / 44

slide-7
SLIDE 7

Chomsky Hierarchy and Machines

For each class one can define a corresponding class of machines.

Regular Context Free Context Sensitive Recursively Enumerable All

DFA PDA TM LBA

Miller, Hassanieh (UIUC) CS374 4 Spring 2020 4 / 44

slide-8
SLIDE 8

Regular vs. Context Free Languages

Regular Languages: Built from strings using:

1

Sequencing

2

Branching

3

Repetition

Miller, Hassanieh (UIUC) CS374 5 Spring 2020 5 / 44

slide-9
SLIDE 9

Regular vs. Context Free Languages

Regular Languages: Built from strings using:

1

Sequencing

2

Branching

3

Repetition Context Free Languages: Built from strings using:

1

Sequencing

2

Branching

3

Recursion

Miller, Hassanieh (UIUC) CS374 5 Spring 2020 5 / 44

slide-10
SLIDE 10

What stack got to do with it?

What’s a stack but a second hand memory?

1

DFA/NFA/Regular expressions. ≡ constant memory computation.

2

Turing machines DFA/NFA + unbounded memory. ≡ a standard computer/program.

Miller, Hassanieh (UIUC) CS374 6 Spring 2020 6 / 44

slide-11
SLIDE 11

What stack got to do with it?

What’s a stack but a second hand memory?

1

DFA/NFA/Regular expressions. ≡ constant memory computation.

2

NFA + stack ≡ context free grammars (CFG).

3

Turing machines DFA/NFA + unbounded memory. ≡ a standard computer/program.

Miller, Hassanieh (UIUC) CS374 6 Spring 2020 6 / 44

slide-12
SLIDE 12

What stack got to do with it?

What’s a stack but a second hand memory?

1

DFA/NFA/Regular expressions. ≡ constant memory computation.

2

NFA + stack ≡ context free grammars (CFG).

3

Turing machines DFA/NFA + unbounded memory. ≡ a standard computer/program. ≡ NFA with two stacks.

Miller, Hassanieh (UIUC) CS374 6 Spring 2020 6 / 44

slide-13
SLIDE 13

Programming Language Design

Question: What is a valid C program? Or a Python program? Question: Given a string w what is an algorithm to check whether w is a valid C program? The parsing problem.

Miller, Hassanieh (UIUC) CS374 7 Spring 2020 7 / 44

slide-14
SLIDE 14

Context Free Languages and Grammars

Programming Language Specification Parsing Natural language understanding Generative model giving structure . . . CFLs provide a good balance between expressivity and tractability. Limited form of recursion.

Miller, Hassanieh (UIUC) CS374 8 Spring 2020 8 / 44

slide-15
SLIDE 15

Programming Languages

Miller, Hassanieh (UIUC) CS374 9 Spring 2020 9 / 44

slide-16
SLIDE 16

Natural Language Processing

Miller, Hassanieh (UIUC) CS374 10 Spring 2020 10 / 44

slide-17
SLIDE 17

Models of Growth

L-systems http://www.kevs3d.co.uk/dev/lsystems/

Miller, Hassanieh (UIUC) CS374 11 Spring 2020 11 / 44

slide-18
SLIDE 18

Kolam drawing generated by grammar

Miller, Hassanieh (UIUC) CS374 12 Spring 2020 12 / 44

slide-19
SLIDE 19

Context Free Grammar (CFG) Definition

Definition

A CFG is a quadruple G = (V , T, P, S) V is a finite set of non-terminal symbols G =

  • Variables,

Terminals, Productions, Start var

  • Miller, Hassanieh (UIUC)

CS374 13 Spring 2020 13 / 44

slide-20
SLIDE 20

Context Free Grammar (CFG) Definition

Definition

A CFG is a quadruple G = (V , T, P, S) V is a finite set of non-terminal symbols T is a finite set of terminal symbols (alphabet) G =

  • Variables,

Terminals, Productions, Start var

  • Miller, Hassanieh (UIUC)

CS374 13 Spring 2020 13 / 44

slide-21
SLIDE 21

Context Free Grammar (CFG) Definition

Definition

A CFG is a quadruple G = (V , T, P, S) V is a finite set of non-terminal symbols T is a finite set of terminal symbols (alphabet) P is a finite set of productions, each of the form A → α where A ∈ V and α is a string in (V ∪ T)∗. Formally, P ⊂ V × (V ∪ T)∗. G =

  • Variables,

Terminals, Productions, Start var

  • Miller, Hassanieh (UIUC)

CS374 13 Spring 2020 13 / 44

slide-22
SLIDE 22

Context Free Grammar (CFG) Definition

Definition

A CFG is a quadruple G = (V , T, P, S) V is a finite set of non-terminal symbols T is a finite set of terminal symbols (alphabet) P is a finite set of productions, each of the form A → α where A ∈ V and α is a string in (V ∪ T)∗. Formally, P ⊂ V × (V ∪ T)∗. S ∈ V is a start symbol G =

  • Variables,

Terminals, Productions, Start var

  • Miller, Hassanieh (UIUC)

CS374 13 Spring 2020 13 / 44

slide-23
SLIDE 23

Example

V = {S} T = {a, b} P = {S → ǫ | a | b | aSa | bSb} (abbrev. for S → ǫ, S → a, S → b, S → aSa, S → bSb)

Miller, Hassanieh (UIUC) CS374 14 Spring 2020 14 / 44

slide-24
SLIDE 24

Example

V = {S} T = {a, b} P = {S → ǫ | a | b | aSa | bSb} (abbrev. for S → ǫ, S → a, S → b, S → aSa, S → bSb) S aSa abSba abbSbba abb b bba

Miller, Hassanieh (UIUC) CS374 14 Spring 2020 14 / 44

slide-25
SLIDE 25

Example

V = {S} T = {a, b} P = {S → ǫ | a | b | aSa | bSb} (abbrev. for S → ǫ, S → a, S → b, S → aSa, S → bSb) S aSa abSba abbSbba abb b bba What strings can S generate like this?

Miller, Hassanieh (UIUC) CS374 14 Spring 2020 14 / 44

slide-26
SLIDE 26

Example formally...

V = {S} T = {a, b} P = {S → ǫ | a | b | aSa | bSb} (abbrev. for S → ǫ, S → a, S → b, S → aSa, S → bSb) G =       {S}, {a, b},            S → ǫ, S → a, S → b S → aSa S → bSb            S      

Miller, Hassanieh (UIUC) CS374 15 Spring 2020 15 / 44

slide-27
SLIDE 27

Palindromes

Madam in Eden I’m Adam Dog doo? Good God! Dogma: I am God. A man, a plan, a canal, Panama Are we not drawn onward, we few, drawn onward to new era? Doc, note: I dissent. A fast never prevents a fatness. I diet on cod. http://www.palindromelist.net

Miller, Hassanieh (UIUC) CS374 16 Spring 2020 16 / 44

slide-28
SLIDE 28

Examples

L = {0n1n | n ≥ 0}

Miller, Hassanieh (UIUC) CS374 17 Spring 2020 17 / 44

slide-29
SLIDE 29

Examples

L = {0n1n | n ≥ 0} S → ǫ | 0S1

Miller, Hassanieh (UIUC) CS374 17 Spring 2020 17 / 44

slide-30
SLIDE 30

Notation and Convention

Let G = (V , T, P, S) then a, b, c, d, . . . , in T (terminals) A, B, C, D, . . . , in V (non-terminals) u, v, w, x, y, . . . in T ∗ for strings of terminals α, β, γ, . . . in (V ∪ T)∗ X, Y , X in V ∪ T

Miller, Hassanieh (UIUC) CS374 18 Spring 2020 18 / 44

slide-31
SLIDE 31

“Derives” relation

Formalism for how strings are derived/generated

Definition

Let G = (V , T, P, S) be a CFG. For strings α1, α2 ∈ (V ∪ T)∗ we say α1 derives α2 denoted by α1 G α2 if there exist strings β, γ, δ in (V ∪ T)∗ such that α1 = βAδ α2 = βγδ A → γ is in P. Examples: S ǫ, S 0S1, 0S1 00S11, 0S1 01.

Miller, Hassanieh (UIUC) CS374 19 Spring 2020 19 / 44

slide-32
SLIDE 32

“Derives” relation continued

Definition

For integer k ≥ 0, α1 k α2 inductive defined: α1 0 α2 if α1 = α2 α1 k α2 if α1 β1 and β1 k−1 α2.

Miller, Hassanieh (UIUC) CS374 20 Spring 2020 20 / 44

slide-33
SLIDE 33

“Derives” relation continued

Definition

For integer k ≥ 0, α1 k α2 inductive defined: α1 0 α2 if α1 = α2 α1 k α2 if α1 β1 and β1 k−1 α2. Alternative definition: α1 k α2 if α1 k−1 β1 and β1 α2

Miller, Hassanieh (UIUC) CS374 20 Spring 2020 20 / 44

slide-34
SLIDE 34

“Derives” relation continued

Definition

For integer k ≥ 0, α1 k α2 inductive defined: α1 0 α2 if α1 = α2 α1 k α2 if α1 β1 and β1 k−1 α2. Alternative definition: α1 k α2 if α1 k−1 β1 and β1 α2

  • ∗ is the reflexive and transitive closure of .

α1

∗ α2 if α1 k α2 for some k.

Examples: S

∗ ǫ, 0S1 ∗ 0000011111.

Miller, Hassanieh (UIUC) CS374 20 Spring 2020 20 / 44

slide-35
SLIDE 35

Context Free Languages

Definition

The language generated by CFG G = (V , T, P, S) is denoted by L(G) where L(G) = {w ∈ T ∗ | S

∗ w}.

Miller, Hassanieh (UIUC) CS374 21 Spring 2020 21 / 44

slide-36
SLIDE 36

Context Free Languages

Definition

The language generated by CFG G = (V , T, P, S) is denoted by L(G) where L(G) = {w ∈ T ∗ | S

∗ w}.

Definition

A language L is context free (CFL) if it is generated by a context free grammar. That is, there is a CFG G such that L = L(G).

Miller, Hassanieh (UIUC) CS374 21 Spring 2020 21 / 44

slide-37
SLIDE 37

Example

L = {0n1n | n ≥ 0}

Miller, Hassanieh (UIUC) CS374 22 Spring 2020 22 / 44

slide-38
SLIDE 38

Example

L = {0n1n | n ≥ 0} L = 0∗1∗

Miller, Hassanieh (UIUC) CS374 22 Spring 2020 22 / 44

slide-39
SLIDE 39

Example

L = {0n1n | n ≥ 0} L = 0∗1∗ L = {0n1m | m > n}

Miller, Hassanieh (UIUC) CS374 22 Spring 2020 22 / 44

slide-40
SLIDE 40

Example

L = {0n1n | n ≥ 0} L = 0∗1∗ L = {0n1m | m > n} L = {0n1m | m < n}

Miller, Hassanieh (UIUC) CS374 22 Spring 2020 22 / 44

slide-41
SLIDE 41

Example

L = {0n1n | n ≥ 0} L = 0∗1∗ L = {0n1m | m > n} L = {0n1m | m < n} L = {0n1m | m = n}

Miller, Hassanieh (UIUC) CS374 22 Spring 2020 22 / 44

slide-42
SLIDE 42

Example

L =

  • w ∈
  • (, )

  • w is properly nested string of parenthesis
  • Miller, Hassanieh (UIUC)

CS374 23 Spring 2020 23 / 44

slide-43
SLIDE 43

Example

L =

  • w ∈
  • (, )

  • w is properly nested string of parenthesis
  • L = {w ∈ {0, 1}∗ | w has equal number of 1s as 0’s}

Miller, Hassanieh (UIUC) CS374 23 Spring 2020 23 / 44

slide-44
SLIDE 44

Closure Properties of CFLs

G1 = (V1, T, P1, S1) and G2 = (V2, T, P2, S2) Assumption: V1 ∩ V2 = ∅, that is, non-terminals are not shared

Miller, Hassanieh (UIUC) CS374 24 Spring 2020 24 / 44

slide-45
SLIDE 45

Closure Properties of CFLs

G1 = (V1, T, P1, S1) and G2 = (V2, T, P2, S2) Assumption: V1 ∩ V2 = ∅, that is, non-terminals are not shared

Theorem

CFLs are closed under union. L1, L2 CFLs implies L1 ∪ L2 is a CFL.

Theorem

CFLs are closed under concatenation. L1, L2 CFLs implies L1·L2 is a CFL.

Theorem

CFLs are closed under Kleene star. If L is a CFL = ⇒ L∗ is a CFL.

Miller, Hassanieh (UIUC) CS374 24 Spring 2020 24 / 44

slide-46
SLIDE 46

Closure Properties of CFLs

Union

G1 = (V1, T, P1, S1) and G2 = (V2, T, P2, S2) Assumption: V1 ∩ V2 = ∅, that is, non-terminals are not shared.

Theorem

CFLs are closed under union. L1, L2 CFLs implies L1 ∪ L2 is a CFL.

Miller, Hassanieh (UIUC) CS374 25 Spring 2020 25 / 44

slide-47
SLIDE 47

Closure Properties of CFLs

Concatenation

Theorem

CFLs are closed under concatenation. L1, L2 CFLs implies L1·L2 is a CFL.

Miller, Hassanieh (UIUC) CS374 26 Spring 2020 26 / 44

slide-48
SLIDE 48

Closure Properties of CFLs

Stardom (i.e, Kleene star)

Theorem

CFLs are closed under Kleene star. If L is a CFL = ⇒ L∗ is a CFL.

Miller, Hassanieh (UIUC) CS374 27 Spring 2020 27 / 44

slide-49
SLIDE 49

Exercise

Prove that every regular language is context-free using previous closure properties. Prove the set of regular expressions over an alphabet Σ forms a non-regular language which is context-free.

Miller, Hassanieh (UIUC) CS374 28 Spring 2020 28 / 44

slide-50
SLIDE 50

Closure Properties of CFLs continued

Theorem

CFLs are not closed under complement or intersection.

Theorem

If L1 is a CFL and L2 is regular then L1 ∩ L2 is a CFL.

Miller, Hassanieh (UIUC) CS374 29 Spring 2020 29 / 44

slide-51
SLIDE 51

Canonical non-CFL

Theorem

L = {anbncn | n ≥ 0} is not context-free. Proof based on pumping lemma for CFLs. Technical and outside the scope of this class.

Miller, Hassanieh (UIUC) CS374 30 Spring 2020 30 / 44

slide-52
SLIDE 52

Parse Trees or Derivation Trees

A tree to represent the derivation S

∗ w.

Rooted tree with root labeled S Non-terminals at each internal node of tree Terminals at leaves Children of internal node indicate how non-terminal was expanded using a production rule

Miller, Hassanieh (UIUC) CS374 31 Spring 2020 31 / 44

slide-53
SLIDE 53

Parse Trees or Derivation Trees

A tree to represent the derivation S

∗ w.

Rooted tree with root labeled S Non-terminals at each internal node of tree Terminals at leaves Children of internal node indicate how non-terminal was expanded using a production rule A picture is worth a thousand words

Miller, Hassanieh (UIUC) CS374 31 Spring 2020 31 / 44

slide-54
SLIDE 54

Example

S à aSb | bSa | SS | ab| ba | ε

S è aSb è abSab è abSSab è abbaSab è abbaab A corresponding derivation of abbaab

S S b a S a b S S b a ε

A derivation tree for abbaab

(also called “parse tree”)

Miller, Hassanieh (UIUC) CS374 32 Spring 2020 32 / 44

slide-55
SLIDE 55

Ambiguity in CFLs

Definition

A CFG G is ambiguous if there is a string w ∈ L(G) with two different parse trees. If there is no such string then G is unambiguous. Example: S → S − S | 1 | 2 | 3

S S S S – – S S – S S – S S 3 2 1 3 2 1 3–(2–1) (3–2)–1

Miller, Hassanieh (UIUC) CS374 33 Spring 2020 33 / 44

slide-56
SLIDE 56

Ambiguity in CFLs

Original grammar: S → S − S | 1 | 2 | 3 Unambiguous grammar: S → S − C | 1 | 2 | 3 C → 1 | 2 | 3

S S – C – S C 3 2 1 (3–2)–1

The grammar forces a parse corresponding to left-to-right evaluation.

Miller, Hassanieh (UIUC) CS374 34 Spring 2020 34 / 44

slide-57
SLIDE 57

Inherently ambiguous languages

Definition

A CFL L is inherently ambiguous if there is no unambiguous CFG G such that L = L(G).

Miller, Hassanieh (UIUC) CS374 35 Spring 2020 35 / 44

slide-58
SLIDE 58

Inherently ambiguous languages

Definition

A CFL L is inherently ambiguous if there is no unambiguous CFG G such that L = L(G). There exist inherently ambiguous CFLs. Example: L = {anbmck | n = m or m = k}

Miller, Hassanieh (UIUC) CS374 35 Spring 2020 35 / 44

slide-59
SLIDE 59

Inherently ambiguous languages

Definition

A CFL L is inherently ambiguous if there is no unambiguous CFG G such that L = L(G). There exist inherently ambiguous CFLs. Example: L = {anbmck | n = m or m = k} Given a grammar G it is undecidable to check whether L(G) is inherently ambiguous. No algorithm!

Miller, Hassanieh (UIUC) CS374 35 Spring 2020 35 / 44

slide-60
SLIDE 60

Inductive proofs for CFGs

Question: How do we formally prove that a CFG L(G) = L? Example: S → ǫ | a | b | aSa | bSb

Theorem

L(G) = {palindromes} = {w | w = w R}

Miller, Hassanieh (UIUC) CS374 36 Spring 2020 36 / 44

slide-61
SLIDE 61

Inductive proofs for CFGs

Question: How do we formally prove that a CFG L(G) = L? Example: S → ǫ | a | b | aSa | bSb

Theorem

L(G) = {palindromes} = {w | w = w R} Two directions: L(G) ⊆ L, that is, S

∗ w then w = w R

L ⊆ L(G), that is, w = w R then S

∗ w

Miller, Hassanieh (UIUC) CS374 36 Spring 2020 36 / 44

slide-62
SLIDE 62

L(G) ⊆ L

Show that if S

∗ w then w = w R

By induction on length of derivation, meaning For all k ≥ 1, S

∗k w implies w = w R.

Miller, Hassanieh (UIUC) CS374 37 Spring 2020 37 / 44

slide-63
SLIDE 63

L(G) ⊆ L

Show that if S

∗ w then w = w R

By induction on length of derivation, meaning For all k ≥ 1, S

∗k w implies w = w R.

If S 1 w then w = ǫ or w = a or w = b. Each case w = w R. Assume that for all k < n, that if S →k w then w = w R Let S n w (with n > 1). Wlog w begin with a.

Then S → aSa k−1 aua where w = aua. And S n−1 u and hence IH, u = uR. Therefore w r = (aua)R = (ua)Ra = auRa = aua = w.

Miller, Hassanieh (UIUC) CS374 37 Spring 2020 37 / 44

slide-64
SLIDE 64

L ⊆ L(G)

Show that if w = w R then S

∗ w.

By induction on |w| That is, for all k ≥ 0, |w| = k and w = w R implies S

∗ w.

Exercise: Fill in proof.

Miller, Hassanieh (UIUC) CS374 38 Spring 2020 38 / 44

slide-65
SLIDE 65

Mutual Induction

Situation is more complicated with grammars that have multiple non-terminals. See Section 5.3.2 of the notes for an example proof.

Miller, Hassanieh (UIUC) CS374 39 Spring 2020 39 / 44

slide-66
SLIDE 66

Normal Forms

Normal forms are a way to restrict form of production rules Advantage: Simpler/more convenient algorithms and proofs

Miller, Hassanieh (UIUC) CS374 40 Spring 2020 40 / 44

slide-67
SLIDE 67

Normal Forms

Normal forms are a way to restrict form of production rules Advantage: Simpler/more convenient algorithms and proofs Two standard normal forms for CFGs Chomsky normal form Greibach normal form

Miller, Hassanieh (UIUC) CS374 40 Spring 2020 40 / 44

slide-68
SLIDE 68

Normal Forms

Chomsky Normal Form: Productions are all of the form A → BC or A → a. If ǫ ∈ L then S → ǫ is also allowed. Every CFG G can be converted into CNF form via an efficient algorithm Advantage: parse tree of constant degree.

Miller, Hassanieh (UIUC) CS374 41 Spring 2020 41 / 44

slide-69
SLIDE 69

Normal Forms

Chomsky Normal Form: Productions are all of the form A → BC or A → a. If ǫ ∈ L then S → ǫ is also allowed. Every CFG G can be converted into CNF form via an efficient algorithm Advantage: parse tree of constant degree. Greibach Normal Form: Only productions of the form A → aβ are allowed. All CFLs without ǫ have a grammar in GNF. Efficient algorithm. Advantage: Every derivation adds exactly one terminal.

Miller, Hassanieh (UIUC) CS374 41 Spring 2020 41 / 44

slide-70
SLIDE 70

Language recognition for CFLs

Algorithmic question: Given CFG G and string w ∈ Σ∗ is w ∈ L(G)?

Miller, Hassanieh (UIUC) CS374 42 Spring 2020 42 / 44

slide-71
SLIDE 71

Language recognition for CFLs

Algorithmic question: Given CFG G and string w ∈ Σ∗ is w ∈ L(G)? Later in course: algorithm for above problem that runs in O(|w|3) time for any fixed grammar G. Via dynamic programming. Hence parsing problem for programming languages is solvable. However cubic time algorithm is too slow! For this reason grammars for PLs are restricted even further to make parsing algorithm faster (essentially linear time) — see CS 421 and compiler courses. In programming languages some amount of “context” may be

  • necessary. But CSL recognition is undecidable (no algorithm)! Hence

people use ad hoc methods for the limited needs in PLs.

Miller, Hassanieh (UIUC) CS374 42 Spring 2020 42 / 44

slide-72
SLIDE 72

Things to know: Pushdown Automata

PDA: a NFA coupled with a stack PDAs and CFGs are equivalent: both generate exactly CFLs. PDA is a machine-centric view of CFLs.

Miller, Hassanieh (UIUC) CS374 43 Spring 2020 43 / 44

slide-73
SLIDE 73

Chomsky Hierarchy

See Wikipedia article for more on Chomsky Hierarchy including the grammar rules for Context Sensitive Languages etc. https://en.wikipedia.org/wiki/Chomsky_hierarchy

Miller, Hassanieh (UIUC) CS374 44 Spring 2020 44 / 44