View
234
Download
2
Category
Preview:
Citation preview
3
Controlling Things ...
If x has happened then do something
If in state y then do somethingchange to new state
If x happened while in state ydo somethingchange to new state
4
State Transition Table
State Event Action New State
happy
work due
next week none happy
happy
work due
tomorrow
start
work anxious
anxious
Work
cancelled none happy
anxious work done
hand in
work happy
8
Components
starting state (one per machine)
transition
d
input
symbol
halting
state
(one or
more)
non-halting
state
9
Sequence of Input Symbols
What input sequences leave this FA in its halt state?
S1S2
S3
a
b
c ac ab abc abac
{ (ab)nac | n>=0 }
yes
no
no
yes
{ ac, abac, ababac, abababac, ... }
10
The Original Example ...
tomorrow
cancelled
donenext week
AnxiousHappy
Some
acceptable
inputs
nnnntc
ntd
Λ
nntcntd
11
Recognising Strings
the set of all strings accepted/recognised by an FA
=
the language accepted/recognised by the FA
12
Rejecting Strings
An FA rejects a string if
with some symbols remaining
there is no transition for the next symbol
or
with no symbols remaining
the FA is not in a halt state
13
Rejected / Accepted Strings
t
c
d n
AnxiousHappy
tdnnn yes/no
tdnnt yes/no
n yes/no
ntc yes/no
ntcd yes/no
14
Recall some simple languages ...Can you draw FA to recognise them?{ Λ, a, aa, aaa, aaaa, ...}
= { an | n >= 0 }
{ a, aa, aaa, aaaa, ...}
= { an | n > 0 }
{ 00, 01, 10, 11 }
15
An Assignment Related Example
Draw an FA to recognise non-negative integers
Extend it to all integers (i.e. allowing +,- signs)
18
Non-Deterministic Automata
In deterministic automata, there can never be two transitions to different state for the same input symbol.
If there are more than one transition to different states for the same input symbol, we call it a non-deterministic automata.
19
Deterministic FAs and Non-Deterministic FAs
For every
non-deterministic FA (NFA)
there is a
deterministic FA (DFA)
which accepts
the same language
24
A General Algorithm
1. Write down {1} as the start state of the DFA
2. Choose a state in the DFA which hasn’t been processed
3. Work out all transitions from it adding new states
4. Repeat from step 2 until all states have been processed
5. Mark halting states
29
Using Building Blocks
For example, you are asked to define a format for a collection of pictures’ file names
G = { a1.gif, a2.gif, a3.gif, ... a33.gif, .... }
30
Using Building Blocks
Now you are asked to define a format for another collection of pictures’ file names
P = { b1.jpg, b2.jpg, b3.jpg, ... b33.jpg, .... }
32
Using Building Blocks
Let’s change the language P to
P = { a1.jpg, a2.jpg, a3.jpg, ... a33.jpg, .... }
(replace ‘b’ by ‘a’)
a 1-9 1-9
.j p g
33
What happens now? If we need an FA for the union of G and P. i.e. G U P
a 1-9 1-9
.j p g
a 1-91-9.
g i f
It’s a NFA!
Recommended