A computation involves inputs and outputs. Typically, we intend for there to be a specific relationship between those inputs and outputs. For example, if the intent is for the computation to perform an addition of two numbers provided as inputs, then we would not be satisfied if the output were not the number corresponding to their sum.
So think of a computer as a device, or "black box", that consumes inputs and produces outputs. Abstract away the details as to how the inputs are provided to it (e.g., button presses (such as via a keyboard or even buttons on the box itself) or mouse movements, or sensors) and in what form the output takes (e.g., textual, numbers, images, sounds). In simplest form, we can think of the inputs as being encoded as a string of bits (0's and 1's) and similarly the output. In fact, this is how things work on actual digital computers!
If you don't yet appreciate the power of using 0's and 1's to encode any kind of data, you should once you have gotten deeper into CMPS 250.
Let's consider a few simple computational problems whose solutions must realize a particular mapping between the bit strings provided as input and the outputs produced by the computation.
Contrary to the previous problems, a machine solving this one cannot simply react (or refrain therefrom) to each input symbol as it is read, without regard to the string of input symbols that it has already read/consumed. Indeed, the machine must "remember" the parity (evenness vs. oddness) of the number of bits that it has read "so far".
A machine solving this problem must be such that its reaction to each input bit depends not only upon the value of that bit but also upon the immediately preceding input bit (if any). Thus, it needs to distinguish between the three situations "no bits have been read yet" vs. "the preceding bit was a 0" vs. "the preceding bit was a 1".
For the purpose of formalizing the notion of a machine "remembering" something about the current "situation" we use the concept of state. To formalize the notion of the situation changing as a result of a bit having been read, we use the concept of transition (i.e., from one state to another). A computation can be thought of as a discrete sequence of steps, where each step begins with the machine in some (current) state. A computation step involves the machine
Which output is produced and to which state a transition occurs is a function of (i.e., is determined by) the current state and the value of the just-read input symbol.
It turns out that each of the problems described above can be solved by a machine having a finite number of states. Such a machine is called, naturally, a finite state machine (FSM) or a finite (state) automaton (FA). Most of our work in this course will involve FSMs that, in effect, produce only one bit of output, the value of which is interpreted as the answer to a YES/NO question. The variety of FSMs that solve the problems listed above are usually called Mealy machines. According to Wikipedia:
The Mealy machine is named after George H. Mealy, who presented the concept in a 1955 paper, "A Method for Synthesizing Sequential Circuits".
One way to describe an FSM is by using an edge-labeled directed graph, often called a transition graph. Each vertex/node corresponds to a state and each edge corresponds to a transition. Each edge is labeled by the input symbol that triggers it and the output that is produced when the transition is taken, separated by a slash.
Below are transition graphs describing single-state FSMs that solve the first four problems listed above.
![]() |
![]() |
![]() |
![]() |
Unary count | Echo | Complement | Unary Count of 0's |
---|
For presentation purposes, in each transition graph the single edge really represents two different transitions, one for input 0 and the other for input 1. In the transition graph for Unary Count, the edge has label 0,1/1, which is shorthand for two edges, one labeled 0/1 and the other labeled 1/1. In the remaining transition graphs, the lone edge has two labels, which is shorthand for two edges, each having one of those labels. The Greek letter λ represents the empty string, which when appearing after the slash in an edge label means that no output is produced as a result of that transition being triggered.
Below are transition graphs describing FSMs that solve the last four problems listed above. In the last one, edge labels include output information only if a non-λ output is produced.
![]() |
![]() |
Half-Length | Bit-Flip Counter |
---|
![]() |
Length-3-Run Reporter |
---|
![]() |
01101-Counter |
---|