2017/09/14 chapter 2.2 in sipser -...

24
Human-aware Robo.cs 1 Pushdown Automata 2017/09/14 Chapter 2.2 in Sipser Ø Announcement: q Slides for this lecture are here: http://www.public.asu.edu/~yzhan442/teaching/CSE355/Lectures/PDA.pdf

Upload: others

Post on 01-Sep-2019

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

1

Pushdown Automata •  2017/09/14

•  Chapter 2.2 in Sipser

Ø  Announcement: q  Slides for this lecture are here:

http://www.public.asu.edu/~yzhan442/teaching/CSE355/Lectures/PDA.pdf

Page 2: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

2

Last time

FA (DFA & NFA) express Regular Expressions (RE)

•  Context free langauges

o  Context free grammars

q  Design CFGs

q  Ambiguities

q  Chomsky normal form

Ø  Goals:

o  Learned context free grammars: the generator for CFLs

CFL

Page 3: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

3

Outline for today

FA (DFA & NFA) express Regular Expressions (RE)

•  Context free langauges

o  Context free grammars

o  Pushdown automata

q  Definition of PDA

q  Computation PDA

Ø  Goals:

o  Learn PDA, the computing machine for CFL

CFL

Page 4: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

4

Pushdown automata

FA:

PDA:

Page 5: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

5

Pushdown automata

NPDA

Page 6: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

6

Pushdown automata

Page 7: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

7

Outline for today

FA (DFA & NFA) express Regular Expressions (RE)

•  Context free langauges

o  Context free grammars

o  Pushdown automata

q  Definition of PDA

q  Computation PDA

Ø  Goals:

o  Learn PDA, the computing machine for CFL

CFL

Page 8: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

8

Computation of PDA

input string stack

Page 9: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

9

Computation of PDA

input string stack

$

Page 10: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

10

Computation of PDA

input string stack

a $

Page 11: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

11

Computation of PDA

input string stack

a $

Page 12: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

12

Computation of PDA

input string stack

a a $

Page 13: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

13

Computation of PDA

input string stack

a $

Page 14: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

14

Computation of PDA

input string stack

$

Page 15: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

15

Computation of PDA

input string stack

ACCEPT

Page 16: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

16

Computation of PDA

input string stack

ACCEPT

what is the language here?

Page 17: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

17

Computation of PDA

input string stack

ACCEPT

what is the language here? { anbn | n = 0, 1, … }

Page 18: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

18

Computation of PDA

Page 19: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

19

Computation of PDA

•  Why do we need the $ sign for stack?

•  Does the stack have to be empty to accept?

•  What if a PDA only pushes and never pops?

•  What if a PDA always pops after pushes?

•  What if a PDA can only keep one symbol on the stack?

Page 20: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

20

Example

Page 21: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

21

Example

{ a+b }

Page 22: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

22

Example

Page 23: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

23

Example

{ ambn | } m n 2m,m > 0

Page 24: 2017/09/14 Chapter 2.2 in Sipser - public.asu.eduyzhan442/teaching/CSE355/Lectures/PDA.pdfHuman-aware Robo.cs 2 Last time FA (DFA & NFA) express Regular Expressions (RE) • Context

Human-awareRobo.cs

24

Outline for today

FA (DFA & NFA) express Regular Expressions (RE)

•  Reading assignment for the next class:

o  Sipser Sec. 2.2 (remaining) – Quiz link will

be sent out; due date is before the

beginning of the next class on Sep 21

CFL

•  Context free langauges

o  Context free grammars

o  Pushdown automata

q  Definition of PDA

q  Computation PDA

Ø  Goals:

o  Learned PDA, the computing machine for CFL