SlideShare a Scribd company logo
1 of 8
Download to read offline
ComputationTheory1 A.L. Mustafa Ghanem Saeed
1| P a g e
ComputerScience Department Collage of Science CihanUniversity
Finite State Machines with Output
(Mealy and Moore Machines)
We shall investigate two different models for FA's with output
capabilities; these are Moore machine and Mealy machine.
Moore Machines:
A Moore machine M is the 5 tuple M = (Q,, Г, Ϩ, q0) where
1. A finite set of states q0, q1, q2, …, where q0 is designed as the
start state.
2. An alphabet of letters for forming the input string Σ= { a, b, c, …}.
3. An alphabet of possible output characters Г = { x, y, z, …}.
4. A transition function Ϩ as in table that shows for each state and
each input letter what state is reached next.
5. Start state as q0.
An output table that shows what character from Г is printed by each state
that is entered.
A Moore machine does not define a language of accepted words, since
every input string creates an output string and there is no such thing as a
final state. The processing is terminated when the last input letter is read
and the last output character is printed.
Example 1:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
Names of states: q0, q1, q2, q3. (q0 = start state)
Q Ϩ(q, a) Ϩ(q, b) Г(Q)
q0 q1 q3 1
q1 q3 q1 0
q2 q0 q3 0
q3 q1 q2 1
Sol:
The Moore machine is:
ComputationTheory1 A.L. Mustafa Ghanem Saeed
2| P a g e
ComputerScience Department Collage of Science CihanUniversity
Note1:
 The two symbols inside the circle are separated by a slash "/", on the
left side is the nameof the state and on the right is the outputfrom
that state.
 If the inputstring is abab to the Moore machinethen the output will
be 10010.
Note 2:
A Moore machineis very similar to a Finite Automaton (FA), with a few
key differences:
• It has no final states.
• It does not accept or reject input; instead, it generates output from
input.
• Moore machines cannothave nondeterministic states.
Every input gives output not if word belongs to the machine or language
like FA
In each state we stop we have to print out what inside that state
(it's content) so the output will be more than input by one because we
start with start state and print out its content before we trace the input
string
Example 2: construct a Moore machine that take set of all strings over
Alphabet {a, b} as input and print 1 as output for every occurrence of
'aab' as substring.
Sol:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
ComputationTheory1 A.L. Mustafa Ghanem Saeed
3| P a g e
ComputerScience Department Collage of Science CihanUniversity
Input string aaababbaabb
State q0q1q2q2q3q1q0q0q1q2q3q0
Output 000010000010
this machine gives 1 after each aab
aabaabaaababaab
0001001000100001
Note:
 Moore machine use as a string recognizer to give us a mark (1) after
each substring so we design a machine put 0 in all states except the
one after the one represent end of substring aab
 The output of the machine contains 1 for each occurrence of the
substring aab found in the input string.
Example 3: Construct a Moore machine that take set of all strings over
Alphabet {0, 1} as input and produce 'A' as output if input end with (10)
or produce 'B' as output if input end with (11) otherwise produce 'C' .
Sol:
Input alphabet: Σ = {0, 1}
Output alphabet: Г = {A, B, C}
Exam
ComputationTheory1 A.L. Mustafa Ghanem Saeed
4| P a g e
ComputerScience Department Collage of Science CihanUniversity
ple 4: Construct a Moore machine that take set of all strings over
alphabet {a, b} as input and produce '1' as output if number of a's in
string mod 3=0 otherwise produce '0'.
Sol:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
Example 5: Construct a Moore machine that outputs a binary string that
contains a 1 for every double letter substring in an input string composed
of a’s and b’s. For example if abba is the input string, 0010 is the
corresponding output.
Sol:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
ComputationTheory1 A.L. Mustafa Ghanem Saeed
5| P a g e
ComputerScience Department Collage of Science CihanUniversity
Mealy Machines:
A Mealy machine M is the 5 tuple, M = (Q, , ,Г, Ϩ, q0) where:
1. A finite set of states q0,q1,q2,…, where q0 is designated the start
state
2. An alphabet Σ of input letters
3. An alphabet Г of output characters
4. A finite set of transitions that indicate, for each state and letter of
the input alphabet, the state to go to next and the character that is
output.
Note: There are no accept states in Moore and Mealy machine because
they are not a language recognizer, they are an output producer. Its
output will be the same length as its input.
Example 1:
Input alphabet: Σ = {a, b}
Output alphabet: Г = {0, 1}
Names of states: q0, q1, q2, q3. (q0 = start state)
Q Ϩ(q, a) Г(q, a) Ϩ(q, b) Г(q, b)
q0 q1 0 q3 0
q1 q3 1 Q2 1
q2 q3 0 q3 1
q3 q3 1 q0 1
Sol:
The Mealy machine is:
ComputationTheory1 A.L. Mustafa Ghanem Saeed
6| P a g e
ComputerScience Department Collage of Science CihanUniversity
Quick review for Binary system complements
As the binary system has base r = 2. So the two types of complements for
the binary system are 2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and
all 0's to 1's. This is called as taking complement or 1's complement.
Example of 1's Complement is as follows.
2's complement
The 2's complement of binary number is obtained by adding 1 to the
Least Significant Bit (LSB) of 1's complement of the number.
2's complement = 1's complement + 1
Example of 2's Complement is as follows.
Note:
 Two’s complement is especially important because it allows us to represent signed
numbers in binary.
ComputationTheory1 A.L. Mustafa Ghanem Saeed
7| P a g e
ComputerScience Department Collage of Science CihanUniversity
 Two’s complement also provides an easier way to subtract numbers using
addition instead of using the longer.
Example 2:
The following Mealy machine prints out the 1's complement of an input
bit string.in other words it flips each digit from a 0 to a 1 or from a 1 to a
0.
Note: If the input is 001010, the output is 110101.This is a case where
the input alphabet and output alphabet are both {0, 1}.
Example 3:
Construct a Mealy machine that take set of all strings over alphabet {0, 1}
as input and produce 'E' as output if number of 1's in string mod 2=0
produce 'O' as output if number of 1's in string mod 2=0.
Sol:
Input alphabet: Σ = {0, 1}
Output alphabet: Г = {E, O}
Note: The machine represented in in example 2, outputs an E if the
number of 1s read so far is even and an O if it is odd; for example, the
translation of 11100101 is OEOOOEEO.
Example 4:
Construct a Mealy machine that take set of all strings over alphabet {0, 1}
and make 2's complement of an input bit string in binary number.
Sol:
Input alphabet: Σ = {0, 1}
Output alphabet: Г = {0,1}
ComputationTheory1 A.L. Mustafa Ghanem Saeed
8| P a g e
ComputerScience Department Collage of Science CihanUniversity
Note: The machine represented in in example 4, if the input is 1010100,
the output is 0101100. This is a casewhere the input alphabet and output
alphabet are both {0, 1}.
Mealy and Moore machines are equivalent
If Mealy machine capture a model, so does a Moore machine
 Moore model might require more states to model a system but
simpler to understand
 Mealy model might require less states to model but might be more
complex to understand
Note: All examples in Moore machine can be solvein mealy Machine
and vris versa becauseMealy and Mooremachines are equivalent, you
have totry solving themas Homework.

More Related Content

What's hot

What's hot (20)

TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
 
Input & Output
Input & OutputInput & Output
Input & Output
 
Register Organization of 80386
Register Organization of 80386Register Organization of 80386
Register Organization of 80386
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammar
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
push down automata
push down automatapush down automata
push down automata
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Computer Organization
Computer OrganizationComputer Organization
Computer Organization
 
TOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite AutomataTOC 2 | Deterministic Finite Automata
TOC 2 | Deterministic Finite Automata
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer Architecture
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Compiler Design Unit 2
Compiler Design Unit 2Compiler Design Unit 2
Compiler Design Unit 2
 
Pushdown Automata Theory
Pushdown Automata TheoryPushdown Automata Theory
Pushdown Automata Theory
 

Viewers also liked

PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃO
PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃOPLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃO
PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃOCURSO DE PP NA ZUMBI DOS PALMARES
 
Syukri 4I 2016
Syukri 4I 2016Syukri 4I 2016
Syukri 4I 2016HazelHuang
 
Continuous integration (d.atanasov)
Continuous integration (d.atanasov)Continuous integration (d.atanasov)
Continuous integration (d.atanasov)Deyan Atanasov
 
安富人生_2010_01
安富人生_2010_01安富人生_2010_01
安富人生_2010_01cmchien
 
It's all about apps: a gestão ágil de aplicativos mobile
It's all about apps: a gestão ágil de aplicativos mobileIt's all about apps: a gestão ágil de aplicativos mobile
It's all about apps: a gestão ágil de aplicativos mobileAna Cecília Bisso Nunes
 
Tricia 4R 2016
Tricia 4R 2016Tricia 4R 2016
Tricia 4R 2016HazelHuang
 
Candy Liew 4E 2016
Candy Liew 4E 2016Candy Liew 4E 2016
Candy Liew 4E 2016HazelHuang
 
Inbound Marketing: o que é e por que não podemos ignorá-lo?
Inbound Marketing: o que é e por que não podemos ignorá-lo?Inbound Marketing: o que é e por que não podemos ignorá-lo?
Inbound Marketing: o que é e por que não podemos ignorá-lo?Mercado Binário
 
Internship PPT on JSTI 2016
Internship PPT on JSTI 2016Internship PPT on JSTI 2016
Internship PPT on JSTI 2016NARENDRA KUMAR
 
Introducción a la ps. clínica
Introducción a la ps. clínicaIntroducción a la ps. clínica
Introducción a la ps. clínicaUTPL UTPL
 
Biodiesel production from various oils
Biodiesel production from various oilsBiodiesel production from various oils
Biodiesel production from various oilsChaitanya kumar
 
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)Paul Marriott
 
Introduction to working capital
Introduction to working capitalIntroduction to working capital
Introduction to working capitalGeoff Burton
 
Dicas essenciais de SEO para e-commerce
Dicas essenciais de SEO para e-commerceDicas essenciais de SEO para e-commerce
Dicas essenciais de SEO para e-commerceMoip
 
Experimental Investigation of Floating slab Incorporated with Pumice stone an...
Experimental Investigation of Floating slab Incorporated with Pumice stone an...Experimental Investigation of Floating slab Incorporated with Pumice stone an...
Experimental Investigation of Floating slab Incorporated with Pumice stone an...Prasanth Gowthama
 
Getting Things Done: A Arte de Fazer Acontecer com Salesforce
Getting Things Done: A Arte de Fazer Acontecer com SalesforceGetting Things Done: A Arte de Fazer Acontecer com Salesforce
Getting Things Done: A Arte de Fazer Acontecer com SalesforceSalesforce Brasil
 
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016Salesforce Brasil
 

Viewers also liked (19)

PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃO
PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃOPLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃO
PLANEJAMENTO DE APLICATIVO PARA MOBILE E WEB - AGÊNCIA CLASSIC COMUNICAÇÃO
 
Syukri 4I 2016
Syukri 4I 2016Syukri 4I 2016
Syukri 4I 2016
 
Continuous integration (d.atanasov)
Continuous integration (d.atanasov)Continuous integration (d.atanasov)
Continuous integration (d.atanasov)
 
安富人生_2010_01
安富人生_2010_01安富人生_2010_01
安富人生_2010_01
 
Net syllabus
Net syllabusNet syllabus
Net syllabus
 
Violencia en la sociedad
Violencia en la sociedadViolencia en la sociedad
Violencia en la sociedad
 
It's all about apps: a gestão ágil de aplicativos mobile
It's all about apps: a gestão ágil de aplicativos mobileIt's all about apps: a gestão ágil de aplicativos mobile
It's all about apps: a gestão ágil de aplicativos mobile
 
Tricia 4R 2016
Tricia 4R 2016Tricia 4R 2016
Tricia 4R 2016
 
Candy Liew 4E 2016
Candy Liew 4E 2016Candy Liew 4E 2016
Candy Liew 4E 2016
 
Inbound Marketing: o que é e por que não podemos ignorá-lo?
Inbound Marketing: o que é e por que não podemos ignorá-lo?Inbound Marketing: o que é e por que não podemos ignorá-lo?
Inbound Marketing: o que é e por que não podemos ignorá-lo?
 
Internship PPT on JSTI 2016
Internship PPT on JSTI 2016Internship PPT on JSTI 2016
Internship PPT on JSTI 2016
 
Introducción a la ps. clínica
Introducción a la ps. clínicaIntroducción a la ps. clínica
Introducción a la ps. clínica
 
Biodiesel production from various oils
Biodiesel production from various oilsBiodiesel production from various oils
Biodiesel production from various oils
 
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)
Introducing The Digital Enterprise (SAUG Keynote, Brisbane, May 2016)
 
Introduction to working capital
Introduction to working capitalIntroduction to working capital
Introduction to working capital
 
Dicas essenciais de SEO para e-commerce
Dicas essenciais de SEO para e-commerceDicas essenciais de SEO para e-commerce
Dicas essenciais de SEO para e-commerce
 
Experimental Investigation of Floating slab Incorporated with Pumice stone an...
Experimental Investigation of Floating slab Incorporated with Pumice stone an...Experimental Investigation of Floating slab Incorporated with Pumice stone an...
Experimental Investigation of Floating slab Incorporated with Pumice stone an...
 
Getting Things Done: A Arte de Fazer Acontecer com Salesforce
Getting Things Done: A Arte de Fazer Acontecer com SalesforceGetting Things Done: A Arte de Fazer Acontecer com Salesforce
Getting Things Done: A Arte de Fazer Acontecer com Salesforce
 
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016
O Futuro do Atendimento na Era do Cliente Conectado: Salesforce WT 2016
 

Similar to Finite State Machines with Output

Lesson 18 Automata .ppt
Lesson 18 Automata .pptLesson 18 Automata .ppt
Lesson 18 Automata .pptGeekyHassan
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machineEhatsham Riaz
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introductionNAMRATA BORKAR
 
Formalization Machines and Sastes
Formalization Machines and SastesFormalization Machines and Sastes
Formalization Machines and SastesLahiru Danushka
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdfFariyaTasneem1
 
state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdfrdjo
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machinesAYESHA JAVED
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! EdholeEdhole.com
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! EdholeEdhole.com
 
String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,8neutron8
 
Chapter 8 Root Locus Techniques
Chapter 8 Root Locus TechniquesChapter 8 Root Locus Techniques
Chapter 8 Root Locus Techniquesguesta0c38c3
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 

Similar to Finite State Machines with Output (20)

Lesson 18 Automata .ppt
Lesson 18 Automata .pptLesson 18 Automata .ppt
Lesson 18 Automata .ppt
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
 
Mealy and moore machine
Mealy and moore machineMealy and moore machine
Mealy and moore machine
 
Chapter7
Chapter7Chapter7
Chapter7
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
Formalization Machines and Sastes
Formalization Machines and SastesFormalization Machines and Sastes
Formalization Machines and Sastes
 
Flat
FlatFlat
Flat
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdf
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! Edhole
 
Free Ebooks Download ! Edhole
Free Ebooks Download ! EdholeFree Ebooks Download ! Edhole
Free Ebooks Download ! Edhole
 
String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,
 
Automaton
AutomatonAutomaton
Automaton
 
Assignment8
Assignment8Assignment8
Assignment8
 
Chapter 8 Root Locus Techniques
Chapter 8 Root Locus TechniquesChapter 8 Root Locus Techniques
Chapter 8 Root Locus Techniques
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 

Finite State Machines with Output

  • 1. ComputationTheory1 A.L. Mustafa Ghanem Saeed 1| P a g e ComputerScience Department Collage of Science CihanUniversity Finite State Machines with Output (Mealy and Moore Machines) We shall investigate two different models for FA's with output capabilities; these are Moore machine and Mealy machine. Moore Machines: A Moore machine M is the 5 tuple M = (Q,, Г, Ϩ, q0) where 1. A finite set of states q0, q1, q2, …, where q0 is designed as the start state. 2. An alphabet of letters for forming the input string Σ= { a, b, c, …}. 3. An alphabet of possible output characters Г = { x, y, z, …}. 4. A transition function Ϩ as in table that shows for each state and each input letter what state is reached next. 5. Start state as q0. An output table that shows what character from Г is printed by each state that is entered. A Moore machine does not define a language of accepted words, since every input string creates an output string and there is no such thing as a final state. The processing is terminated when the last input letter is read and the last output character is printed. Example 1: Input alphabet: Σ = {a, b} Output alphabet: Г = {0, 1} Names of states: q0, q1, q2, q3. (q0 = start state) Q Ϩ(q, a) Ϩ(q, b) Г(Q) q0 q1 q3 1 q1 q3 q1 0 q2 q0 q3 0 q3 q1 q2 1 Sol: The Moore machine is:
  • 2. ComputationTheory1 A.L. Mustafa Ghanem Saeed 2| P a g e ComputerScience Department Collage of Science CihanUniversity Note1:  The two symbols inside the circle are separated by a slash "/", on the left side is the nameof the state and on the right is the outputfrom that state.  If the inputstring is abab to the Moore machinethen the output will be 10010. Note 2: A Moore machineis very similar to a Finite Automaton (FA), with a few key differences: • It has no final states. • It does not accept or reject input; instead, it generates output from input. • Moore machines cannothave nondeterministic states. Every input gives output not if word belongs to the machine or language like FA In each state we stop we have to print out what inside that state (it's content) so the output will be more than input by one because we start with start state and print out its content before we trace the input string Example 2: construct a Moore machine that take set of all strings over Alphabet {a, b} as input and print 1 as output for every occurrence of 'aab' as substring. Sol: Input alphabet: Σ = {a, b} Output alphabet: Г = {0, 1}
  • 3. ComputationTheory1 A.L. Mustafa Ghanem Saeed 3| P a g e ComputerScience Department Collage of Science CihanUniversity Input string aaababbaabb State q0q1q2q2q3q1q0q0q1q2q3q0 Output 000010000010 this machine gives 1 after each aab aabaabaaababaab 0001001000100001 Note:  Moore machine use as a string recognizer to give us a mark (1) after each substring so we design a machine put 0 in all states except the one after the one represent end of substring aab  The output of the machine contains 1 for each occurrence of the substring aab found in the input string. Example 3: Construct a Moore machine that take set of all strings over Alphabet {0, 1} as input and produce 'A' as output if input end with (10) or produce 'B' as output if input end with (11) otherwise produce 'C' . Sol: Input alphabet: Σ = {0, 1} Output alphabet: Г = {A, B, C} Exam
  • 4. ComputationTheory1 A.L. Mustafa Ghanem Saeed 4| P a g e ComputerScience Department Collage of Science CihanUniversity ple 4: Construct a Moore machine that take set of all strings over alphabet {a, b} as input and produce '1' as output if number of a's in string mod 3=0 otherwise produce '0'. Sol: Input alphabet: Σ = {a, b} Output alphabet: Г = {0, 1} Example 5: Construct a Moore machine that outputs a binary string that contains a 1 for every double letter substring in an input string composed of a’s and b’s. For example if abba is the input string, 0010 is the corresponding output. Sol: Input alphabet: Σ = {a, b} Output alphabet: Г = {0, 1}
  • 5. ComputationTheory1 A.L. Mustafa Ghanem Saeed 5| P a g e ComputerScience Department Collage of Science CihanUniversity Mealy Machines: A Mealy machine M is the 5 tuple, M = (Q, , ,Г, Ϩ, q0) where: 1. A finite set of states q0,q1,q2,…, where q0 is designated the start state 2. An alphabet Σ of input letters 3. An alphabet Г of output characters 4. A finite set of transitions that indicate, for each state and letter of the input alphabet, the state to go to next and the character that is output. Note: There are no accept states in Moore and Mealy machine because they are not a language recognizer, they are an output producer. Its output will be the same length as its input. Example 1: Input alphabet: Σ = {a, b} Output alphabet: Г = {0, 1} Names of states: q0, q1, q2, q3. (q0 = start state) Q Ϩ(q, a) Г(q, a) Ϩ(q, b) Г(q, b) q0 q1 0 q3 0 q1 q3 1 Q2 1 q2 q3 0 q3 1 q3 q3 1 q0 1 Sol: The Mealy machine is:
  • 6. ComputationTheory1 A.L. Mustafa Ghanem Saeed 6| P a g e ComputerScience Department Collage of Science CihanUniversity Quick review for Binary system complements As the binary system has base r = 2. So the two types of complements for the binary system are 2's complement and 1's complement. 1's complement The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's. This is called as taking complement or 1's complement. Example of 1's Complement is as follows. 2's complement The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit (LSB) of 1's complement of the number. 2's complement = 1's complement + 1 Example of 2's Complement is as follows. Note:  Two’s complement is especially important because it allows us to represent signed numbers in binary.
  • 7. ComputationTheory1 A.L. Mustafa Ghanem Saeed 7| P a g e ComputerScience Department Collage of Science CihanUniversity  Two’s complement also provides an easier way to subtract numbers using addition instead of using the longer. Example 2: The following Mealy machine prints out the 1's complement of an input bit string.in other words it flips each digit from a 0 to a 1 or from a 1 to a 0. Note: If the input is 001010, the output is 110101.This is a case where the input alphabet and output alphabet are both {0, 1}. Example 3: Construct a Mealy machine that take set of all strings over alphabet {0, 1} as input and produce 'E' as output if number of 1's in string mod 2=0 produce 'O' as output if number of 1's in string mod 2=0. Sol: Input alphabet: Σ = {0, 1} Output alphabet: Г = {E, O} Note: The machine represented in in example 2, outputs an E if the number of 1s read so far is even and an O if it is odd; for example, the translation of 11100101 is OEOOOEEO. Example 4: Construct a Mealy machine that take set of all strings over alphabet {0, 1} and make 2's complement of an input bit string in binary number. Sol: Input alphabet: Σ = {0, 1} Output alphabet: Г = {0,1}
  • 8. ComputationTheory1 A.L. Mustafa Ghanem Saeed 8| P a g e ComputerScience Department Collage of Science CihanUniversity Note: The machine represented in in example 4, if the input is 1010100, the output is 0101100. This is a casewhere the input alphabet and output alphabet are both {0, 1}. Mealy and Moore machines are equivalent If Mealy machine capture a model, so does a Moore machine  Moore model might require more states to model a system but simpler to understand  Mealy model might require less states to model but might be more complex to understand Note: All examples in Moore machine can be solvein mealy Machine and vris versa becauseMealy and Mooremachines are equivalent, you have totry solving themas Homework.