Regular Languages T1 Mealy Machines
Regular Languages T1 Mealy Machines
Regular Languages T1 Mealy Machines
machines
A Level Unit 9
Computer Regular languages
Science
Paper 1
1
Objectives
• Be able to draw and interpret simple state transition
diagrams for FSMs with no output and with output
• Be able to draw and interpret simple state transition
tables for FSMs with no output and with output
Mealy machines
Unit 9 Regular languages
FSM
• Here is a very simple FSM
• Colour the states in green
• Colour the transitions in blue
• Colour the transition conditions in red
Mealy machines
Unit 9 Regular languages
FSM Answers
• Here is a very simple FSM
• Colour the states in green
• Colour the transitions in blue
• Colour the transition conditions in red
Mealy machines
Unit 9 Regular languages
Notation
Symbol Meaning
State
Start state
Accept state
Transition
Mealy machines
Unit 9 Regular languages
Recognising a language
• A finite state system accepts a string
C1 C 2 C 3 … Cn
if there is a path from the start state to an accept
state labelled by the symbols c1, …., cn
• The language recognised by the FSM consists of all
strings accepted by it
Mealy machines
Unit 9 Regular languages
Worksheet
• Complete Task 1 on worksheet
Mealy machines
Unit 9 Regular languages
Mealy machine
• A Mealy machine is a type of FSM
• It generates an output on each state transition
• The output is determined by its current state and its
current input
• It is deterministic: for each combination of state and input,
only a single transition can be assigned
Mealy machines
Unit 9 Regular languages
Mealy machine
• The notation used for the transition condition is
input/output, as shown on the Mealy machine
below
Mealy machines
Unit 9 Regular languages
Input 1 1 0 0 1 0
State sequence S0 S1 S1 S0 S0 S1
S0
Output 0 0 1 0 0 1
Mealy machines
Unit 9 Regular languages
Input 1 1 0 0 1 0
State sequence S0 S1 S1 S0 S0 S1
S0
Output 0 0 1 0 0 1
Mealy machines
Unit 9 Regular languages
Input 1 1 0 1 1 1
State sequence S0
Output 0
Mealy machines
Unit 9 Regular languages
Example 2 – Analysis
• Is it true that this machine outputs 1 whenever three
consecutive 1s are entered and 0 in all other cases?
Input 1 1 0 1 1 1
State sequence S0 S1 S2 S0 S1 S2
S2
Output 0 0 0 0 0 1
Mealy machines
Unit 9 Regular languages
Worksheet
• Complete Task 2 on the worksheet
Mealy machines
Unit 9 Regular languages
Transition tables
• Complete the table for the Mealy machine
shown below:
Current Next
Input Output
state state
0 S0 0 S1
1 S0
0 S1
1 S1
0 S2
1 S2
Mealy machines
Unit 9 Regular languages
Table equivalence
• Both representations are equivalent
• They define the same Mealy machine
Current Next
Input Output
state state
0 S0 0 S1
1 S0 0 S0
0 S1 0 S2
1 S1 0 S1
0 S2 0 S2
1 S2 1 S0
Mealy machines
Unit 9 Regular languages
Example 3
Current Next
• Complete the state Input Output
state state
0 S0 0 S1
sequence for the 1 S0 0 S0
input string: 0 S1 0 S2
00010011 1 S1 0 S1
0 S2 0 S2
1 S2 1 S0
Input 0 0 0 1 0 0 1 1
State S0
Output
Mealy machines
Unit 9 Regular languages
Example 3
Current Next
• Complete the state Input Output
state state
sequence for the 0 S0 0 S1
input string: 1 S0 0 S0
00010011 0 S1 0 S2
1 S1 0 S1
• What substring will
0 S2 0 S2
output a 1?
1 S2 1 S0
Input 0 0 0 1 0 0 1 1
State S0 S1 S2 S2 S0 S1 S2 S0 S0
Output 0 0 0 1 0 0 1 0
Mealy machines
Unit 9 Regular languages
Exercise
• Design a three-state Mealy
machine that will output 1
when the sequence 110 is
encountered and 0 for all
other string sequences
• Show the state transition table
for this machine
• Show the state transition
sequence for the input string:
01011001
Mealy machines
Unit 9 Regular languages
Exercise
Current Next
Input Output
state state
0 S0
1 S0
0 S1
1 S1
0 S2
1 S2
Input 0 1 0 1 1 0 0 1
State S0
Output
Mealy machines
Unit 9 Regular languages
Exercise
Current Next
Input Output
state state
0 S0 0 S0
1 S0 0 S1
0 S1 0 S0
1 S1 0 S2
0 S2 1 S0
1 S2 0 S1
Input 0 1 0 1 1 0 0 1
State S0
Output
Mealy machines
Unit 9 Regular languages
Exercise
Current Next
Input Output
state state
0 S0 0 S0
1 S0 0 S1
0 S1 0 S0
1 S1 0 S2
0 S2 1 S0
1 S2 0 S1
Input 0 1 0 1 1 0 0 1
State S0 S0 S1 S0 S1 S2 S0 S0 S1
Output 0 0 0 0 0 1 0 0
Mealy machines
Unit 9 Regular languages
Worksheet
• Complete Task 3, Question 3 on the worksheet
• Look closely at the input string
• Does there appear to be an error in this Mealy machine?
Plenary
• Mealy machines have an output dependent upon …
• Mealy machines are a type of …
• On Mealy machines
• States are drawn as …
• Transitions are drawn as …
• Transition notation is indicated as …
Copyright
This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part of the
materials distributed with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG Online Limited.
Licence agreement
This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the worksheets,
PowerPoint presentations, teaching guides and other associated files distributed with it is licensed, not sold, to
you by PG Online Limited for use under the terms of the licence.
The materials distributed with this unit may be freely copied and used by members of a single institution on a
single site only. You are not permitted to share in any way any of the materials or part of the materials with any
third party, including users on another site or individuals who are members of a separate institution. You
acknowledge that the materials must remain with you, the licencing institution, and no part of the materials may
be transferred to another institution. You also agree not to procure, authorise, encourage, facilitate or enable any
third party to reproduce these materials in whole or in part without the prior permission of PG Online Limited.