Lecture 1 2
Lecture 1 2
Lecture 1 2
1
Course Evaluation
Topic Marks
Attendance 05
Individual Presentations 10
Class Test (3) 15
Mid Term 30
Final 40
2
Course Materials
Text Book:
•“Discrete Mathematics and Its Application”, Kenneth H. Rosen, 7th Edition,
McGraw-Hill.
•Lecture notes
Reference Materials:
•“Schaum’s Outlines Discrete Mathematics”, Seymore Lipschutz & Marc Lipson,
3rd Edition, McGraw-Hill.
•http://en.wikiversity.org/wiki/Introductory_Discrete_Mathematics_for_Computer_
Science
3
Course Contents
No Topic Exams/Quiz
Lectures 1-2 Introduction to Discrete Mathematics + Propositional Logic
Lectures 3-4 Propositional Logic and Introduction to Set
Lectures 5-6 Class Test-1 + Set Class Test-1
Lectures 7-8 Function
Lectures 9-10 Class Test-2 + Algorithm Class Test-2
4
Discrete mathematics
Discrete mathematics
– study of mathematical structures and objects that are
fundamentally discrete rather than continuous.
Logic defines:
• Syntax of statements
• The meaning of statements
• The rules of logical inference (manipulation)
6
Propositional logic
The simplest logic
• Definition:
– A proposition is a statement that is either true or false.
• Examples:
– Airport is located in the North Part of Dhaka City.
• (T)
– 5 + 2 = 8.
• (F)
– It is raining today.
• (either T or F)
7
Propositional logic
Examples (cont.):
–x+5=3
• since x is not specified, neither true nor false
– 2 is a prime number.
• (T)
Example:
• Proposition A: It rains outside
• Proposition B: We will see a movie
9
Composite Statements
• More complex propositional statements can be built from
elementary statements using logical connectives.
• Logical connectives:
– Negation
– Conjunction
– Disjunction
– Exclusive or
– Implication
– Biconditional
10
Logical connectives: Negation
Definition: Let p be a proposition. The statement "It is not
the case that p." is another proposition, called the negation of
p. The negation of p is denoted by ¬ p and read as "not p."
Example:
• Airport is located in the North Part of Dhaka City.
Other examples:
– 5 + 2 ≠ 8.
– 10 is not a prime number.
– It is not the case that buses stop running at 9:00pm. 11
Logical connectives: Negation
Negate the following propositions:
– It is raining today.
• It is not raining today.
– 2 is a prime number.
• 2 is not a prime number
12
Logical connectives: Negation
P ¬p
T F
F T
• Examples:
– It is raining today and 2 is a prime number.
– 2 is a prime number and 5 + 2 ≠ 8.
– 13 is a perfect square and 9 is prime.
14
Logical connectives: Disjunction
• Examples:
– It is raining today or 2 is a prime number.
– 2 is a prime number or 5 + 2 ≠ 8.
– 13 is a perfect square or 9 is a prime.
15
Truth Tables
p q p˄q p˅q
F F
F T
T F
T T
p q p˄q p˅q
F F F
F T F
T F F
T T T
17
Truth Tables
p q p˄q p˅q
F F F F
F T F T
T F F T
T T T T
p q p q
F F F
F T T
T F T
T T F
19
Implications
p q p → q
F F T
F T T
T F F
T T T
20
Implications
Examples:
– if Germany won 2010 world cup then 2 is a prime.
• If F then T ? T
The converse of p → q is q → p.
• The contrapositive of p → q is ¬q → ¬p
• The inverse of p → q is ¬p → ¬q
Examples:
• If it jams, the traffic moves slowly.
• p: it jams
• q: traffic moves slowly.
•p→q
22
Implications
The converse:
If the traffic moves slowly then it jams.
•q→ p
The contrapositive:
• If the traffic does not move slowly then it does not jams.
• ¬q → ¬p
The inverse:
• If it does not jams the traffic moves quickly.
• ¬p → ¬q
23
Biconditional
p q p ↔ q
F F T
F T F
T F F
T T T
p q ¬p p→q ¬p ↔ q (p → q) ˄ (¬p
↔ q)
F F
F T
T F
T T
25
Constructing the truth table
p q ¬p p→q ¬p ↔ q (p → q) ˄ (¬p
↔ q)
F F T
F T T
T F F
T T F
26
Constructing the truth table
p q ¬p p→q ¬p ↔ q (p → q) ˄ (¬p
↔ q)
F F T T
F T T T
T F F F
T T F T
27
Constructing the truth table
p q ¬p p→q ¬p ↔ q (p → q) ˄ (¬p
↔ q)
F F T T F
F T T T T
T F F F T
T T F T F
28
Constructing the truth table
p q ¬p p→q ¬p ↔ q (p → q) ˄ (¬p ↔
q)
F F T T F F
F T T T T T
T F F F T F
T T F T F F
29
Computer Representation of True and False
p q p˄q p˅q
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
p ¬p
0 1
1 0
31
Bitwise operation
1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1
˅0 1 0 0 1 0 0 1 ˄0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1
1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 0
32
Applications of propositional logic
33
Translation
Assume a sentence:
If you are older than 13 or you are with your parents then you
can attend a PG-13 movie.
Parse:
• If ( you are older than 13 or you are with your parents ) then
( you can attend a PG-13 movie)
• Translation: A ˅ B → C 34
Application of Inference
Assume we know the following sentences are true:
If you are older than 13 or you are with your parents then you can attend a
PG-13 movie. You are older than 13.
Translation:
• If ( you are older than 13 or you are with your parents ) then (you can
attend a PG-13 movie) . (You are older than 13).
– A= you are older than 13
– B= you are with your parents
– C=you can attend a PG-13 movie
• (A ˅ B → C), A
• (A ˅ B → C) ˄ A is true
• With the help of the logic we can infer the following statement
(proposition):
– You can attend a PG-13 movie or C is True
35
Tautology and Contradiction
Some propositions are interesting since their values in the truth
table are always the same
Definitions:
• A compound proposition that is always true for all possible truth values of
the propositions is called a tautology.
• A compound proposition that is always false is called a contradiction.
• A proposition that is neither a tautology nor contradiction is
called a contingency.
Example: p ˅ ¬p is a tautology.
p ˄ ¬p is a contradiction.
p ¬p p ˅ ¬p p ˄ ¬p
1 0 1 0
0 1 1 0 36
Equivalence
How do we determine that two propositions are equivalent?
p q p→q ¬q →¬p
F F T T
F T T T
T F F F
T T T T
38
Important Logical Equivalence
• Double negation
– ¬(¬p) <=> p
• Commutative
– p ˅ q <=> q ˅ p
– p ˄ q <=> q ˄ p
• Associative
– (p ˅ q) ˅ r <=> p ˅ (q ˅ r)
– (p ˄ q) ˄ r <=> p ˄ (q ˄ r)
39
Important Logical Equivalence
• Distributive
– p ˅ (q ˄ r) <=> (p ˅ q) ˄ (p ˅ r)
– p ˄ (q ˅ r) <=> (p ˄ q) ˅ (p ˄ r)
• De Morgan
– ¬( p ˅ q ) <=> ¬p ˄ ¬q
– ¬( p ˄ q ) <=> ¬p ˅ ¬q
40
Showing Logical Equivalence
Show (p ˄ q)→ p is a tautology
42