Jump to content

Moore machine: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
 
(25 intermediate revisions by 19 users not shown)
Line 1: Line 1:
In the [[theory of computation]], a '''Moore machine''' is a [[finite-state machine]] whose output values are determined only by its current [[state (computer science)|state]]. This is in contrast to a [[Mealy machine]], whose output values are determined both by its current state and by the values of its inputs. The Moore machine is named after [[Edward F. Moore]], who presented the concept in a 1956 paper, “[[Thought experiment|Gedanken-experiments]] on Sequential Machines.”<ref name="gedanken">{{cite journal| last=Moore| first=Edward F| title=Gedanken-experiments on Sequential Machines| pages=129–153| journal=Automata Studies, Annals of Mathematical Studies| issue=34| publisher=Princeton University Press| location=Princeton, N.J.| year=1956}}</ref>
{{Short description|Finite-state machine whose output values are determined only by its current state}}
{{More citations needed|date=November 2024}}
In the [[theory of computation]], a '''Moore machine''' is a [[finite-state machine]] whose current output values are determined only by its current [[state (computer science)|state]]. This is in contrast to a [[Mealy machine]], whose output values are determined both by its current state and by the values of its inputs. Like other finite state machines, in Moore machines, the input typically influences the next state. Thus the input may indirectly influence subsequent outputs, but not the current or immediate output. The Moore machine is named after [[Edward F. Moore]], who presented the concept in a 1956 paper, “[[Thought experiment|Gedanken-experiments]] on Sequential Machines.”<ref name="gedanken">{{cite journal| last=Moore| first=Edward F| title=Gedanken-experiments on Sequential Machines| pages=129–153| journal=Automata Studies, Annals of Mathematical Studies| issue=34| publisher=Princeton University Press| location=Princeton, N.J.| year=1956}}</ref>


== Formal definition ==
== Formal definition ==


A Moore machine can be defined as a [[N-tuple|6-tuple]] <math>(S, S_0, \Sigma, \Lambda, T, G)</math> consisting of the following:
A Moore machine can be defined as a [[N-tuple|6-tuple]] <math>(S, s_0, \Sigma, O, \delta, G)</math> consisting of the following:
* A finite set of [[State (computer science)|states]] <math>S</math>
* A finite set of [[State (computer science)|states]] <math>S</math>
* A start state (also called initial state) <math>S_0</math> which is an element of <math>S</math>
* A start state (also called initial state) <math>s_0</math> which is an element of <math>S</math>
* A finite set called the input [[Alphabet (computer science)|alphabet]] <math>\Sigma</math>
* A finite set called the input [[Alphabet (computer science)|alphabet]] <math>\Sigma</math>
* A finite set called the output [[Alphabet (computer science)|alphabet]] <math>\Lambda</math>
* A finite set called the output [[Alphabet (computer science)|alphabet]] <math>O</math>
* A transition [[function (mathematics)|function]] <math>T : S \times \Sigma \rightarrow S</math> mapping a state and the input alphabet to the next state
* A transition [[function (mathematics)|function]] <math>\delta : S \times \Sigma \rightarrow S </math> mapping a state and the input alphabet to the next state
* An output function <math>G : S \rightarrow \Lambda</math> mapping each state to the output alphabet
* An output function <math>G : S \rightarrow O</math> mapping each state to the output alphabet

"Evolution across time" is realized in this abstraction by having the state machine consult the time-changing input symbol at discrete "timer ticks" <math>t_0, t_1, t_2, ...</math> and react according to its internal configuration at those idealized instants, or else having the state machine wait for a next input symbol (as on a FIFO) and react whenever it arrives.


A Moore machine can be regarded as a restricted type of [[finite-state transducer]].
A Moore machine can be regarded as a restricted type of [[finite-state transducer]].


==Visual representation==
==Visual representation==

{| class="wikitable"
|-
! States !! a !! b !! output
|-
| q0 || q1|| q2 || 10
|-0
| q1 || q1 || q1 || 0
|-
| q2 || q1 || q0 || 1
|}


===Table===
===Table===
[[State transition table]] is a table showing relation between an input and a state.{{Clarify|date=June 2015}}
A [[state transition table]] is a table listing all the triples in the transition relation <math>\delta : S \times \Sigma \rightarrow S </math>.


===Diagram===
===Diagram===
The [[state diagram]] for a Moore machine or Moore diagram is a diagram that associates an output value with each state.
The [[state diagram]] for a Moore machine, or Moore diagram, is a state diagram that associates an output value with each state.
Moore machine is an output producer.


==Relationship with Mealy machines==
==Relationship with Mealy machines==
As Moore and Mealy machines are both types of finite-state machines, they are equally expressive: either type can be used to parse a [[regular language]].
As Moore and Mealy machines are both types of finite-state machines, they are equally expressive: either type can be used to parse a [[regular language]].


The difference between Moore machines and [[Mealy machine]]s is that in the latter, the output of a transition is determined by the combination of current [[state (computer science)|state]] and current input (<math>S \times \Sigma</math> as the input to <math>G</math>), as opposed to just the current state (<math>S</math> as the input to <math>G</math>). When represented as a [[state diagram]],
The difference between Moore machines and [[Mealy machine]]s is that in the latter, the output of a transition is determined by the combination of current [[state (computer science)|state]] and current input (<math>S \times \Sigma</math> as the domain of <math>G</math>), as opposed to just the current state (<math>S</math> as the domain of <math>G</math>). When represented as a [[state diagram]],
* for a Moore machine, each node (state) is labeled with an output value;
* for a Moore machine, each node (state) is labeled with an output value;
* for a Mealy machine, each arc (transition) is labeled with an output value.
* for a Mealy machine, each arc (transition) is labeled with an output value.


Every Moore machine <math>M</math> is equivalent to the Mealy machine with the same states and transitions and the output function <math>G(s, \sigma) \rightarrow G_M(s)</math>, which takes each state-input pair <math>(s, \sigma)</math> and yields <math>G_M(s)</math>, where <math>G_M</math> is <math>M</math>'s output function.
Every Moore machine <math>M</math> is equivalent to the Mealy machine with the same states and transitions and the output function <math>G(s, \sigma) = G_M(\delta_M(s, \sigma))</math>, which takes each state-input pair <math>(s, \sigma)</math> and yields <math>G_M(\delta_M(s, \sigma))</math>, where <math>G_M</math> is <math>M</math>'s output function and <math>\delta_M</math> is <math>M</math>'s transition function.


However, not every Mealy machine can be converted to an equivalent Moore machine. Some can be converted only to an ''almost'' equivalent Moore machine, with outputs shifted in time. This is due to the way that state labels are paired with transition labels to form the input/output pairs. Consider a transition <math>s_i\rightarrow s_j</math> from state <math>s_i</math> to state <math>s_j</math>. The input causing the transition <math>s_i\rightarrow s_j</math> labels the edge <math>(s_i, s_j)</math>. The output corresponding to that input, is the label of state <math>s_i</math>.<ref>{{cite book|last1=Lee|first1=Edward Ashford|last2=Seshia|first2=Sanjit Arunkumar|title=Introduction to Embedded Systems|date=2013|publisher=Lulu.com|location=UC Berkeley|isbn=9780557708574|edition=1.08|url=http://leeseshia.org/|accessdate=1 July 2014}}</ref> Notice that this is the source state of the transition. So for each input, the output is already fixed before the input is received, and depends solely on the present state. This is the original definition by E. Moore. It is a common mistake to use the label of state <math>s_j</math> as output for the transition <math>s_i\rightarrow s_j</math>.
However, not every Mealy machine can be converted to an equivalent Moore machine. Some can be converted only to an ''almost'' equivalent Moore machine, with outputs shifted in time. This is due to the way that state labels are paired with transition labels to form the input/output pairs. Consider a transition <math>s_i\rightarrow s_j</math> from state <math>s_i</math> to state <math>s_j</math>. The input causing the transition <math>s_i\rightarrow s_j</math> labels the edge <math>(s_i, s_j)</math>. The output corresponding to that input, is the label of state <math>s_i</math>.<ref>{{cite book|last1=Lee|first1=Edward Ashford|last2=Seshia|first2=Sanjit Arunkumar|title=Introduction to Embedded Systems|date=2013|publisher=Lulu.com|location=UC Berkeley|isbn=9780557708574|edition=1.08|url=http://leeseshia.org/|accessdate=1 July 2014}}</ref> Notice that this is the source state of the transition. So for each input, the output is already fixed before the input is received, and depends solely on the present state. This is the original definition by E. Moore. It is a common mistake to use the label of state <math>s_j</math> as output for the transition <math>s_i\rightarrow s_j</math>.
Line 63: Line 55:
[[File:Moore Machine.svg|Example moore machine|thumb|upright=1.5|right|alt=Example moore machine]]
[[File:Moore Machine.svg|Example moore machine|thumb|upright=1.5|right|alt=Example moore machine]]


A moore machine with nine states for the above description is shown on the right. The initial state is state A, and the final state is state I. The state table for this example is as follows:
A Moore machine with nine states for the above description is shown on the right. The initial state is state A, and the final state is state I. The state table for this example is as follows:
{| class="wikitable" style="text-align: center"
{| class="wikitable" style="text-align: center"
|-
|-
Line 96: Line 88:
| 1 || H
| 1 || H
|-
|-
| rowspan=2 | H || 0 || H || rowspan=2 | 0
| rowspan=2 | H || 0 || H || rowspan=2 |0
|-
|-
| 1 || I
| 1 || I
Line 110: Line 102:
== Gedanken-experiments ==
== Gedanken-experiments ==


In Moore's paper "[[Thought experiment|Gedanken-experiments]] on Sequential Machines",<ref name="gedanken"/> the <math>(n;m;p)</math> automata (or machines) <math>S</math> are defined as having <math>n</math> states, <math>m</math> input symbols and <math>p</math> output symbols. Nine theorems are proved about the structure of <math>S</math>, and experiments with <math>S</math>. Later, "<math>S</math> machines" became known as "Moore machines".
In Moore's 1956 paper "[[Thought experiment|Gedanken-experiments]] on Sequential Machines",<ref name="gedanken"/> the <math>(n;m;p)</math> automata (or machines) <math>S</math> are defined as having <math>n</math> states, <math>m</math> input symbols and <math>p</math> output symbols. Nine theorems are proved about the structure of <math>S</math>, and experiments with <math>S</math>. Later, "<math>S</math> machines" became known as "Moore machines".


At the end of the paper, in Section "Further problems", the following task is stated:
At the end of the paper, in Section "Further problems", the following task is stated:
Line 124: Line 116:
<blockquote>'''Theorem B.''' There exists an <math>(n;m;p)</math> machine, every two states of which are distinguishable from one another, such that the length of the shortest experiments establishing the state of the machine at the end of the experiment is equal to <math>\tfrac{(n-1)(n-2)}{2} + 1</math>.</blockquote>
<blockquote>'''Theorem B.''' There exists an <math>(n;m;p)</math> machine, every two states of which are distinguishable from one another, such that the length of the shortest experiments establishing the state of the machine at the end of the experiment is equal to <math>\tfrac{(n-1)(n-2)}{2} + 1</math>.</blockquote>


Theorems A and B were used for the basis of the course work of a student of the fourth year, A. A. Karatsuba, "On a problem from the automata theory", which was distinguished by testimonial reference at the competition of student works of the faculty of mechanics and mathematics of Moscow Lomonosow State University in 1958. The paper by Karatsuba was given to the journal ''Uspekhi Mat. Nauk'' on 17 December 1958 and was published there in June 1960.<ref>{{cite journal| last=Karatsuba| first=A. A.| title=Solution of one problem from the theory of finite automata | pages=157–159| journal=Uspekhi Mat. Nauk| issue=15:3| year=1960}}</ref>
Theorems A and B were used for the basis of the course work of a student of the fourth year, A. A. Karatsuba, "On a problem from the automata theory", which was distinguished by testimonial reference at the competition of student works of the faculty of mechanics and mathematics of [[Moscow State University]] in 1958. The paper by Karatsuba was given to the journal ''Uspekhi Mat. Nauk'' on 17 December 1958 and was published there in June 1960.<ref>{{cite journal| last=Karatsuba| first=A. A.| title=Solution of one problem from the theory of finite automata | pages=157–159| journal=Uspekhi Mat. Nauk| issue=15:3| year=1960}}</ref>


Until the present day (2011), Karatsuba's result on the length of experiments is the only exact nonlinear result, both in automata theory, and in similar problems of computational complexity theory.
Until the present day (2011), Karatsuba's result on the length of experiments is the only exact nonlinear result, both in automata theory, and in similar problems of [[computational complexity theory]].


== See also ==
== See also ==
Line 137: Line 129:
{{reflist}}
{{reflist}}


== Further reading ==
==Further reading==
* {{cite book | first=J.H. | last=Conway | authorlink=John Horton Conway | title=Regular algebra and finite machines | publisher=Chapman and Hall | year=1971 | isbn=0-412-10620-5 | zbl=0231.94041 | location=London }}
*{{cite book | first=J.H. | last=Conway | authorlink=John Horton Conway | title=Regular algebra and finite machines | publisher=Chapman and Hall | year=1971 | isbn=0-412-10620-5 | zbl=0231.94041 | location=London }}
* Moore E. F. Gedanken-experiments on Sequential Machines. Automata Studies, Annals of Mathematical Studies, 34, 129–153. Princeton University Press, Princeton, N.J.(1956).
* Moore E. F. Gedanken-experiments on Sequential Machines. Automata Studies, Annals of Mathematical Studies, 34, 129–153. Princeton University Press, Princeton, N.J.(1956).
* Karatsuba A. A. Solution of one problem from the theory of finite automata. Usp. Mat. Nauk, 15:3, 157–159 (1960).
* Karatsuba A. A. Solution of one problem from the theory of finite automata. Usp. Mat. Nauk, 15:3, 157–159 (1960).
* Karatsuba A. A. Experimente mit Automaten (German) Elektron. Informationsverarb. Kybernetik, 11, 611–612 (1975).
* Karatsuba A. A. Experimente mit Automaten (German) Elektron. Informationsverarb. Kybernetik, 11, 611–612 (1975).
* Karatsuba A. A. ''[http://www.mi.ras.ru/~karatsuba/list_e.html List of research works]''
* Karatsuba A. A. ''[http://www.mi.ras.ru/~karatsuba/list_e.html List of research works]''.

[https://www.thecompletecodes.com/2019/09/Moore-and-Mealy-Machine.html Moore-and-Mealy-Machine]

== External links ==
*{{Commonscatinline}}


[[Category:Finite automata]]
[[Category:Finite automata]]

Latest revision as of 02:46, 4 December 2024

In the theory of computation, a Moore machine is a finite-state machine whose current output values are determined only by its current state. This is in contrast to a Mealy machine, whose output values are determined both by its current state and by the values of its inputs. Like other finite state machines, in Moore machines, the input typically influences the next state. Thus the input may indirectly influence subsequent outputs, but not the current or immediate output. The Moore machine is named after Edward F. Moore, who presented the concept in a 1956 paper, “Gedanken-experiments on Sequential Machines.”[1]

Formal definition

[edit]

A Moore machine can be defined as a 6-tuple consisting of the following:

  • A finite set of states
  • A start state (also called initial state) which is an element of
  • A finite set called the input alphabet
  • A finite set called the output alphabet
  • A transition function mapping a state and the input alphabet to the next state
  • An output function mapping each state to the output alphabet

"Evolution across time" is realized in this abstraction by having the state machine consult the time-changing input symbol at discrete "timer ticks" and react according to its internal configuration at those idealized instants, or else having the state machine wait for a next input symbol (as on a FIFO) and react whenever it arrives.

A Moore machine can be regarded as a restricted type of finite-state transducer.

Visual representation

[edit]

Table

[edit]

A state transition table is a table listing all the triples in the transition relation .

Diagram

[edit]

The state diagram for a Moore machine, or Moore diagram, is a state diagram that associates an output value with each state.

Relationship with Mealy machines

[edit]

As Moore and Mealy machines are both types of finite-state machines, they are equally expressive: either type can be used to parse a regular language.

The difference between Moore machines and Mealy machines is that in the latter, the output of a transition is determined by the combination of current state and current input ( as the domain of ), as opposed to just the current state ( as the domain of ). When represented as a state diagram,

  • for a Moore machine, each node (state) is labeled with an output value;
  • for a Mealy machine, each arc (transition) is labeled with an output value.

Every Moore machine is equivalent to the Mealy machine with the same states and transitions and the output function , which takes each state-input pair and yields , where is 's output function and is 's transition function.

However, not every Mealy machine can be converted to an equivalent Moore machine. Some can be converted only to an almost equivalent Moore machine, with outputs shifted in time. This is due to the way that state labels are paired with transition labels to form the input/output pairs. Consider a transition from state to state . The input causing the transition labels the edge . The output corresponding to that input, is the label of state .[2] Notice that this is the source state of the transition. So for each input, the output is already fixed before the input is received, and depends solely on the present state. This is the original definition by E. Moore. It is a common mistake to use the label of state as output for the transition .

Examples

[edit]

Types according to number of inputs/outputs.

Simple

[edit]

Simple Moore machines have one input and one output:

Most digital electronic systems are designed as clocked sequential systems. Clocked sequential systems are a restricted form of Moore machine where the state changes only when the global clock signal changes. Typically the current state is stored in flip-flops, and a global clock signal is connected to the "clock" input of the flip-flops. Clocked sequential systems are one way to solve metastability problems. A typical electronic Moore machine includes a combinational logic chain to decode the current state into the outputs (lambda). The instant the current state changes, those changes ripple through that chain, and almost instantaneously the output gets updated. There are design techniques to ensure that no glitches occur on the outputs during that brief period while those changes are rippling through the chain, but most systems are designed so that glitches during that brief transition time are ignored or are irrelevant. The outputs then stay the same indefinitely (LEDs stay bright, power stays connected to the motors, solenoids stay energized, etc.), until the Moore machine changes state again.

alt text
Moore machine in combinational logic

Worked Example

[edit]

A sequential network has one input and one output. The output becomes 1 and remains 1 thereafter when at least two 0's and two 1's have occurred as inputs.

Example moore machine
Example moore machine

A Moore machine with nine states for the above description is shown on the right. The initial state is state A, and the final state is state I. The state table for this example is as follows:

Current state Input Next state Output
A 0 D 0
1 B
B 0 E 0
1 C
C 0 F 0
1 C
D 0 G 0
1 E
E 0 H 0
1 F
F 0 I 0
1 F
G 0 G 0
1 H
H 0 H 0
1 I
I 0 I 1
1 I

Complex

[edit]

More complex Moore machines can have multiple inputs as well as multiple outputs.

Gedanken-experiments

[edit]

In Moore's 1956 paper "Gedanken-experiments on Sequential Machines",[1] the automata (or machines) are defined as having states, input symbols and output symbols. Nine theorems are proved about the structure of , and experiments with . Later, " machines" became known as "Moore machines".

At the end of the paper, in Section "Further problems", the following task is stated:

Another directly following problem is the improvement of the bounds given at the theorems 8 and 9.

Moore's Theorem 8 is formulated as:

Given an arbitrary machine , such that every two of its states are distinguishable from one another, then there exists an experiment of length which determines the state of at the end of the experiment.

In 1957, A. A. Karatsuba proved the following two theorems, which completely solved Moore's problem on the improvement of the bounds of the experiment length of his "Theorem 8".

Theorem A. If is an machine, such that every two of its states are distinguishable from one another, then there exists a branched experiment of length at most through which one may determine the state of at the end of the experiment.

Theorem B. There exists an machine, every two states of which are distinguishable from one another, such that the length of the shortest experiments establishing the state of the machine at the end of the experiment is equal to .

Theorems A and B were used for the basis of the course work of a student of the fourth year, A. A. Karatsuba, "On a problem from the automata theory", which was distinguished by testimonial reference at the competition of student works of the faculty of mechanics and mathematics of Moscow State University in 1958. The paper by Karatsuba was given to the journal Uspekhi Mat. Nauk on 17 December 1958 and was published there in June 1960.[3]

Until the present day (2011), Karatsuba's result on the length of experiments is the only exact nonlinear result, both in automata theory, and in similar problems of computational complexity theory.

See also

[edit]

References

[edit]
  1. ^ a b Moore, Edward F (1956). "Gedanken-experiments on Sequential Machines". Automata Studies, Annals of Mathematical Studies (34). Princeton, N.J.: Princeton University Press: 129–153.
  2. ^ Lee, Edward Ashford; Seshia, Sanjit Arunkumar (2013). Introduction to Embedded Systems (1.08 ed.). UC Berkeley: Lulu.com. ISBN 9780557708574. Retrieved 1 July 2014.
  3. ^ Karatsuba, A. A. (1960). "Solution of one problem from the theory of finite automata". Uspekhi Mat. Nauk (15:3): 157–159.

Further reading

[edit]
  • Conway, J.H. (1971). Regular algebra and finite machines. London: Chapman and Hall. ISBN 0-412-10620-5. Zbl 0231.94041.
  • Moore E. F. Gedanken-experiments on Sequential Machines. Automata Studies, Annals of Mathematical Studies, 34, 129–153. Princeton University Press, Princeton, N.J.(1956).
  • Karatsuba A. A. Solution of one problem from the theory of finite automata. Usp. Mat. Nauk, 15:3, 157–159 (1960).
  • Karatsuba A. A. Experimente mit Automaten (German) Elektron. Informationsverarb. Kybernetik, 11, 611–612 (1975).
  • Karatsuba A. A. List of research works.

Moore-and-Mealy-Machine

[edit]