CSE1203:
Discrete Mathematics
Ahsanullah University of Science and Technology
Course Teacher:
Shoeb Mohammad Shahriar
Assistant Professor, Department of CSE, AUST
Course Information
• Instructor: Shoeb Mohammad Shahriar
• Email: [email protected]
• Textbook: Discrete Mathematics and Its Applications(6th Edition), by
Kenneth H. Rosen, McGraw-Hill
• Grading:
• Final Exam: 70%
• Class Test (Best 3 of 4): 20%
• Attendance and Class Perf. : 10%
CSE1203: Discrete Mathematics 1-2
What is Mathematics, really?
• It’s not just about numbers!
• Mathematics is much more than that:
Mathematics is, most generally, the study of any and all
absolutely certain truths about any and all perfectly well-
defined concepts.
• These concepts can be about numbers, symbols, objects, images,
sounds, anything!
• It is a way to interpret the world around you.
CSE1203: Discrete Mathematics 1-3
So, what’s this class about?
• What are “discrete structures” anyway?
• “Discrete” - Composed of distinct, separable parts. (Opposite of continuous.)
discrete: continuous :: digital: analog
• “Structures” - Objects built up from simpler objects according to some
definite pattern.
• “Discrete Mathematics” - The study of discrete, mathematical (i.e. well-
defined conceptual) objects and structures.
CSE1203: Discrete Mathematics 1-4
Why Study Discrete Math?
• The basis of all of digital information processing is: Discrete
manipulations of discrete structures represented in memory.
• It’s the basic language and conceptual foundation for all of computer
science.
• Discrete math concepts are also widely used throughout math,
science, engineering, economics, biology, etc., …
• A generally useful tool for rational thought!
CSE1203: Discrete Mathematics 1-5
Uses for Discrete Math in Computer
Science
• Advanced algorithms & data structures
• Programming language compilers & interpreters
• Computer networks
• Operating systems
• Computer architecture
• Database management systems
• Cryptography
• Error correction codes
• Graphics & animation algorithms, game engines, etc.…
• i.e., the whole field!
CSE1203: Discrete Mathematics 1-6
1.1 Propositional Logic
• Logic
• Study of reasoning.
• Specifically concerned with whether reasoning is correct.
• Focuses on the relationship among statements, not on the content of any
particular statement.
• Proposition
• Definition: A proposition is a declarative sentence or statement that is either
True or False, but not both at the same time.
• Truth Values: True (T) and False (F)
CSE1203: Discrete Mathematics 1-7
Proposition
• Examples
p: ‘Dhaka is the capital of Bangladesh’: True (T)
q: ‘The integer 20 is a prime number’: False (F)
• Not examples:
What is your name?
Solve the problem.
CSE1203: Discrete Mathematics 1-8
Negation of a Proposition
• Definition: Say, p is a proposition. Negation of p, denoted by ¬p or p,
and read ‘not p’, is a proposition which is true, if p is false and false, if
p is true.
• Examples:
p: ‘10 is divisible by 5’.
Truth Table:
In Discrete Math, grammar doesn't matter
¬p : ‘It is not the case that 10 is divisible by 5’, p ¬p
or simply T F
¬p: ‘10 is not divisible by 5’. F T
CSE1203: Discrete Mathematics 1-9
Negation of a Proposition
• Proof using Truth Tables
¬(¬ p) is equivalent to p, i.e. ¬(¬ p) ≡ p
p ¬p ¬(¬ p)
T F T
F T F
¬ (not)- unary logical operator.
CSE1203: Discrete Mathematics 1-10
Compound Propositions involving
Connectives
• Connectives are Binary logical operators.
i. Conjunctions:
• Definition: Let p and q be two propositions, conjunction of p and q is denoted
Mnemonic: Caret-Conjunction
by ‘p ∧ q’ and read ‘p and q’, is a proposition which is true only when both p
Mnemonic: ^ looks like A
and q are true. Like AND gate
• Examples:
p: ‘The boy prepares his lessons regularly’.
q: ‘The boy helps his parents everyday’.
p ᶺ q: ‘The boy prepares his lessons regularly and [although, but] helps his parents
everyday’.
CSE1203: Discrete Mathematics 1-11
Compound Propositions involving
Connectives (cont.)
i. Conjunctions:
• Truth Table:
p q p∧q
F F F
F T F
T F F
T T T
CSE1203: Discrete Mathematics 1-12
Compound Propositions involving
Connectives (cont.)
ii. Disjunctions:
• Definition: Let p and q be two propositions, disjunction of p and q is denoted
by ‘p v q’ and read ‘p or q’, is a proposition that is false only when both p and
q are false. Like OR gate
• Examples:
p: ‘You can take Physics this semester’.
q: ‘You can take Chemistry this semester’.
p v q: ‘You can take Physics or Chemistry [or both] this semester’.
CSE1203: Discrete Mathematics 1-13
Compound Propositions involving
Connectives (cont.)
ii. Disjunctions:
• Truth Table:
p q pvq
F F F
F T T
T F T
T T T
CSE1203: Discrete Mathematics 1-14
Compound Propositions involving
Connectives (cont.)
iii. Exclusive Disjunctions:
• Definition: Let p and q be two propositions, exclusive disjunction of p and q is
denoted by ‘p ⊕ q’ and read ‘p exclusive or q’, is a proposition which is true
only when exactly one of p and q is true. Like XOR gate
• Examples:
p: ‘You can take tea’.
q: ‘You can take coffee’.
p ⊕ q: ‘You can take tea or coffee [but not both]’.
CSE1203: Discrete Mathematics 1-15
Compound Propositions involving
Connectives (cont.)
iii. Disjunctions:
• Truth Table:
p q p⊕q
F F F
F T T
T F T
T T F
CSE1203: Discrete Mathematics 1-16
Compound Propositions involving
Connectives (cont.)
iii. Disjunctions: This is HSC formula; A XOR B = A(bar)B+AB(bar)
p ⊕ q ≡ (¬p ∧ q) v (p ∧ ¬q)
p q ¬p ¬q ¬p ∧ q p ∧ ¬q (¬p ∧ q) v (p ∧ ¬q)
F F T T F F F
F T T F T F T
T F F T F T T
T T F F F F F
p⊕q
CSE1203: Discrete Mathematics 1-17
Conditional Statement or Implication
• Definition: Let, p and q be two propositions. The compound
proposition denoted by ‘p → q’ and most commonly read ‘p implies q’,
is called a conditional statement or Implication which is false only
when p is true but q is false.
• Examples:
If you fall ill then you miss the examination.
p: You fall ill. p- premise/ antecedent/ hypothesis
q: You miss the examination. q- conclusion/ consequence
If p, then q i.e. p→q
CSE1203: Discrete Mathematics 1-18
Implication (cont.)
•p→q
Most commonly read as,
▪ p implies q.
▪ q if p.
▪ q whenever p.
▪ q follows from p.
CSE1203: Discrete Mathematics 1-19
Implication (cont.)
Can be easily derived from truth table De Morgan
p q p→q ¬p ¬q p ∧ ¬q ¬(p ∧ ¬q) ¬p v q
F F T T T F T T
F T T T F F T T
Use this line to
derive formula T F F F T T F F
T T T F F F T T
CSE1203: Discrete Mathematics 1-20
Implication (cont.)
Mnemonic: Coverse > In a reverse order
• Converse, Inverse and Contrapositive of a conditional statement:
Conditional Converse Inverse Contrapositive
p q p→q q→p ¬p ¬q ¬p → ¬q ¬q → ¬p
F F T T T T T T
F T T F T F F T
T F F T F T T F
T T T T F F T T
• Conditional statement is logically equivalent to Contrapositive.
• Converse of a conditional statement is logically equivalent to inverse of a conditional
statement.
CSE1203: Discrete Mathematics 1-21
Converse, Inverse and Contrapositive
• From p →q we can form new conditional statements .
• q →p is the converse of p →q
• ¬q → ¬ p is the contrapositive of p →q
• ¬ p → ¬ q is the inverse of p →q
• Example: Find the converse, inverse, and contrapositive of “It is
raining in a sufficient condition for me not going to town.”
Solution:
converse: If I do not go to town, then it is raining.
inverse: If it is not raining, then I will go to town.
contrapositive: If I go to town, then it is not raining
CSE1203: Discrete Mathematics 1-22
Biconditional Statement
• If p and q are propositions, then we can form the biconditional
proposition p ↔q , read as “p if and only if q .” The biconditional p
↔q denotes the proposition with this truth table:
p q p↔q
T T T Opposite of XOR
T F F
F T F
F F T
• If p denotes “I am at home.” and q denotes “It is raining.” then p ↔q
denotes “I am at home if and only if it is raining.
CSE1203: Discrete Mathematics 1-23
Biconditional Statement (cont.)
• Example:
p: The angles of a triangle are equal to each other.
q: The triangle are equilateral.
p ↔ q: The angles of a triangle are equal to each other if and only if the
triangle is equilateral.
• Some alternative ways “p if and only if q” is expressed in English:
▪ p is necessary and sufficient for q
▪ if p then q , and conversely
▪ p iff q
CSE1203: Discrete Mathematics 1-24
Special Logical Convention
• Tautology: Compound proposition which is always true. Mnemonic: Both starts with 'T'
Easiest Example: p OR (not)p
¬(p v q) ↔ (¬p ∧ ¬q ) is a tautology.
p q pvq ¬(p v q) ¬p ¬q ¬p ∧ ¬q ¬(p v q) ↔ (¬p ∧ ¬q)
F F F T T T T T
F T T F T F F T
T F T F F T F T
T T T F F F F T
CSE1203: Discrete Mathematics 1-25
Special Logical Convention (cont.)
• Contradiction: Compound proposition which is always false.
▪ p ∧ ¬p
▪ ((p ∧ q) ↔ (q ∧ p))
CSE1203: Discrete Mathematics 1-26
Special Logical Convention (cont.)
Contingency (Word Meaning) => Future event that is possible but cannot be predicted with certainty
• Contingency: Compound proposition which is neither a tautology nor a
contradiction.
• Order of Precedence of logical operators:
Operator Precedence
1
Mnemonic: Nostalgia And Origi Implies Bi
2
3
→ 4
5
• p and q are logically equivalent if p ↔ q is a tautology.
Because for being a Tautology, all truth values must be same
CSE1203: Discrete Mathematics 1-27
Common Propositional Equivalences
• Important Laws of Propositional Logic
1. Double Negation Law:
Idempotence is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application.
2. Idempotent laws: ,
Commute> to move > even though moved, yet remains unchanged
3. Commutative Laws: ,
4. Associative Laws:
Order of Assosiation doesn't matter
5. Distributive Laws:
Just like Distributive law of multiplication
But applicable for both 'AND' and 'OR' operation
During proof, situation arises that we must use this
law to shorten the expression, that is, write the LHS
from RHS CSE1203: Discrete Mathematics 1-28
Common Propositional Equivalences (cont.)
• Important Laws of Propositional Logic
6. De Morgan’s Laws:
7. Identity Laws: ,
8. Domination Laws: ,
9. Complement (Negation) Laws: ,
opposite operations used
10. Absorption Laws:
It itself is a law, can't use distributive law to prove it.
To prove, use truth table
Toughest to remember
CSE1203: Discrete Mathematics 1-29
Common Propositional Equivalences (cont.)
• Important Laws of Propositional Logic
11. p → q ≡ ¬ (p ∧ ¬q ) ≡ ¬p v q [Elimination of Conditional]
Already shown on page 20
12. p → q ≡ ¬ q → ¬ p [Contrapositive]
13. (p → q) ∧ (p → r) ≡ p → (q ∧ r)
Premise same, Conclusion different -> to remember, use common sense
14. (p → q) v (p → r) ≡ p → (q v r)
15. (p → r) ∧ (q → r) ≡ (p v q) → r
Premise different, Conclusion same -> to remember -> opposite of the previous one
16. (p → r) v (q → r) ≡ (p ∧ q) → r
CSE1203: Discrete Mathematics 1-30
Common Propositional Equivalences (cont.)
• Important Laws of Propositional Logic
17. p ↔ q ≡ (p → q) ∧ (q → p) Common sense / According to definition
18. p ↔ q ≡ (p ∧ q) v (¬p ∧ ¬q) Use truth table
19. p ↔ q ≡ q ↔ p ≡ ¬p ↔ ¬q ≡ ¬q ↔ ¬p Converse, Inverse, Contrapositive :- all are same for Biconditional
CSE1203: Discrete Mathematics 1-31
Common Propositional Equivalences (cont.)
• p v (q ∧ r) ≡ (p v q) ∧ (p v r) (Proof)
p q r q∧r p v (q ∧ r) pvq pvr (p v q) ∧ (p v r)
F F F F F F F F
F F T F F F T F
F T F F F T F F
F T T T T T T T
T F F F T T T T
T F T F T T T T
T T F F T T T T
T T T T T T T T
CSE1203: Discrete Mathematics 1-32
Common Propositional Equivalences (cont.)
• ((p ∧ ¬q) v (q ∧ p)) → p ≡ T
LHS ≡ ((p ∧ ¬q) v (q ∧ p)) → p
≡ ¬((p ∧ ¬q) v (q ∧ p)) v p [Elimination of Conditional]
≡ (¬(p ∧ ¬q) ∧ ¬(q ∧ p)) v p [De Morgan’s Law]
≡ ((¬p v ¬(¬q)) ∧ (¬q v ¬p)) v p [De Morgan’s Law]
≡ ((¬p v q) ∧ (¬q v ¬p)) v p [Double Negation Law]
≡ ((¬p v q) ∧ (¬p v ¬q)) v p [Commutative Law]
≡ (¬p v (q ∧ ¬q)) v p [Distributive Law]
≡ (¬p v F) v p [Complement Law]
≡ ¬p v p [Identity Law]
≡T [Complement Law]
= RHS
(Proved)
CSE1203: Discrete Mathematics 1-33