Chapter 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Chapter 1 Introduction to the Theory of

Computation
• Computer science is a practical discipline. Those who work in it often
have a marked preference for useful and tangible problems over
theoretical speculation. Theory provides concepts and principles that
help us understand the general nature of the discipline. The field of
computer science includes a wide range of special topics, from
machine design to programming. The use of computers in the real
world involves a wealth of specific detail that must be learned for a
successful application. This makes computer science a very diverse
and broad discipline.
• In this course, we will look at models that represent features at the
core of all computers and their applications. To model the hardware
of a computer, we introduce the notion of an automaton (plural,
automata).
• An automaton is a construct that possesses all the indispensable
features of a digital computer. It accepts input, produces output, may
have some temporary storage, and can make decisions in
transforming the input into the output. A formal language is an
abstraction of the general characteristics of programming languages.
A formal language consists of a set of symbols and some rules of
formation by which these symbols can be combined into entities
called sentences. We can learn a great deal about programming
languages from formal languages. In Section 1.1, we review the main
ideas from mathematics that will be required.
1.1 Mathematical Preliminaries and Notation

Sets

• A set is a collection of elements, without any structure other than


membership. To indicate that x is an element of the set 𝑆, we write
𝑥𝜖𝑆. The statement that x is not in 𝑆 is written 𝑥 ∉ 𝑆. A set is
specified by enclosing some description of its elements in curly
braces; for example, the set of integers 0,1,2 is shown as

𝑆 = {0,1,2}
• The usual set operations are union (∪),intersection (∩),and
difference(-), defined as;

𝑆1 ∪ 𝑆2 = {𝑥: 𝑥𝜖𝑆1 𝑜𝑟 𝑥𝜖𝑆2 }


𝑆1 ∩ 𝑆2 = 𝑥: 𝑥𝜖𝑆1 𝑎𝑛𝑑 𝑥𝜖𝑆2
𝑆1 − 𝑆2 = {𝑥: 𝑥𝜖𝑆1 𝑎𝑛𝑑 𝑥 ∉ 𝑆2 }
• Another basic operation is complementation. The complement of a
set S, denoted by S, consists of all elements not in S. To make this,
meaningful, we need to know what the universal set 𝑈 of all possible
elements is. If 𝑈 is specified, then

𝑆 = {𝑥: 𝑥𝜖𝑈 𝑎𝑛𝑑 𝑥 ∉ 𝑆}


• The set with no elements, called the empty set or the null set is
denoted by 𝜙. From the definition of a set, it is obvious that

𝑆 ∪ 𝜙 = 𝑆 − 𝜙 = 𝑆,

𝑆 ∩ 𝜙 = 𝜙,

𝜙 = 𝑈,

𝑆=𝑆
• The following useful identities, known as the DeMorgan's laws,

𝑆1 ∪ 𝑆2 = 𝑆1 ∩ 𝑆2
𝑆1 ∩ 𝑆2 = 𝑆1 ∪ 𝑆2
are needed on several occasions.

• A set 𝑆1 is said to be a subset of 𝑆 if every element of 𝑆1 is also an element of 𝑆.


We write this as
𝑆1 ⊆ 𝑆

• If 𝑆1 ⊆ 𝑆, but 𝑆 contains an element not in 𝑆1 we say that 𝑆1 is a proper subset


of 𝑆; we write this as
𝑆1 ⊂ 𝑆
• If 𝑆1 and 𝑆2 have no common element, that is, 𝑆1 ∩ 𝑆2 = 𝜙,then the
sets are said to be disjoint.

• A set is said to be finite if it contains a finite number of elements;


otherwise it is infinite. The size of a finite set is the number of
elements in it; this is denoted by |𝑆|.

• A given set normally has many subsets. The set of all subsets of a set
𝑆 is called the powerset of 𝑆 and is denoted by 2𝑆 . Observe that 2𝑆 is
a set of sets.
Example 1.1
• In many of our examples, the elements of a set are ordered
sequences of elements from other sets. Such sets are said to be the
Cartesian product of other sets. For the Cartesian product of two
sets, which itself is a set of ordered pairs, we write

𝑆 = 𝑆1 𝑋𝑆2 = {(𝑥, 𝑦): 𝑥𝜖𝑆1 , 𝑦𝜖𝑆2 }


Example 1.2
Functions and Relation

• A function is a rule that assigns to elements of one set a unique


element of another set. If f denotes a function, then the first set is
called the domain of f, and the second set is its range. We write

𝑓: 𝑆1 ⟶ 𝑆2

to indicate that the domain of f is a subset of 𝑆1 and that the range of f


is a subset of 𝑆2 . If the domain of f is all of 𝑆1 , we say that f is a total
function on 𝑆1 ; otherwise f is said to be a partial function.
Example 1.3
Example 1.4
Graphs and Trees

• A graph is a construct consisting of two finite sets, the set 𝑉 =


𝑣1 , 𝑣2 , … , 𝑣𝑛 of vertices and the set 𝐸 = 𝑒1 , 𝑒2 , … , 𝑒𝑚 of edges.
Each edge is a pair of vertices from V, for instance

𝑒𝑖 = (𝑣𝑗 , 𝑣𝑘 )

is an edge from 𝑣𝑗 to 𝑣𝑘 . We say that the edge 𝑒𝑖 is an outgoing edge


for 𝑣𝑗 and an incoming edge for 𝑣𝑘 . Such a construct is actually a
directed graph (digraph), since we associate a direction (from 𝑣𝑗 to 𝑣𝑘 )
with each edge.
• Graphs are conveniently visualized by diagrams in which the vertices
represented as circles and the edges as lines with arrows connecting
the vertices. The graph with vertices 𝑣1 , 𝑣2 , 𝑣3 and edges
(𝑣1 , 𝑣3 ), 𝑣3 , 𝑣1 , 𝑣3 , 𝑣2 , 𝑣3 , 𝑣3 is depicted in Figure 1.1.
Figure 1.1
• A sequence of edges 𝑣𝑖 , 𝑣𝑗 , 𝑣𝑗 , 𝑣𝑘 , … , 𝑣𝑚 , 𝑣𝑛 is said to be a walk
from 𝑣𝑖 to 𝑣𝑛 . A walk in which no edge is repeated is said to be a
path; a path is simple if no vertex is repeated. A walk from 𝑣𝑖 , to itself
with no repeated edges is called a cycle with base 𝑣𝑖 .An edge from a
vertex to itself is called a loop. In Figure 1.1 there is a loop on vertex
𝑣3 .
• Trees are a particular type of graph. A tree is a directed graph that has
no cycles, and that has one distinct vertex, called the root, such that
there is exactly one path from the root to every other vertex. This
definition implies that the root has no incoming edges and that there
are some vertices without outgoing edges. These are called the leaves
of the tree. If there is an edge from 𝑣𝑖 , to 𝑣𝑗 then 𝑣𝑖 is said to be the
parent of 𝑣𝑗 , and the 𝑣𝑗 child of 𝑣𝑖 .

• The level associated with each vertex is the number of edges in the
path from the root to the vertex. The height of the tree is the
Iargestlevel number of any vertex. These terms are illustrated in
Figure 1.2.
Figure 1.2
1.2 Three Basic Concepts

• Three fundamental ideas are the major themes of this course:


languages, grammars and automata. In the course of our study we
will explore many results about these concepts and about their
relationship to each other.
Languages
• We are all familiar with the notion of natural languages, such as
English and French. Still, most of us would probably find it difficult to
say exactly what the word “language” means. Dictionaries define the
term informally as a system suitable for the expression of certain
ideas, facts, or concepts, including a set of symbols and rules for their
manipulation. While this gives us an intuitive idea of what a language
is, it is not sufficient as a definition for the study of formal languages.
We need a precise definition for the term.
• We start with a finite, nonempty set Σ of symbols, called the alphabet.
From the individual symbols we construct strings, which are finite
sequences of symbols from the alphabet. For example, if the alphabet
Σ = {a, b}, then abab and aaabbba are strings on Σ. With few
exceptions, we will use lowercase letters a, b, c,…for elements of Σ
and u, υ, ω,…for string names. We will write, for example, to indicate

𝑤 = 𝑎𝑏𝑎𝑎𝑎

to indicate that the string named w has the specific value abaaa.
Example 1.3
Example 1.4

You might also like