Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pushdown Automata PDAs

Similar presentations


Presentation on theme: "Pushdown Automata PDAs"— Presentation transcript:

1 Pushdown Automata PDAs

2 Pushdown Automaton -- PDA
Input String Stack States

3 Initial Stack Symbol Stack Stack stack head top bottom special symbol
Appears at time 0

4 The States Pop symbol Input symbol Push symbol

5 input stack top Replace

6 input stack top Push

7 input stack top Pop

8 input stack top No Change

9 Empty Stack input stack empty Pop top The automaton HALTS No possible transition after

10 A Possible Transition input stack Pop top

11 PDAs are non-deterministic
Non-Determinism PDAs are non-deterministic Allowed non-deterministic transitions

12 Example PDA PDA

13 Basic Idea: Push the a’s on the stack 2. Match the b’s on input with a’s on stack 3. Match found

14 Execution Example: Time 0 Input Stack current state

15 Time 1 Input Stack

16 Time 2 Input Stack

17 Time 3 Input Stack

18 Time 4 Input Stack

19 Time 5 Input Stack

20 Time 6 Input Stack

21 Time 7 Input Stack

22 Time 8 Input Stack accept

23 A string is accepted if there is
a computation such that: All the input is consumed AND The last state is an accepting state At the end of the computation, we do not care about the stack contents (the stack can be empty at the last state)

24 The input string is accepted by the PDA:

25 In general, is the language accepted by the PDA:

26 Rejection Example: Time 0 Input Stack current state

27 Rejection Example: Time 1 Input Stack current state

28 Rejection Example: Time 2 Input Stack current state

29 Rejection Example: Time 3 Input Stack current state

30 Rejection Example: Time 4 Input Stack current state

31 Rejection Example: Time 4 Input Stack reject current state

32 The input string is rejected by the PDA:

33 no computation such that:
A string is rejected if there is no computation such that: All the input is consumed AND The last state is an accept state At the end of the computation, we do not care about the stack contents

34 Another PDA example PDA

35 Basic Idea: Push v on stack 3. Match on input with v on stack 2. Guess middle of input 4. Match found

36 Execution Example: Time 0 Input Stack

37 Time 1 Input Stack

38 Time 2 Input Stack

39 Time 3 Input Guess the middle of string Stack

40 Time 4 Input Stack

41 Time 5 Input Stack

42 Time 6 Input Stack accept

43 Rejection Example: Time 0 Input Stack

44 Time 1 Input Stack

45 Time 2 Input Stack

46 Time 3 Input Guess the middle of string Stack

47 Time 4 Input Stack

48 Time 5 There is no possible transition. Input Input is not consumed Stack

49 Another computation on same string:
Input Time 0 Stack

50 Time 1 Input Stack

51 Time 2 Input Stack

52 Time 3 Input Stack

53 Time 4 Input Stack

54 Time 5 Input No final state is reached Stack

55 There is no computation
that accepts string

56 Another PDA example PDA

57 Execution Example: Time 0 Input Stack

58 Time 1 Input Stack

59 Time 2 Input Stack

60 Time 3 Input Stack accept

61 Rejection example: Time 0 Input Stack

62 Time 1 Input Stack

63 Time 2 Input Stack

64 Time 3 Input Stack

65 Time 4 Input Stack Halt and Reject

66 Pushing Strings Pop symbol Input symbol Push string

67 Example: input pushed string stack top Push

68 Another PDA example PDA

69 Execution Example: Time 0 Input Stack current state

70 Time 1 Input Stack

71 Time 3 Input Stack

72 Time 4 Input Stack

73 Time 5 Input Stack

74 Time 6 Input Stack

75 Time 7 Input Stack

76 Time 8 Input Stack accept

77 Formalities for PDAs

78 Transition function:

79 Transition function:

80 Formal Definition Pushdown Automaton (PDA) Final states States Input
alphabet Stack start symbol Transition function Initial state Stack alphabet

81 Instantaneous Description
Current state Current stack contents Remaining input

82 Example: Instantaneous Description Input Time 4: Stack

83 Example: Instantaneous Description Input Time 5: Stack

84 We write: Time 4 Time 5

85 A computation:

86 For convenience we write:

87 Formal Definition Language of PDA : Initial state Final state

88 Example: PDA :

89 PDA :

90 Therefore: PDA :


Download ppt "Pushdown Automata PDAs"

Similar presentations


Ads by Google