Discrete Structures: Muhammad Waqas
Discrete Structures: Muhammad Waqas
Discrete Structures: Muhammad Waqas
Muhammad Waqas
Lecture 01
Introduction
Textbook
2
Lecture Agenda
•Goals, and Course Outline
•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
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.
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.
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.
•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
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..
p q pq p q pq
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
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 pq.
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.