0% found this document useful (0 votes)
6 views

Chap01 Sets

Uploaded by

Yasir Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Chap01 Sets

Uploaded by

Yasir Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 60

Discrete Structures

Course Code: CS-321


Credit Hours: 3(3-0)
Instructor: Yasir Ali
Introduction
1. Logic and Proofs
1. Logic and Proofs
Propositional Logic
Propositional Logic
Propositional Logic (Exercise)
Are each of these propositions?

1.I am a dolphin.

2.Supercalifragilisticexpialidocious.

3.Jupiter is the 5th planet from the sun.

4.On Thursdays, van Gogh painted landscapes.

5.56*3=40
Propositional Logic (Exercise)
Connectives
Negation
Conjunction
Disjunction
Disjunction
Disjunction (Exercise)
• What is the truth value of these compound propositions?
1.“The earth is round and the sky is blue.”
2.“Dogs or cats make great pets.”
3.“It is 20∘ Celsius outside and it is snowing.”
4.“Lemons are purple or grass is green”
Implication
Implication
Implication
Implication
C
Implication
Biconditional
Biconditional
• Biconditional
• Let p be “2 is an even number”. Let q be “4 is an even number”. p↔q is a
biconditional and its truth value is true, since both p and q are true.
Biconditional (Exercise)
• What is the truth value of these compound propositions?
1.“The Earth is flat” → “Pigeons are robots” (T)
2.“Bats have wings” → “Bats are birds” (f)
3.“A square is a rectangle” ↔ “A square had four 90∘ interior angles” (T)
4.“Spinach is green” ↔ “Penguins can fly” (f)
Propositional Formulas
Discrete Structure Fundamentals [ Set ]

George Cantor (1845-1915), in 1895, was the first to define a set


formally.
Set
Definition
A set is an unordered collection of zero or more distinct well defined objects.
Or
The collection of well defined distinct elements

The objects that make up a set are called


elements or members of the set.
Specifying sets
There are three ways to specify a set
• Tabular form
E.g. A = {a, e, i, o, u}
• Descriptive form
e.g. set of vowels
• Set builder form
State those properties which characterized the members in the set.
E.g. B = {x : x is an even integer, x > 0}
We read this as “B is the set of x such that x is an even integer and x is grater than zero”. Note that
we can’t list all the members in the set B.
A = {x : x is a vowel}
Properties of set
1. The order in which the elements are presented in a set is not important.
i. A = {a, e, i, o, u} and
ii. B = {e, o, u, a, i} both define the same set.

2. The members of a set can be anything.

3. In a set the same member does not appear more than once.
F = {a, e, i, o, a, u} is incorrect since the element ‘a’ repeats.
We Some common
denote following sets by sets
the following symbols:
N = The set of positive integers/ The set of natural numbers = {1, 2, 3, ……………}
W = The set of whole numbers = {0, 1, 2, 3, ……………}

Z = The set of integers = {….-3, -2, -1, 0, 1, 2, 3….}


R = The set of real numbers = {x: - ∞ < x < ∞}
Q = The set of rational numbers = {x: x = m/n, n ≠ 0}
I = The set of irrational numbers = {x: x ≠ m/n}
Universal set and Empty set
• The members of all the investigated sets in a particular problem usually
belongs to some fixed large set. That set is called the universal set and is
usually denoted by ‘U’.

• The set that has no elements is called “Empty set” and is denoted by  or
{}.
• E.g. {x | x2 = 4 and x is an odd integer} = 
Equality
• A set oftotwo
‘A’ is equal a setsets
‘B’ if and only if both sets have the same
elements. If sets ‘A’ and ‘B’ are equal we write: A = B. If sets ‘A’ and ‘B’ are
not equal we write A  B.

• In other words we can say:


A = B  (x, xA  xB)
e.g.
A = {1, 2, 3, 4, 5}, B = {3, 4, 1, 2, 5}, C = {1, 3, 5, 4}
D = {x : x  N  0 < x < 6}, E = {1, 10/5, √9, 22, 5} then A = B = D = E and A  C.
Cardinality of set
• The number of elements in a set is called the
cardinality of that set.

Let ‘A’ be any set then its cardinality is denoted by |A|


e.g. A = {a, e, i, o, u} then |A| = 5.
Subset
• Set ‘A’ is called a subset of set ‘B’ if and only if every element of set ‘A’ is
also an element of set ‘B’. We also say that ‘A’ is contained in ‘B’ or that ‘B’
contains ‘A’. It is denoted by A  B or B  A.

• In other words we can say:


(A  B)  ( x, x  A  x  B)
Subsets
• If ‘A’ is not a subset of ‘B’ then it is denoted by
A  B or B  A
e.g. A = {1, 2, 3, 4, 5} and B = {1, 3} and C = {2, 4, 6} then B  A and C  A

A
B
5 C
1 3 4
2 6
Proper subset
• Notice that when we say A  B then it is even possible to be A = B.

• We say that set ‘A’ is a proper subset of set ‘B’ if and only if A  B and A 
B. it is denoted by

• In other words we can say:


(A  B)  (x, xA  xB  AB)
Improper subset
• We say that set ‘A’ is an improper subset of set ‘B’ if and only if A  B and
A=B. It is denoted by . In other words we can say:

(A  B)  (x, xA  xB  A=B)


Power set
• The set of all subsets of a set ‘S’ is called the power set of ‘S’. It is denoted
by P(S) or 2S.

• In other words we can say:


P(S) = {x : x  S}
e.g. A = {1, 2, 3} then
P(A) = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
• Note that |P(S)| = 2|S|.
e.g. |P(A)| = 2|A| = 23 = 8.
Set operations “Complement”

The (absolute) complement of a set ‘A’ is the set of elements which belongs
to the universal set but does not belong to A. This is denoted by Ac or Ā or
Á.

• In other words we can say:

• Ac = {x : xU  xA}
Set operations Union
 Union of two sets ‘A’ and ‘B’ is the set of all elements which belong to either
‘A’ or ‘B’ or both. This is denoted by A  B.

 In other words we can say:


A  B = {x : xA  xB}
e.g. A = {3, 5, 7}, B = {2, 3, 5}
A  B = {3, 5, 7, 2, 3, 5} = {2, 3, 5, 7}
Intersection
• Intersection of two sets ‘A’ and ‘B’ is the set of all elements which belong to
both ‘A’ and ‘B’. This is denoted by A  B.

• In other words we can say:


A  B = {x : xA  xB}
e.g. A = {3, 5, 7}, B = {2, 3, 5}
A  B = {3, 5}
Difference
• The difference or the relative complement of a set ‘B’ with respect
to a set ‘A’ is the set of elements which belong to ‘A’ but which do
not belong to ‘B’. This is denoted by A B.
• In other words we can say:
A B = {x : xA  xB} Remember that
e.g. A = {3, 5, 7}, B = {2, 3, 5} A–B≠B-A
A B = {3, 5, 7} {2, 3, 5} = {7}

Note:Set difference is also called r


Cartesian product
• For any two sets A and B the set of all ordered pairs such that the first
member of the ordered pair is an element of A and the second number is an
element of B is called Cartesian product
• We can say that
A X B ={(x, y): x  A  y  B}
Algebra of sets
•Idempotent laws
•A  A = A
•A  A = A
•Associative laws
• (A  B)  C = A  (B  C)
• (A  B)  C = A  (B  C)
• Commutative laws Algebra of sets
•A  B = B  A
•A  B = B  A

• Distributive laws
• A  (B  C) = (A  B)  (A  C)
• A  (B  C) = (A  B)  (A  C)
• Identity laws Algebra of sets
•A  =A
•A  U=A
•A  U=U
•A  =
• Involution laws
• (Ac)c = A
Algebra of sets
• Complement laws
• A  Ac = U
• A  Ac = 
• Uc = 
• c = U
Algebra of sets

De Morgan’s laws
• (A  B) c = Ac  Bc

• (A  B) c = Ac  Bc
Proofs Using Algebraic Method
x(AB)c  xAB
 xA  xB
 xAc  xBc
 xAcBc
 (AB)c  AcBc (i)
De Morgan’s Law
xAcBc  xAc  xBc
 xA  xB
 xAB
 x(AB)c
 AcBc  (AB)c
(ii)
From (i) and (ii)
(AB)c = AcBc
Venn Diagram

John Venn (4 August 1834 – 4 April 1923)

This is the pictorial representation of sets and their corresponding


operations e.g; union, intersection, difference, complement etc…
Venn Diagram
A∩B
Venn Diagram
AB
Venn Diagram
A-B
Venn Diagram

A’
Computer representation of sets

• Let a universal set U has finite number of elements “n” and all the
elements are in some proper order a 1,a2,a3…an and AU. then A is
represented in computer in bit string of n elements such that i th bit
in set A will be “1” if ai  A and is 0 if ai  A
Example:
U = {1, 2, 3, 4, 5, 6,7 , 8, 9, 10}
A = {1, 3, 5, 7}
Then computer representation/bit representation A
={1010101000}
Example
U= {
1 2 3 4 5 6 7 8 9 10 }
A= { 1 3 5 7 }
{1
Bit Pattern for A=
0 1 0 1 0 1 0 0 0 }
Function
A rule which assigns a unique element from range
(Y) to each element of domain (X).
Example
•Let A ={a, b, c, d} B={1, 2, 3, 4, 5}

f:AB = {(a,1) (b,2) (c,3) (d,4)}


Then
Domain (f) = {a, b, c, d}
Range (f) = {1, 2, 3, 4}
codomain (f) = {1, 2, 3, 4, 5}
Properties of function
A function is
A
• ONE to ONE function
a B 1
called ONE to

2 ONE if for each


b bB there is
3
c AT MOST one a
Domain = A 4  A such
Range ≠ B d ONE5to ONE that
function is also
f(a) = b called
Properties of function
A function is
A
• ONTO function
a B called ONTO
1 if for each b
B there is AT
b LEAST one a 
2
c A such that
Domain = A f(a) = b
Range = B 3
(with repetition) d ONTO function is also called su
Properties of function
• A function is called bijective if it is both injective( ONE
to ONE) and surjective( ONTO)
A a
1 B
b 2
Domain = A
c 3
Range = B
(with no repetition) d 4

You might also like