Lab Session #4 #
Agenda #
- Deterministic Pushdown Automaton (DPDA): Notion, formal definition, configuration, transition, and acceptance.
- Exercises on DPDAs
Pushdown Automata #
A Pushdown Automaton (PDA) is a way to implement a Context Free Grammar in a similar way we design Finite Automaton for Regular Grammar.
- It is more powerful than FSA
- FSA has a very limited memory but PDA has more memory
- PDA = FSA + a Stack
A stack is a way we arrange elements one on top of another; it does two basic operations:
- PUSH: A new element is added at the Top of the stack
- POP: The Top element of the stack is read and removed
PDA-components #
A Pushdown Automaton has 3 components:
- An input tape
- A Finite Control Unit
- A Stack of infinite size
Acceptance criteria: A string is accepted by a PDA if there is a path coherent with on the PDA that goes from the initial state to the final state. The input string has to be read completely.
When a PDA reads an input symbol, it will be able to save it (or save other symbols) in its memory.
- For deciding if an input string is in the language , the PDA needs to remember the numbers of ’s.
- Whenever the PDA reads the input symbol , two things should happen:
- it should change states: from now on the only legal input symbols are ’s.
- it should delete one a from its memory for every it reads.
A single move of a PDA will depend on:
- the current state,
- the next input (it could be no symbol: ε symbol), and
- the symbol currently on top of the stack. PDA will be assumed to begin operation with an initial start symbol on its stack
- is not essential, but useful to simplify definitions
- is on top means that the stack is effectively empty.
Formal Definition #
A Pushdown Automaton is a tuple , , , , , , , where:
- is a finite set of states.
- and are finite sets, the input and stack alphabets.
- is the transition function.
- , the initial state.
- , the initial stack symbol.
- , the set of accepting states.
Configuration A configuration is a generalization of the notion of state. It shows:
- the current state,
- the portion of the input string that has not yet been read, and
- the stack. It is a snapshot of the PDA.
Example #
Construct a PDA that accepts
Exercises #
Part I #
Build DPDAs that recognise the following languages:
- (where , are the reversed strings , ), the alphabet is
- The language of nested and balanced brackets and parentheses. E.g. a string in the language: , a string that does not belong to the language: – the alphabet is
Part II #
Build DPDAs that recognise the following languages:
- where is the number of occurrences of the character in the string
Homework #
- Define a DPDA that recognises this language:
- Construct a DPDA that recognises the language of well-formed parentheses of the arithmetic expressions (binary operations).
For simplicity, consider the alphabet - a single symbol that represents terms and a single operator .
Examples of strings belonging to the language are: