You are on page 1of 61

Discrete Structures

Muhammad Waqas
Lecture 01
Introduction
Textbook

Discrete Mathematics and Its Applications


by Kenneth H. Rosen

2
Lecture Agenda
•Goals, and Course Outline

•What is Discrete Structure?

•Discrete vs. Continuous

•Overview of the Course

•Logic
Course Themes, Goals, and Course Outline
Introduce students to a range of mathematical tools from discrete
mathematics that are key in computer science

Mathematical Sophistication
How to write statements rigorously
How to read and write theorems, lemmas, etc.
How to write rigorous proofs

Note: Learning to do proofs from


watching the slides is like trying to
learn to play tennis from watching
it on TV! So, do the exercises!
Course Outline
Logic and Methods of Proof
Propositional Logic (as an encoding language!)
Predicates and Quantifiers
Methods of Proofs
Sets Theory
Sets and Set operations
Functions
Counting and Combinatorics
Basics of counting
Pigeonhole principle
Permutations and Combinations
Number Theory
Modular arithmetic
RSA cryptosystems
Course Outline
Probability
Probability Axioms, events, random variable
Independence, expectation, example distributions
Birthday paradox
Monte Carlo method
Graphs and Trees (in detail Algorithms analysis)
Graph terminology
Example of graph problems and algorithms:
graph coloring
TSP
shortest path
Relations and Functions
What is Discrete Structure?
•  It is the study of mathematical structures that are countable
or otherwise distinct and separable. Examples of structures
that are discrete are combinations, graphs, and logical
statements. Discrete structures can be finite or infinite.
Discrete mathematics is in contrast to continuous
mathematics, which deals with structures which can range in
value over the real numbers, or have some non-separable
quality.
So What is Discrete Structure is about?

Continuous vs. Discrete Math


Why is it computer science?
Mathematical techniques for DM

8
Discrete vs. Continuous Mathematics
Continuous Mathematics
It considers objects that vary continuously;
Example: analog wristwatch (separate hour, minute, and second hands).
From an analog watch perspective, between 1 :25 p.m. and 1 :26 p.m.
there are infinitely many possible different times as the second hand
moves around the watch face.

Real-number system --- core of continuous mathematics;


Continuous mathematics --- models and tools for analyzing real-world
phenomena that change smoothly over time. (Differential equations etc.)

9
Discrete vs. Continuous Mathematics
Discrete Mathematics
It considers objects that vary in a discrete way.
Example: digital wristwatch.
On a digital watch, there are only finitely many possible different
times between 1 :25 P.M. and 1:27 P.M.
Integers --- core of discrete mathematics
Discrete mathematics --- models and tools for analyzing real-world
phenomena that change discretely over time and therefore ideal for
studying
computer science – computers are digital! (numbers as finite bit
strings; data structures, all discrete! Historical aside: earliest
computers were analogue.)

10
Discrete vs. Continuous
Example
• Number of Students in the Class
• Height of a Person
• Time in a game
• Number of candies in a packet
• Number of voters lost by any political party
• Distance covered by a ball
Why is it computer science?
Example: System Specification:
 The router can send packets to the edge system only if it supports the
new address space.
 For the router to support the new address space it’s necessary that
the latest software release be installed.
 The router can send packets to the edge system if the latest software
release is installed.
 The router does not support the new address space.

How to write these specifications in a rigorous /


formal way? Use Logic.
Number Theory:
RSA and Public-key Cryptography

Alice and Bob have never met but they would like to
exchange a message. Eve would like to eavesdrop.
E.g. between you and the Bank of Pakistan.

They could come up with a good


encryption algorithm and exchange
the encryption key – but how to do it
without
Eve getting it? (If Eve gets it, all
security is lost.)

CS folks found the solution:


public key encryption. Quite remarkable
that that is feasible. 13
Number Theory:
Public Key Encryption

RSA – Public Key Cryptosystem (why RSA?)


Uses modular arithmetic and large primes  Its security comes from the computational difficulty
of factoring large numbers. 14
Graphs and Networks

•Many problems can be represented by a graphical


network representation.

•Examples:
– Distribution problems
Aside: finding the right
– Routing problems problem representation
– Maximum flow problems is one of the key issues.
– Designing computer / phone / road networks
– Equipment replacement
– And of course the Internet

15
Networks are
New Science of Networks
Sub-Category Graph
pervasive
No Threshold

Utility Patent network


1972-1999
(3 Million patents)
Gomes,Hopcroft,Lesser,Selman

Neural network of the


nematode worm C- elegans
(Strogatz, Watts)

NYS Electric
Power Grid Network of computer scientists
(Thorp,Strogatz,Watts) ReferralWeb System Cybercommunities
(Kautz and Selman) 16
(Automatically discovered)
Kleinberg et al
Logic
•Logic is the study of the principles and techniques of
reasoning.
•Logic plays a central role in the development of every
area of learning, especially in mathematics and
computer science.
For example:
•Computer scientists, employ logic to develop
programming languages and to establish the
correctness of programs. Electronics engineers apply
logic in the design of computer chips.
Propositional Logic
• A proposition is a statement that can either be true
or false but not both. 
• Propositional logic aims to outline the rules of how
these statements can be altered and combined.
• A statement that has a truth value
• Propositional variables: p, q, r, s, . . .
• Truth values: T for true, F for false
Continue..
Example 1
(1) Socrates was a Greek philosopher.
(2) 3+4=5.
(3) 1 + 1 = 0 and the moon is made of green cheese.
(4) If i = 2, then roses are red.
(5) Let me go!
(6) x+3=5
Which are the propositions?
Truth Value of Proposition
• The truthfulness or falsity of a proposition is
called its truth value, denoted by T(true) and
F(false), respectively. (These values are often
denoted by 1 and 0 by computer scientists.)
• For example, the truth value of statement (1)
in Example 1 is T and that of statement (2) is F.
Simple Proposition
Negation:
• The negation of a proposition p is It is not the
case that p, denoted by p. You may read p
as the negation of p or simply not p.
• If a proposition p is true, then p is false; if p
is false, then p is true.
Continue..
Let p: Lahore is the capital of Pakistan and
q: Ayesha is an intelligent student.
The negation of p is
p: It is not the case that Lahore is the capital of
Pakistan.
or p: Lahore is not the capital of Pakistan.
Likewise, the negation of q is
q: Ayesha is not an intelligent student.
Continue..
• The truth table of negation can be represent
as:
Compound Propositions
• Propositions (1) and (2) in Example 1 are
simple propositions.
• A compound proposition is formed by
combining two or more simple propositions
called components. For instance, propositions
(3) and (4) in Example 1 are compound.
Continue..
Conjunction:
• The conjunction of two arbitrary propositions
p and q, denoted by p  q, is the proposition p
and q. It is formed by combining the
propositions using the word and, called a
connective.
Continue..
Example 2
Consider the statements
p: Socrates was a Greek philosopher
q: Euclid was a Chinese musician.
Their conjunction is given by
p  q: Socrates was a Greek philosopher and
Euclid was a Chinese musician.
Continue..
• To define the truth value of p  q, where p and
q are arbitrary propositions, we need to
consider four possible cases:
• p is true, q is true.
• p is true, q is false.
• p is false, q is true.
• p is false, q is false.
Continue..
• Representation of Example 2 with the help of
Tree Diagram.
Continue..
• This information can be summarized in a table.
In the third column of Table, enter the truth
value of p  q corresponding to each pair of
truth values of p and q.
Continue..
• The resulting table is the truth table for p  q.
Continue..
Disjunction:
• A second way of combining two propositions p
and q is by using the connective or.
• The resulting proposition p or q is the
disjunction of p and q and is denoted by p v q.
Continue..
Example 3
Consider the statements
p: Harry likes pepperoni pizza for lunch
q: Harry likes mushroom pizza for lunch.
Their disjunction is given by
p v q: Harry likes pepperoni pizza for lunch or Harry likes
mushroom pizza for lunch.
We can also write it as
p v q: Harry likes pepperoni or mushroom pizza for lunch.
Continue..

• The disjunction of two propositions is true if at


least one component is true; it is false only if
both components are false.
Continue..
Exclusive Or:
• Exclusive Or can be written as p  q is true
when exactly one of p or q is true.
• False otherwise
Continue..
Example 4
In a shared Environment, process p1 can
reserve the printer or process p2 reserve the
printer separately but not both at the same
time.
p1 p2 p1  p2
T T F
T F T
F T T
F F F
Continue..
Implication:
• Two propositions p and q can be combined to
form statements of the form: If p, then q.
• Such a statement is an implication, denoted by p
 q.
• Since it involves a condition, it is also called a
conditional statement. The component p is the
hypothesis (or premise) of the implication and q
the conclusion.
Continue..
Example 5:
Let p: ΔABC is equilateral
And q: ΔABC is isosceles.
Then p  q implies that If ΔABC is equilateral,
then it is isosceles.
Continue..
• Implications occur in a variety of ways. The following
are some commonly known occurrences:
• If p, then q.
• If p, q.
• p implies q.
• p only if q.
• q if p.
• p is sufficient for q.
• q is necessary for p.
Continue..
Accordingly, the implication p  q can be read
in one of these ways. For instance, consider
the proposition
p  q : If AABC is equilateral, then it is isosceles.
It means exactly the same as any of the
following propositions:
• If AABC is equilateral, it is isosceles.
• AABC is equilateral implies it is isosceles.
Continue..
• AABC is equilateral only if it is isosceles.
• AABC is isosceles if it is equilateral.
• That AABC is equilateral, is a sufficient
condition for it to be isosceles.
• That AABC is isosceles, is a necessary
condition for it to be equilateral.
Order of Precedence
• Negation (not) p
• Conjunction (and) pq
• Disjunction (or) pq
• Exclusive or pq
• Implication pq
• Biconditional pq
Truth Tables
p p p q pq

p q pq p q pq
Previous Lecture
• Logic
• Propositional Logic
• Truth Value of Proposition
• Simple Proposition
• Compound Proposition
• Boolean Expression
• Order of Precedence
Lecture’s Agenda
• Bi-Conditional statement
•Fuzzy Logic
•Fuzzy Decision
•Quantifier
Converse, Inverse, and Contrapositive
• The converse of the implication p  q is q  p
(switch the premise and the conclusion in p  q).
• The inverse of p  q is  p   q (negate the
premise and the conclusion).
• The contrapositive of p  q is  q   p (negate
the premise and the conclusion, and then switch
them).
• Many people mistakenly think that an implication and its converse
mean the same thing; they usually say one to mean the other.
Cont…
Example
• Let p  q. If ΔABC is equilateral, then it is isosceles.
• Its converse, inverse, and contrapositive are given by:
• Converse q  p: If ΔABC is isosceles, then it is
equilateral.
• In verse  p   q: If ΔABC is not equilateral, then it
is not isosceles.
• Contrapositive  q   p: If ΔABC is not isosceles,
then it is not equilateral.
Boolean operators
• We have presented four Boolean operators:  , v, 
and  .
• The first three enable us to combine two
propositions; accordingly, they are binary operators.
• On the other hand, we need only one proposition to
perform negation, so  is a unary operator.
• These operators can be employed to construct more
complex statements, as the next example
demonstrates.
Basic Logic Operators
• AND
Binary
• OR
• NOT Unary

• F(a,b) = a•b, F is 1 if and only if a=b=1


• G(a,b) = a+b, G is 1 if either a=1 or b=1
• H(a) = a’, H is 1 if a=0
Timing Diagram
t0 t1 t2 t3 t4 t5 t6
1
Input A 0
1 Transitions
signals B 0

1
F=A•B 0 Basic
Gate
1 Assumption:
Output G=A+B 0 Zero time for
Signals
1 signals to
H=A’ 0 propagate
Through gates
Complex Boolean Expression
• Construct a truth table for (p  q)  (q  p).
Bi-conditional Statement
• Two propositions p and q can be combined
using the connective if and only if.
• The resulting proposition, p if and only if q, is
the conjunction of two implications:
(1) p only if q, and (2) p if q, that is, p  q and
q  p.
• Accordingly, it is called a bi-conditional
statement, symbolized by pq.
Cont…
Example
• Let p: ΔABC is equilateral
• and q: ΔABC is equiangular.
• Then the bi-conditional statement is given by
• p  q: ΔABC is equilateral if and only if it is
equiangular.
• Notice that the statement p  q is true if both p
and q have the same truth value; conversely, if p 
q is true, then p and q have the same truth value.
Cont…
Example
• Let S denote the sum of the digits in 2034. If 3 is a
factor of S, then 3 is a factor of 2034 also.
Conversely, if 3 is a factor of 2034, then 3 is a factor
of S also.
• Thus the bi-conditional, 2034 is divisible by 3 if and
only if S is divisible by 3, is a true proposition.
Consequently, if one component say, S is divisible by
3 is true, then the other component is also true.
Cont…
Tautology
• An interesting observation, a compound
statement which is always true, regardless of the
truth values of its components.

• Such a compound proposition is a tautology; it is


an eternal truth.

• For example, p v p is a tautology. (Verify this.)


Contradiction and Contingency
• On the other hand, a compound statement
that is always false is a contradiction.
• For instance, p  p is a contradiction (Verify
this).

• A compound proposition that is neither a


tautology nor a contradiction is a contingency.
• For example, p v q is a contingency.
Switching Network
• A switching network is an arrangement of wires
and switches connecting two terminals.
• A switch that permits the flow of current is said
to be closed; otherwise, it is open.
• Likewise, a switching network is closed if current
can flow from one end of the network to the
other; otherwise, it is open.
• Two switches A and B can be connected either in
series or in parallel.
Cont…
• The switching network in Figure is closed if
and only if both A and B are closed;
accordingly, it is symbolically denoted by A 
B.
• The network in Figure is closed if and only if at
least one of the two switches is closed;
consequently, it is denoted by A v B.
Logically equivalences
• Two compound propositions p and q, although
they may look different, can have identical
truth values for all possible pairs of truth
values of their components.

• Such statements are logically equivalent,


symbolized by p ≡ q; otherwise, we write p q.
Cont…
• Example
• Verify that p  q ≡ p v q.
• SOLUTION: Construct a truth table containing
columns headed by p  q and p v q.
Cont…
• Example
• Show that p  q ≡ q  p; that is, an implication is
logically equivalent to its contrapositive.
• SOLUTION: Once again, construct a truth table, with
columns headed by p, q, p  q, q, p and q  p.

You might also like