You are on page 1of 14

Ogunbanwo A.

Simbo CSC 425

FORMAL MODELS OF COMPUTATIONS


LECTURE NOTE 1 & 2

Modelling is the process of gaining a deeper understanding of a system through


imitation. Models imitate the system and reflect properties of the system.
Models of dynamics specify what a system does; that is, how it reacts to stimulus
from its environment, and how it evolves over time. Modelling plays a central
role in modern design processes.
The purpose of the theory of computation is to develop formal mathematical
models of computation that reflect real-world computers. Therefore, a model of
computation is a model which describes how an output of a mathematical
function is computed given an input. Models of computation is used to measure
the computational complexity of an algorithm. It is created to simulate a set of
processes observed in the natural world in order to gain an understanding of
these processes and to predict the outcome of natural processes given a specific
set of input parameters.
The theory of computation can be divided into the following three areas:
Complexity Theory, Computability Theory, and Automata.

 Complexity Theory: Classify problems according to their degree of


“difficulty”. Give a rigorous proof that problems that seem to be “hard”
are really “hard”.
 Computability Theory: Classify problems as being solvable or unsolvable.
 Automata Theory: Do these models have the same power, or can one
model solve more problems than the other?
For the purpose of the class, automata theory and computation theory will be
focussed on.
Background Mathematics
 Notations and Meaning
Ʌ and v or Ɐ for all ⱻ exist →/ implies
↔//≡ iff/equivalent Ɛ/λ empty string є is in ∑ alphabet
∩ intersection ᴜ union  subset |x| length of string ¬ not
∑* all finite string over alphabet ∑ a є A element of a belong to set of A

Page 1 of 14
Ogunbanwo A. Simbo CSC 425

{a1…an} the set with element a1…an

Ordinary state

 Some Logic
A ∧ B Conjunction A ∨ B Disjunction A ⇒ B Implication
A iff B Equivalence ¬A Negation

 Set
A Set is a collection of well-defined objects. R = {1, 2} S = {4, 3, 2}
Union: The union of R and S, R ∪ S, is the set of elements occurring in R or S (or
both). (x: ∈ R or x ∈ S). e.g. {1, 2} ∪ {4, 3, 2} = {1, 2, 3, 4}
Intersection: The intersection of R and S, R n S, is the set of elements occurring
in both R and S. (x: ∈ R and x ∈ S). e.g. {1, 2} n {4, 3, 2} = {2}
Set difference: R - S is the set of elements that occur in R but not in S. Note that
S may have elements not in R. These are ignored, e. g {1, 2, 3} - {2, 4} = {1, 3}.
Cartesian product of R and S is defined as R × S = {(x, y) : x ∈ R and y ∈ S} e.g.
{1, 2} ∪ {4, 3, 2} = {1, 2, 2, 3, 4}

 Definitions:
Alphabet: An alphabet is a finite non empty set of symbols or letters denoted by
Σ. The elements of the alphabet are called letters. The choice of the alphabet
depends on the application in mind. Alphabet can be represented as a
characters or digits. The most common alphabet is binary alphabet 0 and 1.
Example 1: Σ1 = (a, b … z)
Σ2 = (0, 1)
Σ3 = (#, $, & …)
String: A string is a finite sequence of symbols that are chosen from a specific
finite set or alphabet, which is usually written next to one another and not
separated by comma. Therefore, a string over an alphabet is a finite sequence
of symbols from that alphabet, which is usually written next to one another and
not separated by commas.

Page 2 of 14
Ogunbanwo A. Simbo CSC 425

Example 2: If Σ = (0, 1) then 0101 is a string over Σ


If S a = {0,1} then 001001 is a string over S a
If Sb = {a, b, KK z} then axyrpqstcd is a string over Sb .

Kleene Star: Given an alphabet Σ, Σ* is defined as the set of all possible strings
over the alphabet Σ. The * denotes the Kleene star operator. Σꝏ to denote the
set of all infinite sequences over the alphabet Σ.

For example 3: if Σ = {0, 1}, the set of strings ({ε, 1, 00, 01, 10, 11, 000, 001,
010, 011, 100, 101, 110, 111, 0000, …}

Length of String: The length of a string is its length as a sequence (number of


character in the string. The length of a string x is written as |x| and can be any
non-negative integer.
Example 3: |10011| = 5
|aab| = 3
|Ɛ| = 0
Empty String: The string of zero length is called the empty string. The empty
string plays the role of 0 in a number system and it is denoted by Ɛ or λ
Language: A language is denoted by L and is defined as set (possibly infinite) of
strings over some finite alphabet or a possibly infinite set of strings over a finite
alphabet.
Grammar: A grammar is a way to characterize a language L, a way to list out
which strings are in L and which are not or is a set of rules for forming strings in
a formal language.

Page 3 of 14
Ogunbanwo A. Simbo CSC 425

AUTOMATA THEORY
Automata theory is the study of abstract machines and computational problem
that can be solved using these machines. Automata Theory deals with
definitions and properties of different types of computation models. For
example model like Finite Automata are used in text processing, compilers, and
hardware design. Context-Free Grammars are used to define programming
languages and in Artificial Intelligence while Turing Machines is a simple abstract
model of a “real” computer, such as your PC at home. Automaton is a singular
form of automata.
Automata
An automaton is an abstract model of a digital computer. As such, every
automaton includes some essential features. It has a mechanism for reading
input. It will be assumed that the input is a string over a given alphabet, written
on an input file, which the automaton can read but not change. The input file is
divided into cells, each of which can hold one symbol. The input mechanism can
read the input file from left to right, one symbol at a time. The input mechanism
can also detect the end of the input string (by sensing an end-of-file condition).
The automaton can produce output of some form. It may have a temporary
storage device, consisting of an unlimited number of cells, each capable of
holding a single symbol from an alphabet (not necessarily the same one as the
input alphabet). The automaton can read and change the contents of the
storage cells. Finally, the automaton has a control unit, which can be in any one
of a finite number of internal states, and which can change state in some
defined manner.

Schematic representation of a general automaton

Page 4 of 14
Ogunbanwo A. Simbo CSC 425

An automaton is assumed to operate in a discrete timeframe. At any given time,


the control unit is in some internal state, and the input mechanism is scanning a
particular symbol on the input file. The internal state of the control unit at the
next time step is determined by the next-state or transition function. This
transition function gives the next state in terms of the current state, the current
input symbol, and the information currently in the temporary storage. During
the transition from one time interval to the next, output may be produced or
the information in the temporary storage changed. The term configuration will
be used to refer to a particular state of the control unit, input file, and temporary
storage. The transition of the automaton from one configuration to the next will
be called a move.
Automaton operates in the following manner. At the initial time, it is assumed
to be in the initial state q0, with its input mechanism on the leftmost symbol of
the input string. During each move of the automaton, the input mechanism
advances one position to the right, so each move consumes one input symbol.
When the end of the string is reached, the string is accepted if the automaton is
in one of its final states. Otherwise the string is rejected. The input mechanism
can move only from left to right and reads exactly one symbol on each step. The
transitions from one internal state to another are governed by the transition
function ∂.
In discussing automata, it is essential to have a clear and intuitive picture to work
with. To visualize and represent finite automata, we use transition graphs, in
which the vertices represent states and the edges represent transitions. The
labels on the vertices are the names of the states, while the labels on the edges
are the current values of the input symbol. While graphs are convenient for
visualizing automata, other representations are also useful. For example, we can
represent the function d as a table. The row label is the current state, while the
column label represents the current input symbol. The entry in the table defines
the next state.

∂ 0 1

q1 q1 q2

q2 q1 q2

Page 5 of 14
Ogunbanwo A. Simbo CSC 425

An example: Controlling a toll gate


Before we give a formal definition of a finite automaton, we consider an example
in which such an automaton shows up in a natural way. We consider the
problem of designing a “computer” that controls a toll gate. When a car arrives
at the toll gate, the gate is closed. The gate opens as soon as the driver has payed
25 Naira. We assume that we have only three coin denominations: 5, 10, and 25
Naira. We also assume that no excess change is returned. After having arrived
at the toll gate, the driver inserts a sequence of coins into the machine. At any
moment, the machine has to decide whether or not to open the gate, i.e.,
whether or not the driver has paid 25 Naira (or more). In order to decide this,
the machine is in one of the following six states, at any moment during the
process:
• The machine is in state q0, if it has not collected any money yet.
• The machine is in state q1, if it has collected exactly 5 Naira.
• The machine is in state q2, if it has collected exactly 10 Naira.
• The machine is in state q3, if it has collected exactly 15 Naira.
• The machine is in state q4, if it has collected exactly 20 Naira.
• The machine is in state q5, if it has collected 25 Naira or more.
Initially (when a car arrives at the toll gate), the machine is in state q0. Assume,
for example, that the driver presents the sequence (10,5,5,10) of coins.
• After receiving the first 10 Naira coin, the machine switches from state
q0 to state q2.
• After receiving the first 5 Naira coin, the machine switches from state q2
to state q3.
• After receiving the second 5 Naira coin, the machine switches from state
q3 to state q4.
• After receiving the second 10 Naira coin, the machine switches from
state q4 to state q5. At this moment, the gate opens. (Remember that no
change is given.)

The figure below represents the behaviour of the machine for all possible
sequences of coins. State q5 is represented by two circles, because it is a special
state: As soon as the machine reaches this state, the gate opens.

Page 6 of 14
Ogunbanwo A. Simbo CSC 425

Observe that the machine (or computer) only has to remember which state it is
in at any given time. Thus, it needs only a very small amount of memory: It has
to be able to distinguish between any one of six possible cases and, therefore, it
only needs a memory of [log 6] = 3 bits.

Types of Automaton

 Deterministic Automata
 Non-deterministic Automata

Deterministic Automata:
A deterministic automaton is one in which each move (transition from one state to
another) is unequally determined by the current configuration. If the internal state,
input and contents of the storage are known, it is possible to predict the future
behaviour of the automaton. This is said to be deterministic automata otherwise it is
nondeterministic automata. An automaton whose output response is “yes” or “No” is
called an “Acceptor”.

Formal definition of DFA

A deterministic finite automata (DFA) is a 5-tuple. M = (Q, ∑, ∂, q0, F) where

Q is a finite set of internal states,

∑ is a finite set of symbols called the input alphabet,

∂:Q × ∑ → Q is a total function called the transition function,

q0 ∈ Q is the initial state,

F ⊆Q is a set of final states. (F is a subset of Q; the elements of F are called accept


states).

Page 7 of 14
Ogunbanwo A. Simbo CSC 425

For example: if ∂ (q0, a) = q1. This indicated that if the DFA is in state q0 and the current
input symbol is a, the DFA will go into state q1

Example 1.

Solution

From the given data;

If a string ends in a 0, it is rejected and accepted only if the string ends in a 1.


Therefore, the language is

Example 2

Obtain the state table diagram and state diagram (DFA Schematic) of the finite state
automata M = (Q, ∑, ∂, q0, F)

Page 8 of 14
Ogunbanwo A. Simbo CSC 425

F is the final state and the transition is given as

Example 3

Page 9 of 14
Ogunbanwo A. Simbo CSC 425

Assignment

1 Design a DFA, M which accepts the language L(M) = {w Є (a, b )* : w does not contain

three consecutive b’s}

Page 10 of 14
Ogunbanwo A. Simbo CSC 425

2 Obtain the DFA that accepts/recognizes the language

Page 11 of 14
Ogunbanwo A. Simbo CSC 425

Nondeterministic Finite Automata:


Nondeterministic means a choice of moves for an automaton. Rather than prescribing
a unique move in each situation, we allow a set of possible moves. Formally, we
achieve this by defining the transition function so that its range is a set of possible
states.

There are three major differences between NFA definition and the definition of a DFA.
 In a nondeterministic accepter, the range of transition (∂) is in the powerset 2 Q
so that its value is not a single element of Q but a subset of it.
 NFA allows λ as the second argument of ∂. This means that the NFA can make
a transition without consuming an input symbol. Although we still assume that
the input mechanism can only travel to the right, it is possible that it is stationary
on some moves.
 In an NFA, the set ∂ (qi,a) may be empty, meaning that there is no transition
defined for the specific situation.
Like DFA's, nondeterministic accepters can be represented by transition graphs. The
vertices are determined by Q, while an edge (qi, qj) with label a is in the graph if and
only if ∂ (qi, a) contains qj. Note that since a may be the empty string, there can be
some edges labelled λ.
A string is accepted by an nfa if there is some sequence of possible moves that will
put the machine in a final state at the end of the string. A string is rejected (that is, not
accepted) only if there is no possible sequence of moves by which a final state can be
reached.

Page 12 of 14
Ogunbanwo A. Simbo CSC 425

Example 1: Determine an NFA accepting all strings over {0, 1} which end in 1 but does
not cointain the substring 00.
Solution:

Example 2
Sketch the NFA state diagram for

Solution:

Page 13 of 14
Ogunbanwo A. Simbo CSC 425

Assignment 3
Given L is the language accepted by NFA in figure below

Page 14 of 14

You might also like