Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.

Similar presentations


Presentation on theme: "1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States."— Presentation transcript:

1 1 Pushdown Automata PDAs

2 2 Pushdown Automaton -- PDA Input String Stack States

3 3 Initial Stack Symbol Stack bottom special symbol

4 4 The States Input symbol Pop symbol Push symbol

5 5 top input stack

6 6 top input stack

7 7 top input stack

8 8 top input stack

9 9 Non-Determinism

10 10 NPDA: Non-Deterministic PDA Example:

11 11 Execution Example: Input current state Time 0 Stack

12 12 Input Time 1 Stack

13 13 Input Stack Time 2

14 14 Input Stack Time 3

15 15 Input Stack Time 4

16 16 Input Stack Time 5

17 17 Input Stack Time 6

18 18 Input Stack Time 7

19 19 Input Time 8 accept Stack

20 20 A string is accepted if: All the input is consumed The last state is a final state We do not care about the stack contents

21 21 The input string is accepted by the NPDA:

22 22 is the language accepted by the NPDA: In general,

23 23 Another NPDA example NPDA

24 24

25 25 Execution Example: Input Time 0 Stack

26 26 Input Time 1 Stack

27 27 Input Time 2 Stack

28 28 Input Time 3 Stack

29 29 Input Time 4 Stack

30 30 Input Time 5 Stack

31 31 Input Time 6 Stack accept

32 32 Pushing Strings Input symbol Pop symbol Push string

33 33 top input stack pushed string Example:

34 34 Another NPDA example NPDA

35 35

36 36 Execution: Time 0 Input current state Stack

37 37 Time 1 Input Stack

38 38 Time 3 Input Stack

39 39 Time 4 Input Stack

40 40 Time 5 Input Stack

41 41 Time 6 Input Stack

42 42 Time 7 Input Stack

43 43 Time 8 Input Stack accept

44 44 Formalities for NPDAs

45 45 Transition function:

46 46 Transition function:

47 47 Formal Definition Non-Deterministic Pushdown Automaton NPDA States Input alphabet Stack alphabet Transition function Final states Stack start symbol

48 48 Instantaneous Description Current state Remaining input Current stack contents

49 49 Input Stack Time 4: Example:Instantaneous Description

50 50 Input Stack Time 5: Example:Instantaneous Description

51 51 We write: (Time 4)(Time 5)

52 52 A computation:

53 53 For convenience we write:

54 54 Formal Definition Language of NPDA : Start state Final state

55 55 Example: NPDA : thus

56 56 NPDA : thus

57 57 NPDA : Therefore:

58 58 Converting Context-Free Grammars to NPDAs

59 59 An example grammar: What is the equivalent NPDA?

60 60 Grammar: NPDA:

61 61 The NPDA simulates leftmost derivations of the grammar L(grammar) = L(NPDA)

62 62 Grammar: A leftmost derivation:

63 63 NPDA execution: Input Stack Time 0 current state

64 64 Input Stack Time 1

65 65 Input Stack Time 2

66 66 Input Stack Time 3

67 67 Input Stack Time 4

68 68 Input Stack Time 5

69 69 Input Stack Time 6

70 70 Input Stack Time 7

71 71 Input Stack Time 8

72 72 Input Stack Time 9

73 73 Input Stack Time 10 accept

74 74 In general: Given any grammar We can construct a NPDA With

75 75 Constructing NPDA from grammar : For any production For any terminal

76 76 Grammar generates string if and only if NPDA accepts

77 77 Therefore: For any context-free language there is an NPDA that accepts the same language


Download ppt "1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States."

Similar presentations


Ads by Google