Chapter 1
Introduction
Agenda
Introduction
Mathematical preliminaries and notations
Relations between sets
Set Operations
Relation and function
Graphs and Trees
Proof techniques
Proof by induction
Proof by Contradiction
Introduction
Computer science has two major components
I. The fundamental ideas and models
underlying computing
II. Engineering techniques for the design of
computing system (both hardware and
software)
Automata and formal language is in the first
category
Introduction…
Automata is an abstract model of a digital computer
Automata theory is the study of abstract machine (a
theoretical model of a computer hardware and
software) and problems they are able to solve
Language is a system suitable for the expression of
certain ideas, facts or concepts, including a set of
symbols and rules of formation
There are two types of languages
Natural language
Formal language – developed by applying strict rules
(e.g. programming languages)
Introduction…
Why we study Automata and formal language?
To get concepts and principles that help us
understand the general nature of the discipline
To construct abstract models of a computer
It has immediate and important applications in
compiler design
programming languages
software engineering
artificial intelligence
etc
Fun by itself
Mathematical preliminaries and notations
Set – is a (well-defined) collection of objects
Examples
A = {a, b, c, d} – complete listing method
B= {1, 2, 3, …, 100} – partial listing method
C = {x | x>0 and x is even} – set builder
notation
Finite sets
infinite sets
Relations between sets
Subset (A z B)
Let A and B be sets. A is a subset of B if every
element of A also belongs to B; that is,
A z B iff (Ax) (x e A x e B).
Proper subset (A c B)
Let A and B be sets. A is a proper subset of B if
every element of A also belongs to B and B
contains at least one element which is not in A;
that is,
A c B iff (A z B and A Î B).
Relations between sets…
Equality of sets (A=B)
Two sets A and B are said to be equal if
they contain exactly the same elements;
i.e.
A = B iff (Ax) (x e A ¤ x e B).
Equivalence of sets (A~ B)
Two sets are said to be equivalent if they
contain the same number of elements
Set Operations
Union (U)
A U B = { x | x is in A or x is in B }
Intersection (n)
(A n B) = { x | x is in A and x is in B }
Disjoint sets ?
Difference (- or \)
A\B = { x | x is in A and x is not in B }
Symmetric difference (D)
A D B = (A-B) U (B-A)
Set Operations…
Cartesian Product (X)
AXB = {(x, y) | x e A and y e B}
Power set (2A)
2A =the set of all subsets of A
Number of power sets = 2|A|
Complement (‘, -)
A’ = { x | x e U and x ‰ A}
Demorgan’s law
AUB = A nB
A nB =AUB
Example
Given Two sets;
A = {a, b, c, d}
B= {1, 2, c, d}
Find:
A U B, A n B, A\B, A D B, AXB, 2A, 2B , 2-
Prove Demorgan’s law using the two sets
Which of the relationships between sets are
preserved by the two sets
Relation and function
Relations are used to describe relationships
between members of sets of objects.
Formally, a relation is just a subset of a cross
product of two sets. i.e. it is any subset of
ordered pairs.
Definition :
Let A and B be sets. A relation R from A to B is simply a
subset of A X B. If (a, b) e R, we write aRb. If (a, b)‰ R, we
write aRb.
If A = B, we say R is a relation in A.
Relation and function…
A relation R is said to be
A relation is reflexive iff (Ax)(xRx).
A relation is symmetric iff (Ax)(Ay)(xRy yRx).
A relation is transitive iff (Ax)(Ay)(Az)((xRy¶yRz)xRz).
An equivalence relation is a relation that is reflexive,
symmetric, and transitive.
E.g.1. Let A = {1, 2, 3, 4} , then R1 = AXA is equivalence
relation
E.g.2. R2 = { (K, M), k & m are parallel lines in the same
plane } is equivalence relation too
Relation and function…
A function f is a special type of relation in which each
first coordinate is associated with one and only one
second coordinate.
Definition;
A function f: A f B is a subset of A X B for which
(Aa e A) ((afb1 ¶ afb2) b1 = b)
2
Range: The range of a function f: X f Y is given by
{y e Y|Ex e X such that f(x) = y}.
Domain: The domain of a function f: X f Y is given
by {x e X|EyeY such that f(x) = y}.
Relation and function…
Let f: A f B; f is said to be
Into function(total function)
Ax e A, Ey e B such that f(x) =y – every
element of a domain is mapped -
Onto function:
Ay e B, Ex e A such that f(x) =y – every
element of a range is mapped
one to one (injective) function :
If x1 Î x2 then f(x1) Î f(x2)
Graphs and Trees
A graph is a construct consisting of two finite sets,
the set V = {v1, v2, ..., vn} of vertices
the set E = {e1,e2,...,em} of edges.
Each edge is a pair of vertices from V, from
instance ei = (vj, vk)is an edge from vj to vk.
ei is an outgoing edge for vertex vj and an
incoming edge for vertex vk
Such a construct actually is directed graph
(digraph), since we associate a direction (from vj to
vk) with each edge
Graphs and Trees …
Graphs are conveniently visualized by diagrams.
The above graph has three vertices v1, v2, and v3 and
four edges (v1, v3), (v3, v1), (v3, v2) and (v3, v3)
Graphs and Trees …
A walk is a sequence of edges.
(vi, vj), (vj, vk), …, (vm, vn) is a walk from vi to vn
The length of a walk is the total number of edges
traversed in going from initial to final vertex
Path is a walk in which no edge is repeated.
A path is simple if no vertex is repeated
Cycle - A walk from vi to itself with no repeated edges
with base vi
If no vertices other than the base are repeated in a cycle,
then it is said to be simple
Graphs and Trees …
A tree is a diagraph with the following
properties
There is one vertex called the root that has no
predecessors and from which there is a path to
every vertex
Each vertex other than the root has exactly one
predecessor (no cycle)
The successor of each vertex are ordered from
the left
Graphs and Trees …
Binary Tree
Proof Techniques
Proof is a convincing demonstration (within the accepted
standards of the field) that some mathematical statement
is necessarily true.
There are a number of proof techniques. Some of them are
Direct proof
Proof by induction
Proof by transposition
Proof by contradiction
Proof by construction,
etc
We will see proof by induction and proof by contradiction
Proof by induction
Suppose we have some statement pn and we want
to demonstrate pn is true for An e N.
In proof by induction we say pn is true for all
positive n provided that;
P1 is true
If pk is true, so is pk+1, for some k e Z+
An inductive proof has three parts:
Basis case – [P1 is true ]
Inductive hypothesis – [ If pk is true ]
Inductive step – [so is pk+1]
Proof by induction…
Example n
n(n 1)
Show that
i 1
i
2
For all n>=1.
Proof
Base case : n=1
1
1(1 1)
i
i 1 2
1 = 1
Inductive hypothesis:k k (k 1)
Suppose that i for some k>=1.
i 1 2
Inductive step: k 1
We will show that i
(k 1)(k 2)
i 1 2
k 1 k
i i (k 1)
i 1 i 1
k (k 1) by the inductive hypothesis
(k 1)
2
k (k 1) 2(k 1)
2
(k 1)(k 2)
2
It follows that for all n>=1. •
n
n(n 1)
i
i 1 2
Proof By Contradiction
Suppose we want to prove that some statement p is
true. We then assume, that p is false and see where
that assumption leads us.
Example
prove that is 2 irrational number
Proof:
Lets assume 2 is rational number
So, by definition we can write 2 as
p
2
q
Proof By Contradiction…
- where p and q are integers with no common factors
other than 1
- So, p = q 2 ,
- p2 = 2q2 (by squaring both sides)
- p2 is even. This implies p is even
- If P is even we can write p as p = 2m, where m is an
integer.
- Hence, p2 = (2m)2 = 4m2
Proof By Contradiction…
- 4m2 = 2q2
- q2 =2m2
- Again q2 is even means q is even.
- Hence, p and q are both even, which shows that p
and q have a common factor other than 1 (2).
- This contradicts our assumption.
- So, 2 is irrational