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

3 Autómatas a Pila Los Autómatas a Pila permiten analizar palabras para reconocer si pertenecen o no a lenguajes de tipo 2, independientes del contexto. Tienen la misma estructura que los Autómatas Finitos, pero se añade una pila (memoria auxiliar) para poder guardar información que podrá ser útil en momentos posteriores del análisis. Definición Se definen los Autómatas a pila como:

4

5

6

7 Pushdown Automaton -- PDA
Input String Stack States

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

9 The States Pop symbol Input symbol Push symbol

10 input stack top Replace

11 input stack top Push

12 input stack top Pop

13 input stack top No Change

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

15 A Possible Transition input stack Pop top

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

17 Example PDA PDA

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

19 Execution Example: Time 0 Input Stack current state

20 Time 1 Input Stack

21 Time 2 Input Stack

22 Time 3 Input Stack

23 Time 4 Input Stack

24 Time 5 Input Stack

25 Time 6 Input Stack

26 Time 7 Input Stack

27 Time 8 Input Stack accept

28 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)

29 The input string is accepted by the PDA:

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

31 Rejection Example: Time 0 Input Stack current state

32 Rejection Example: Time 1 Input Stack current state

33 Rejection Example: Time 2 Input Stack current state

34 Rejection Example: Time 3 Input Stack current state

35 Rejection Example: Time 4 Input Stack current state

36 Rejection Example: Time 4 Input Stack reject current state

37 The input string is rejected by the PDA:

38 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

39 Another PDA example PDA

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

41 Execution Example: Time 0 Input Stack

42 Time 1 Input Stack

43 Time 2 Input Stack

44 Time 3 Input Guess the middle of string Stack

45 Time 4 Input Stack

46 Time 5 Input Stack

47 Time 6 Input Stack accept

48 Rejection Example: Time 0 Input Stack

49 Time 1 Input Stack

50 Time 2 Input Stack

51 Time 3 Input Guess the middle of string Stack

52 Time 4 Input Stack

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

54 Another computation on same string:
Input Time 0 Stack

55 Time 1 Input Stack

56 Time 2 Input Stack

57 Time 3 Input Stack

58 Time 4 Input Stack

59 Time 5 Input No final state is reached Stack

60 There is no computation
that accepts string

61 Another PDA example PDA

62 Execution Example: Time 0 Input Stack

63 Time 1 Input Stack

64 Time 2 Input Stack

65 Time 3 Input Stack accept

66 Rejection example: Time 0 Input Stack

67 Time 1 Input Stack

68 Time 2 Input Stack

69 Time 3 Input Stack

70 Time 4 Input Stack Halt and Reject

71 Pushing Strings Pop symbol Input symbol Push string

72 Example: input pushed string stack top Push

73 Another PDA example PDA

74 Execution Example: Time 0 Input Stack current state

75 Time 1 Input Stack

76 Time 3 Input Stack

77 Time 4 Input Stack

78 Time 5 Input Stack

79 Time 6 Input Stack

80 Time 7 Input Stack

81 Time 8 Input Stack accept

82 Formalities for PDAs

83 Transition function:

84 Transition function:

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

86 Instantaneous Description
Current state Current stack contents Remaining input

87 Example: Instantaneous Description Input Time 4: Stack

88 Example: Instantaneous Description Input Time 5: Stack

89 We write: Time 4 Time 5

90 A computation:

91 For convenience we write:

92 Formal Definition Language of PDA : Initial state Final state

93 Example: PDA :

94 PDA :

95 Therefore: PDA :


Download ppt "Pushdown Automata PDAs"

Similar presentations


Ads by Google