Preamble
Finite automata is used in text processing (lexical analysis) Pushdown automata is used in parsing The Turing Machine is a more general kind of automaton which is universal
Formal Languages
Alphabet
An alphabet is a finite set of symbols. Examples of alphabets include: , and .
Link to original
Word (finite automata)
A word or string (over an alphabet ) is a finite sequence of symbols from written without commas. For example, or .
Link to original
Language
A language (over an alphabet ) is a set of words over .
For example, given .
Given :
Link to original
Chomsky hierarchy
Depending on the form of the language, identifying valid words can vary in difficulty.
Chomsky hierarchy
The Chomsky hierarchy categorises languages into collections according to their difficulty.
Type Abstract Machine Type-0 Turing Machine Type-1 Linear-bounded Turing Machine Type-2 Pushdown Automata Type-3 Finite Automata Each level has varying memory capabilities.
Link to original
Finite Automata
Finite automata (or finite-state machines) with alphabet is defined by a finite number of states and a set of transitions between states (one transition for each symbol in ).
There is a distinguished state, called initial state, indicated by an arrow where the automaton starts, and one or more final / accepting states indicated by double circle.
Finite automata
A finite automata is a tuple where:
Link to original
- is an alphabet (finite set of atomic symbols)
- is a finite set of states
- is the initial state
- is the set of accepting states
- is the transition function
The language associated with a finite automaton is the set of words it accepts, denoted .
Example: A vending machine
graph LR; start(( )); 0((0)); 5((5)); 10((10)); 15((15)); 20(((20))); start-->0; 0-- 5 -->5; 5-- 5 -->10; 10-- 5 -->15; 15-- 5 -->20; 0-- 10 -->10; 5-- 10 -->15; 10-- 10 -->20; 0-- 20 -->20;any sequence of coins adding exactly to 20p
- : valid word, terminates in accepting state
- : invalid word, terminates in non-accepting state
- : invalid word, no valid transition
Exercises
![]()
Deterministic and Non-Deterministic Finite Automata
Non-deterministic finite automata
A non-deterministic finite automata is a tuple where:
- is an alphabet (finite set of atomic symbols)
- is a finite set of states
- is the initial state
- is the set of accepting states
- is the transition function
- is the power set of
- is an empty transition label that can be taken at any point when reading a word
A word is accepted if there is any trace from the initial state to an accepting state.
Link to original
Example: NDFA
graph LR; start(( )); p((p)); q(((q))); start-->p; p-- 0,1 -->p; p-- 1 -->q;Is a valid word?
- : non-accepting trace
- : non-accepting trace
- : accepting trace
- : non-accepting trace
Non-deterministic and deterministic finite automata are computationally equivalent. A language can be recognised by an NFA iff the language can be recognised by a DFA.
Power of finite automata
- They have no ‘memory’, no knowledge of previous state.
- This limits languages we can associate (these are regular languages)
- Regular languages are closed under basic set operations (union, intersect)
- A language that is not pumpable is not regular.
The Pumping Lemma (Theorem)
The Pumping Lemma says if is a regular language then there is some such that every word of length can be written in the form for such that:
Link to original
- If and ,
- then for all .
Pushdown automata
Pushdown automata (PDA) are finite automata but with a stack. The stacks in the PDA store symbols.
Stack
Stacks are specialised forms of memory where:
Link to original
- only the top of the stack can be read (pop) and in the process it is removed from the stack
- new elements must be added to the top of the stack (push)
Pushdown automata
A pushdown automata (PDA) is a tuple where:
- is an alphabet (finite set of atomic symbols)
- is a finite set of states
- is the set of symbols that can be stored on stack
- is the initial state
- is the set of accepting states
- is the transition function
The transition function maps to a set of pairs of the form .
- Symbol in domain is to be popped.
- Symbol in co-domain is to be pushed.
- If symbol is (empty), nothing is to be popped / pushed.
Transitions may also be labelled . A word is accepted if there is any trace from initial state to accepting state that leaves the stack empty.
Link to original
Example: PDA
graph LR; start(( )); p((p)); q((q)); r(((r))); start-->p; p-- (0, ε); A -->p; p-- (ε, ε); ε --> q; q-- (1, A); ε -->q; q-- (ε, ε); ε -->r;Transition notation is where:
- is the next character of word
- is symbol to be popped from stack
- is symbol to be pushed to stack
Is a valid word?
Exercises
For the PDA example above:
More exercises:
Power of PDA
- They have limited memory
- Limits languages the PDA can be associated with to Type-2 languages
- These are called context-free languages



