lecture 18 - pushdown automata - examples

14
Pushdown Automata - Examples Lecture 18 Section 2.2 Robb T. Koether Hampden-Sydney College Mon, Oct 8, 2012 Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 1 / 14

Upload: adrian-gil-ors

Post on 30-Oct-2014

33 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Lecture 18 - Pushdown Automata - Examples

Pushdown Automata - ExamplesLecture 18Section 2.2

Robb T. Koether

Hampden-Sydney College

Mon, Oct 8, 2012

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 1 / 14

Page 2: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 2 / 14

Page 3: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 3 / 14

Page 4: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 4 / 14

Page 5: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automaton)Design a PDA that accepts the language

{w | w contains an equal number of a’s and b’s}.

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 5 / 14

Page 6: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automaton)The strategy will be to keep the excess symbols, either a’s or b’s,on the stack.One state will represent an excess of a’s.Another state will represent an excess of b’s.We can tell when the excess switches from one symbol to theother because at that point the stack will be empty.In fact, when the stack is empty, we may return to the start state.

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 6 / 14

Page 7: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automaton)

b, $ → εa, ε → $

b, ε → $

a, ε → ab, a → ε

b, ε → ba, b → ε

a < b

a > b

a, $ → ε

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 7 / 14

Page 8: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automaton)Note that this solution is inspired by the grammar

S → SS | aSb | bSa | ε

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 8 / 14

Page 9: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 9 / 14

Page 10: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automata)Let Σ = {a, (, )}. Design a PDA whose language is

{w | w contains balanced parentheses}.

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 10 / 14

Page 11: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 11 / 14

Page 12: Lecture 18 - Pushdown Automata - Examples

Examples

Example (Pushdown automata)Let Σ = {a, b, c, +,×, (, )}. Design a PDA whose language is

{w | w is a valid algebraic expression}.

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 12 / 14

Page 13: Lecture 18 - Pushdown Automata - Examples

Outline

1 Examples of PDAsEqual Number of a’s and b’sBalanced ParenthesesAlgebraic Expressions

2 Assignment

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 13 / 14

Page 14: Lecture 18 - Pushdown Automata - Examples

Assignment

AssignmentRead Section 2.2, pages 112 - 114.Problems 21, 22, 23, 24, page 130.Let Σ = {a, (, ), [, ]}. Design a PDA whose language is

{w | w contains balanced parentheses and brackets}.

Design a PDA whose language is

{anbmcmdn | m, n ≥ 0}.

Design a PDA whose language is

{anbm | n 6= m}.

Robb T. Koether (Hampden-Sydney College) Pushdown Automata - Examples Mon, Oct 8, 2012 14 / 14