Regular Languages T1 Mealy Machines

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

AQA Mealy

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

Finite state machines (FSM)


• Recall that an FSM is an abstract model of
computation used to design computer programs
and sequential logic circuits, test for valid syntax,
etc.
• It is an abstract representation of how something changes
from one state to another in response to a condition or event
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

• Which of the following strings will be accepted by this


finite state automaton?
aaac badc adadbd ac bdaac bd

• Note: If no outgoing transition is defined from a state for a particular input


symbol and that symbol is input then the string is rejected
Mealy machines
Unit 9 Regular languages

Finite state machines


• Draw an FSM for turning a light on and off when a
button is pressed
• The light should initially start in the off state
• Label the states, transitions, and transition conditions
Mealy machines
Unit 9 Regular languages

Finite state machines


• Draw an FSM for turning a light on and off when a
button is pressed
• The light should initially start in the off state
• Label the states, transitions, and transition conditions
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

Use of a Mealy machine


• A Mealy machine can be used to map an input
sequence to an output sequence
• It is used in language parsing
• It can be used to translate from one language to another
Mealy machines
Unit 9 Regular languages

Example 1 – Generating output


• The output for any input string can be shown
• Write down the input string, for example 110010
• Start with S0, as shown in black
• At S0, with an input of 1, output 0 and transition to S1

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

Example 1 – Read the FSM


• Output 1 if a particular substring is entered as part of
a larger string of input values
• Follow this sequence of state changes until you get
an output of 1
• Move out of S0 requires a ‘1’. Is output = ‘1’? No, keep going
• Move out of S1 requires a ‘0’. Is output = ‘1’? Yes, end
• The sequence ’10’ generates an output of 1
Mealy machines
Unit 9 Regular languages

Example 1 – Read the sequence


• Recognising substrings in output
• How many states in this FSM? 2
• Where are the 1s in the output? See
• Count back the number of states (2 inclusive)
• What is the substring? See

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

Example 2 – Generating output


• The Mealy machine below outputs 1 whenever three
consecutive 1s are entered. Otherwise, output is 0
• Complete the table

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

State transition table


• A state transition table may be used to define a
Mealy machine. It shows all the states and possible
inputs and the outputs for each combination of state
and input
Input Current state Output Next state
0 S0 0 S1
1 S0 ? ?
0 S1 ? ?
1 S1 ? ?
0 S2 ? ?
1 S2 ? ?
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?

• Complete Question 4 on the worksheet


• How does the behaviour of this Mealy machine compare to
the one in Question 3?
Mealy machines
Unit 9 Regular languages

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 …

• Two ways of representing a Mealy machine are …


• The connection between languages and Mealy
machines is …
Mealy machines
Unit 9 Regular languages

Copyright

© 2016 PG Online Limited

The contents of this unit are protected by 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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy