Merged Presentation Choladeck
Merged Presentation Choladeck
CS-1203
Syed Ijaz Hussain Bukhari
Discrete Structure
Course Objective
1.Express statements with the precision of formal logic
2.Analyze arguments to test their validity
3.Apply the basic properties and operations related to sets
4.Apply to sets the basic properties and operations related to relations and
function
5.Define terms recursively
6.Prove a formula using mathematical induction
7.Prove statements using direct and indirect methods
8.Compute probability of simple and conditional events
9.Identify and use the formulas of combinatorics in different problems
10.Illustrate the basic definitions of graph theory and properties of graphs
11.Relate each major topic in Discrete Mathematics to an application area in
computing
Discrete Structure
• Recommended Books:
1. Discrete Mathematics and Its Applications
(7th edition) by Kenneth H. Rosen
1. Logic
2. Sets & Operations on sets
3. Relations & Their Properties
4. Functions
5. Sequences & Series
6. Recurrence Relations
7. Mathematical Induction
8. Loop Invariants
9. Combinatorics
10. Probability
11. Graphs and Trees
What is Discrete Math?
Discrete Mathematics concerns processes that
consist of a sequence of individual steps.
The Foundations: Logic and Proofs
The rules of logic specify the meaning of mathematical statements. For instance, these rules help us
understand and reason with statements such as “There exists an integer that is not the sum of two
squares” and “For every positive integer n, the sum of the positive integers not exceeding n is
n(n+1)/2.” Logic is the basis of all mathematical reasoning, and of all automated reasoning. It has
practical applications to the design of computing machines, to the specification of systems, to
artificial intelligence, to computer programming, to programming languages, and to other areas of
computer science, as well as to many other fields of study.
Propositions
A proposition is a declarative sentence (that
is, a sentence that declares a fact) that is
either true or false, but not both.
Logic and Proposition
SIMPLE STATEMENT:
• A statement is a declarative sentence that is
either true or false but not both.
• A statement is also referred to as a proposition
Example: 2+2 = 4, It is Sunday today
• If a proposition is true, we say that it has a truth
value of "true”.
• If a proposition is false, its truth value is "false".
• The truth values “true” and “false” are,
respectively, denoted by the letters T and F.
Logic and Proposition
• EXAMPLES:
1. Grass is green.
2. 4 + 2 = 6
3. 4 + 2 = 7
4. There are four fingers in a hand.
5. Washington, D.C., is the capital of the United
States of America.
6. Toronto is the capital of Canada.
7. 1+1=2
8. 2+2=3 are propositions
Logic and Proposition
Not Propositions
• Close the door.
• x is greater than 2.
• He is very rich.
are not propositions.
Logic and Proposition
Rule:
• If the sentence is preceded by other sentences that make the
pronoun or variable reference clear, then the sentence is a
statement.
Example:
• x=1
• x>2
• x > 2 is a statement with truth-value FALSE.
Example
• Bill Gates is an American
• He is very rich
• He is very rich is a statement with truth-value TRUE.
Logic and Proposition
• UNDERSTANDING STATEMENTS:
1. x + 2 is positive. Not a statement
2. May I come in? Not a statement
3. Logic is interesting. A statement
4. It is hot today. A statement
5. -1 > 0 A statement
6. x + y = 12 Not a statement
Logic and Proposition
Consider the following sentences.
1. What time is it?
2. Read this carefully.
3. x+1=2.
4. x+y=z.
Sentences 1 and 2 are not propositions because they
are not declarative sentences. Sentences 3 and 4 are
not propositions because they are neither true nor
false. Note that each of sentences 3 and 4 can be
turned into a proposition if we assign values to the
variables.
COMPOUND STATEMENT:
Simple statements could be used to build a
compound statement.
LOGICAL CONNECTIVES
EXAMPLES:
1. “3 + 2 = 5” and “Lahore is a city in Pakistan”
2. “The grass is green” or “ It is hot today”
3. “Discrete Mathematics is not difficult to me”
AND, OR, NOT are called LOGICAL CONNECTIVES.
Logic and Proposition
• SYMBOLIC REPRESENTATION:
• We use letters to denote propositional variables
(or statement variables), that is, variables that
represent propositions, just as letters are used to
denote numerical variables. The conventional
letters used for propositional variables are p, q, r,
s, ... . The truth value of a proposition is true,
denoted by T, if it is a true proposition, and the
truth value of a proposition is false, denoted by F,
if it is a false proposition.
SYMBOLIC REPRESENTATION
Disjunction or Vel
w = “Zia is wealthy”
s = “Zia is wise”
Translate the compound statements to symbolic form:
1. Zia is healthy and wealthy but not wise. (h w) (~s)
• pq T
T
T
F
T
F
F T F
F F F
• DISJUNCTION () or INCLUSIVE OR
If p & q are statements, then the disjunction of
p and q is “p or q”, denoted as “p q”. It is
true when at least one of p or q is true and is
false only when both p and q are false.
TRUTH TABLE FOR p q
p q pq
T T T
T F T
F T T
F F F
Applications of Propositional Logic
• Logic has many important applications to mathematics,
computer science, and numerous other disciplines.
Statements in mathematics and the sciences and in
natural language often are imprecise or ambiguous. To
make such statements precise, they can be translated
into the language of logic. For example, logic is used in
the specification of software and hardware, because
these specifications need to be precise before
development begins. Furthermore, propositional logic
and its rules can be used to design computer circuits, to
construct computer programs, to verify the correctness
of programs, and to build expert systems.
Applications of Propositional Logic
• Translating English Sentences
• There are many reasons to translate English sentences into
expressions involving propositional variables and logical
connectives. In particular, English (and every other human
language) is often ambiguous. Translating sentences into compound
statements (and other types of logical expressions, which we will
introduce later in this chapter) removes the ambiguity. Note that
this may involve making a set of reasonable assumptions based on
the intended meaning of the sentence. Moreover, once we have
translated sentences from English into logical expressions we can
analyze these logical expressions to determine their truth values,
we can manipulate them, and we can use rules of inference (which
are discussed in Section 1.6) to reason about them.
• Example
How can this English sentence be translated into a logical expression?
“You can access the Internet from campus only if you are a computer science
major or you are not a freshman.”
Discrete Structure
Lecture 2
Syed Ijaz Hussain Bukhari
Truth Tables
Truth Tables for:
1. ~pq
2. ~ p (q ~ r)
3. (pq) ~ (pq)
Truth table for the statement form ~ p q
Truth Table
p q ~p ~p ^ q
T T F F
T F F F
F T T T
F F T F
Truth Table
Truth table for ~ p (q ~ r)
p q r ~r Q v ~r ~p ~p ^ (q v ~r)
T T T F T F F
T T F T T F F
T F T F F F F
T F F T T F F
F T T F T T T
F T F T T T T
F F T F F T F
F F F T T T T
Truth Table
Truth table for (pq) ~ (pq)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
Truth Table
Double Negative Property ~(~p) p
P ~p ~ ( ~p )
T F T
F T F
Truth Table
• Example
• “It is not true that I am not happy”
• Solution:
• Let p = “I am happy”
• then ~ p = “I am not happy”
• and ~(~ p) = “It is not true that I am not happy”
• Since ~ (~p) p
• Hence the given statement is equivalent to:
• “I am happy”
Truth Table
~ (pq) and ~p ~q are not logically equivalent
p q ~p ~q p^q ~(p ^ q) ~ p ^ ~q
T T F F T F F
T F F T F T F
F T T F F T F
F F T T F T T
Truth Table
• DE MORGAN’S LAWS:
• 1) The negation of an and statement is logically
equivalent to the or statement in which each
component is negated.
Symbolically ~(p q) ~p ~q.
• 2) The negation of an or statement is logically
equivalent to the and statement in which each
component is negated.
Symbolically: ~(p q) ~p ~q.
Truth Table
~(p q) ~p ~q
p q ~p ~q Pvq ~ (p v q) ~ p ^ ~q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
Truth Table
• Application:
• Give negations for each of the following
statements:
• a. The fan is slow or it is very hot.
• b. Akram is unfit and Saleem is injured.
• Solution
• a. The fan is not slow and it is not very hot.
• b. Akram is not unfit or Saleem is not injured.
Truth Table
• INEQUALITIES AND DEMORGAN’S LAWS:
Use DeMorgan’s Laws to write the negation of
-1 < x 4
for some particular real no. x
-1 < x 4 means x > –1 and x 4
By DeMorgan’s Law, the negation is:
x > –1 or x 4
Which is equivalent to: x –1 or x > 4
• EXERCISE:
1. (p q) r p (q r)
2. Are the statements (pq)r and p(q r) logically
equivalent?
Truth Table
• TAUTOLOGY:
A tautology is a statement form that is always
true regardless of the truth values of the
statement variables.
• A tautology is represented by the symbol “T”..
EXAMPLE: The statement form p ~ p is
tautology p ~p p~p
• p ~p t T F T
F T T
Truth Table
• CONTRADICTION:
• A contradiction is a statement form that is always
false regardless of the truth values of the
statement variables.
• A contradiction is represented by the symbol “c”.
• So if we have to prove that a given statement
form is CONTRADICTION we will make the truth
table for the statement form and if in the column
of the given statement form all the entries are F,
then we say that statement form is contradiction.
Truth Table
• EXAMPLE:
• The statement form p ~ p is a contradiction.
p ~p p~p
T F F
F T F
T T T T F F
T F T F T T
F T T F T T
F F F F T F
Discrete Structure
Lecture No 3
Syed Ijaz Hussain Bukhari
Logical Equivalences
Name Equivalences
Identity Law pT=p
pvF=p
Domination Law pvT=T
pF=F
Indempotent Law pvp=p
pp=p
Double Negation Law ~(~p) = p
Commutative Law pvq=qvp
pq=qp
Associative Law (p v q) v r = p v (q v r)
(p q) r = p (q r)
Distributive Law p v (q r) = (p v q) ( p v r)
p (q v r) = (p q) v (p r )
Absorption Law p v (p q ) = p
p (p v q) = p
APPLYING LAWS OF LOGIC
• Using law of logic, simplify the statement form
p [~(~p q)]
• Solution:
“You will get an A if you are hardworking and the sun shines, or you are hardworking and it rains.”
Rephrase the condition more simply.
Solution:
Let p = “You are hardworking’
q = “The sun shines”
r = “It rains” .
Introduction
Consider the statement:
"If you earn an A in Math, then I'll buy you a computer."
This statement is made up of two simpler statements:
p: "You earn an A in Math," and
q: "I will buy you a computer."
The original statement is then saying:
if p is true, then q is true, or, more simply, if p, then q.
We can also phrase this as p implies q, and we write
p q.
CONDITIONAL STATEMENTS OR
IMPLICATIONS
• If p and q are statement variables, the
conditional of q by p is “If p then q” or “p
implies q” and is denoted p q.
• It is false when p is true and q is false;
otherwise it is true.
• The arrow " " is the conditional operator,
and in p q the statement p is called the
hypothesis and q is called the conclusion.
TRUTH TABLE
p q pq
T T T
T F F
F T T
F F T
PRACTICE WITH CONDITIONAL
STATEMENTS:
Determine the truth value of each of the following
conditional statements:
1. “If 1 = 1, then 3 = 3.” TRUE
2. “If 1 = 1, then 2 = 3.” FALSE
3. “If 1 = 0, then 3 = 3.” TRUE
4. “If 1 = 2, then 2 = 3.” TRUE
5. “If 1 = 1, then 1 = 2 and 2 = 3.” FALSE
6. “If 1 = 3 or 1 = 2 then 3 = 3.” TRUE
• ALTERNATIVE WAYS OF EXPRESSING IMPLICATIONS:
The implication p q could be expressed in many alternative ways as:
•“if p, q” •“q if p”
If you get the job, then you have the best credentials.
d) It is necessary to walk 8 miles to get to the top of the Peak.
If you get to the top of the peak, then you must have walked 8 miles.
TRANSLATING ENGLISH SENTENCES
TO SYMBOLS
Let p and q be propositions:
p = “you get an A on the final exam”
q = “you do every exercise in this book”
r = “you get an A in this class”
Write the following propositions using p, q, and r
and logical connectives.
1. To get an A in this class it is necessary for you to
get an A on the final.
• SOLUTION pr
•
• 2. You do every exercise in this book; You get an A
on the final, implies, you get an A in the class.
• SOLUTION pqr
•
• 3. Getting an A on the final and doing every
exercise in this book is sufficient for getting an A
in this class.
• SOLUTION pqr
TRANSLATING SYMBOLIC
PROPOSITIONS TO ENGLISH
• Let p, q, and r be the propositions:
p = “you have the flu”
q = “you miss the final exam”
r = “you pass the course”
Express the following propositions as an English sentence.
1. p q
If you have flu, then you will miss the final exam.
2.~q r
If you don’t miss the final exam, you will pass the course.
3.~p ~q r
If you neither have flu nor miss the final exam, then you will
pass the course.
HIERARCHY OF OPERATIONS
FOR LOGICAL CONNECTIVES
• ~ (negation)
• (conjunction), (disjunction)
• (conditional)
Logical Equivalences
Involving Conditional Statements
Construct a truth table for the statement form
p~q~p
p q ~q ~p p ~q p~q~p
T T F F T F
T F T F T F
F T F T F T
F F T T T T
Construct a truth table for the statement form
(p q)(~ p r)
p q r pq ~p ~pr (pq)(~ p r)
T T T T F T T
T T F T F T T
T F T F F T F
T F F F F T F
F T T T T T T
F T F T T F F
F F T T T T T
F F F T T F F
LOGICAL EQUIVALENCE INVOLVING
IMPLICATION
Use truth table to show pq ~q ~p
p q ~q ~p pq ~q ~p
T T F F T T
T F T F F F
F T F T T T
F F T T T T
p q pq ~p ~pq
T T T F T
T F F F F
F T T T T
F F T T T
Thus the negation of “if p then q” is logically equivalent to “p and not q”.
Accordingly, the negation of an if-then statement does not start with the
word if.
EXAMPLES
Write negations of each of the following conditional statements:
1. If Ali lives in Pakistan then he lives in Lahore.
2. If my car is in the repair shop, then I cannot get to class.
3. If x is prime then x is odd or x is 2.
4. If n is divisible by 6, then n is divisible by 2 and n is divisible by 3.
SOLUTIONS:
T T T F F T
T F F F T T
F T T T F F
F F T T T T
p q pq qp
T T T T
T F F T
F T T F
F F T T
• WRITING CONVERSE:
1.If today is Friday, then 2 + 3 = 5.
If 2 + 3 = 5, then today is Friday.
2.If it snows today, I will ski tomorrow.
I will ski tomorrow only if it snows today.
3. If P is a square, then P is a rectangle.
If P is a rectangle then P is a square.
4. If my car is in the repair shop, then I cannot get to class.
If I cannot get to the class, then my car is in the repair shop.
CONTRAPOSITIVE OF A CONDITIONAL
STATEMENT:
The contrapositive of the conditional statement p q is~ q ~ p
T T T F F T T
T F F F T F T
F T T T F T T
F F T T T T T
T T T T T T
T T F T F F
T F T F F T
T F F F T F
F T T F T F
F T F F F T
F F T T F F
F F F T T T
TRUTH TABLE FOR
p ~r qr
Here p ~ r q r means (p (~ r)) (q r)
p q r ~r p~r qr p ~r qr
T T T F F T F
T T F T T T T
T F T F F T F
T F F T T F F
F T T F F T F
F T F T F T F
F F T F F T F
F F F T F F T
• LOGICAL EQUIVALENCE INVOLVING
BICONDITIONAL
• Show that ~pq and p~q are logically
equivalent
p q ~p ~q ~pq p~q
T T F F F F
T F F T T T
F T T F T T
F F T T F F
EXERCISE:
• Show that ~(pq) and pq are logically equivalent
SOLUTION
STATEMENT REASON
Lecture 5
By
Syed Ijaz Hussain Bukhari
Argument
• ARGUMENT:
An argument is a list of statements called premises (or assumptions or
hypotheses) followed by a statement called the conclusion.
P1 Premise
P2 Premise
P3 Premise
. . . . .. . . . .
Pn Premise
______________
C Conclusion
• EXAMPLE
An interesting teacher keeps me awake. I stay awake in Discrete Mathematics
class. Therefore, my Discrete Mathematics teacher is interesting.
Is the above argument valid?
• VALID AND INVALID ARGUMENT:
• An argument is valid if the conclusion is true
when all the premises are true.
• Alternatively, an argument is valid if conjunction
of its premises imply conclusion. That is (P1 P2
P3 . . . Pn) C is a tautology.
• An argument is invalid if the conclusion is false
when all the premises are true.
• Alternatively, an argument is invalid if
conjunction of its premises does not imply
conclusion.
Critical Row
• The critical rows are those rows where the
premises have truth value T. (Also remember
that we say an argument is valid if in all critical
rows and conclusion has truth value T)
• EXAMPLE:
• Show that the following argument form is valid:
pq
p
q
p q pq p q
T T T T T Critical Row
T F F T F
F T T F T
F F T F F
EXAMPLE Show that the following argument form is
invalid:
pq
q
p
Premisis Conclusion
p q pq q p
T T T T T
T F F F T Critical
F T T T F
F F T F F
• EXERCISE:
Use truth table to determine the argument
form
pq
p ~q
pr
r
is valid or invalid.
premises conclusion
F T T F T T T T
F T F F T T T F
F F T T F T T T
F F F T F T T F
d p dp ~d ~p
T T T F F
T F F F T
F T T T F
F F T T T
Therefore mt
t a m ta am mt
T T T T T T
T T F T F F
T F T F F T
T F F F F F
F T T T T F
F T F T F F
F F T T F F
F F F T F F
P Q State
Closed Closed On
Closed Open On
Open Closed On
Output S = 1
CONSTRUCTING THE INPUT/OUTPUT TABLE FOR A CIRCUIT
Construct the input/output table for the following circuit.
LABELING INTERMEDIATE OUTPUTS:
P Q R X Y S
1 1 1 1 0 1
1 1 0 1 0 0
1 0 1 0 1 1
1 0 0 0 1 1
0 1 1 0 1 1
0 1 0 0 1 1
0 0 1 0 1 1
0 0 0 0 1 1
FINDING A BOOLEAN EXPRESSION FOR A CIRCUIT
P
OR
Q
AND
R OR
• SOLUTION:
Trace through the circuit from left to right, writing
down the output of each logic gate.
P PQ
OR
Q (PQ) (PR)
PR AND
R OR