Discrete Mathematics: Unit-I-Chapter-1 Logic-Sets-Functions
Discrete Mathematics: Unit-I-Chapter-1 Logic-Sets-Functions
Unit-I-Chapter-1
Logic-Sets-Functions
Overview of the Subject - DM
Gives you foundation of skills you can build as you need.
Helps in thinking with mathematical maturity.
Why learn mathematics now?
Computation – can’t be seen, touched, yet obeys well-defined rules
Therefore, we need a language to reason about things which we can’t see and
touch and which are too big, but follows strict, simple, well-defined rules
Our reasoning must be consistent!!!
Course Outcomes
After completing this course, the student will be able to:
1. Apply Propositional and Predicate logic for a variety of problems in various domains.
2. Understand Set Theory, Venn Diagrams, relations, functions and apply them to Real-world scenarios.
3. Model and solve the real world problems using Generating Functions and Recurrence Relations.
4. To identify the basic properties of graphs and trees and use these concepts to model simple applications.
5. Understand General properties of Algebraic systems and study lattices as partially ordered sets and their
applications.
6. Apply the knowledge and skills obtained to investigate and solve a variety of discrete mathematics
problems.
Propositional Logic is the logic that deals with statements (propositions) and compound statements
Definition:
Let p be a proposition. The negation of p, denoted by or is the
statement: “ it is not the case that p”.
Example:
Find the conjunction of the propositions p and q where
p: Rebecca’s PC has more than 16 GB free hard disk space and
q: The processor in Rebecca’s PC runs faster than 1 GHz.
: Rebecca’s PC has more than 16 GB free hard disk space, and the processor in Rebecca’s
PC runs faster than 1GHz.
Note: A conjunction p1
Λ p2Λ ….. pn of n
Truth Table for : propositions will have 2n
rows in its truth table
18
BE III Sem-DM - CSE - 2020-21 - MJCET
Compound Propositions: The Exclusive-Or Operator
Definition: Let p and q be propositions. The exclusive or of p and q, denoted by , is the
proposition that is true when exactly one of p and q is true and is false otherwise.
conditional statement.
Neither Inverse nor Converse has same truth value as .
BE III Sem-DM - CSE - 2020-21 - MJCET 21
Examples of implication
p: Today is Easter
q: Tomorrow is Monday
p →q : If today is Easter then tomorrow is Monday.
Converse: q →p: If tomorrow is Monday then today is
Easter.
Inverse: ¬p → ¬q: If today is not Easter then tomorrow
is not Monday.
Contra positive: ¬q → ¬p: If tomorrow is not Monday
then today is not Easter.
BE III Sem-DM - CSE - 2020-21 - MJCET 22
Biconditional Operator
Definition: Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “p if and only if q.” The biconditional statement p ↔ q is true when p and q
have the same truth values, and is false otherwise.
Example
:Let p: You can take the flight and let q: You buy a ticket. Then p ↔ q is the
statement: You can take the flight if and only if you buy a ticket.”
• Construct the truth table of the compound proposition
1. p ∧ ¬ p 17. (p ⊕ q) ∨ (p ⊕ ¬ q)
2. p ∨ ¬ p 18. (p ⊕ q) ∧ (p ⊕ ¬ q)
3. (p ∨ ¬ q) → q 19. p → ¬ q
4. (p ∨ q) → (p ∧ q) 20. ¬ p ↔ q
5. (p → q) ↔ ( ¬ q → ¬ p) 21. (p → q) ∨ ( ¬ p → q)
6. (p → q) → (q → p) 22. (p → q) ∧ ( ¬ p → q)
7. (p ∨ q) → (p ⊕ q) 23. (p ↔ q) ∨ ( ¬ p ↔ q)
8. (p ⊕ q) → (p ∧ q) 24. ( ¬ p ↔ ¬ q) ↔ (p ↔ q)
9. (p ∨ q) ⊕ (p ∧ q) 25. p → ( ¬ q ∨ r)
10. (p ↔ q) ⊕ ( ¬ p ↔ q) 26. ¬ p → (q → r)
11. (p ↔ q) ⊕ ( ¬ p ↔ ¬ r) 27. (p → q) ∨ ( ¬ p → r)
12. (p ⊕ q) → (p ⊕ ¬ q) 28. (p → q) ∧ ( ¬ p → r)
13. p ⊕ p 29. (p ↔ q) ∨ ( ¬ q ↔ r)
14. p ⊕ ¬ p 30. ( ¬ p ↔ ¬ q) ↔ (q ↔ r)
15. p ⊕ ¬ q 31. ((p → q) → r) → s.
16.¬ p ⊕ ¬ q 32. (p ↔ q) ↔ (r ↔ s).
q r s
not You can ride the roller coaster if you are under 4 feet tall unless You r older than 16.
∧¬ 𝑠)→ ¬ 𝑞
(𝑟
2) Show that ¬ (p ∨ ( ¬ p ∧ q)) and ¬ p ∧ ¬ q are logically equivalent by developing a series of logical
equivalences.
¬ (p ∨ ( ¬ p ∧ q)) ≡ ¬ p ∧ ¬ ( ¬ p ∧ q) by the second De Morgan law
≡ ¬ p ∧ [ ¬ ( ¬ p)∨ ¬ q] by the first De Morgan law
≡ ¬ p ∧ (p ∨ ¬ q) by the double negation law
≡ ( ¬ p ∧ p) ∨ ( ¬ p ∧ ¬ q) by the second distributive law
≡ F ∨ ( ¬ p ∧ ¬ q) because ¬ p ∧ p ≡ F
≡ ( ¬ p ∧ ¬ q) ∨ F by the commutative law for disjunction
≡ ¬ p ∧ ¬ q by the identity law for F
Quantification.
Quantification expresses the extent to which a predicate is true over a range of elements.
Area of logic which deals with predicates and quantifiers – Predicate Calculus.
Quantifiers provide a notation that allows us to quantify (count) how many objects in the universe of
proposition that asserts that P(x) is true for all values of x in this
domain.
When all elements in the domain can be listed—say, x1, x2, . . . , xn—the
What are the negations of the statement ∀x (x2 > x) and ∃x (x2 > 2)
Let P(x), Q(x) & R(x) be the stmts “x is a lion”, “x is fierce” and “x drinks coffee”,
respectively.
Assuming the Domain is the Set of all creatures, express the statement in the
argument using quantifiers and P(x),Q(x) and R(x).
Sol: ∀x(P(x) → Q(x))
∃x (P(x) ˄ ¬ R(x))
∃x (Q(x) ˄ ¬ R(x))
BE III Sem-DM - CSE - 2020-21 - MJCET 61
Translating From English into Logical Expressions
Exercise
Consider these statements, of which the first three are premises and the
fourth is a valid conclusion.
“All hummingbirds are richly colored.”
“No large birds live on honey.”
“Birds that do not live on honey are dull in color.”
“Hummingbirds are small.”
Let P(x),Q(x),R(x) and S(x) be the statements “x is a hummingbird”, “x is
large”, “x lives on honey” and “x is colored” respectively. Domain is the set of
all birds, express the statements in the argument using quantifiers and P(x),
Q(x),R(x) and S(x).
a) No one is perfect.
b) Not everyone is perfect.
c) All your friends are perfect.
d) At least one of your friends is perfect.
e) Everyone is your friend and is perfect.
f ) Not everybody is your friend or someone is not perfect.
inverse”.
Express the statement “Everyone has exactly one best friend”
Use quantifiers to express the statement “There is a woman who has taken a
Example: {1, 2, 3, 4}
= {x | x is an integer where x > 0 and x < 5 }
= {x∈Z | x > 0 and x < 5 }
∅⊆S, S⊆S
Ex: All even integers are a subset of all integers.
Superset: (“S is a superset of T ”) means T⊆S
Note (S = T) ≡ (S⊆T ∧ T⊆S)
≡ ∀x(x∈S → x∈T) ∧ ∀x(x∈T → x∈S)
≡ ∀x(x∈S ↔ x∈T)
S ⊆ T means ¬(S⊆T), i.e. ∃x(x∈S ∧ x∉T)
Given a set S, the power set of S is the set of all subsets of the
set S. The Power set of S is denoted by P(S)
The power set of {0,1,2}
P({0,1,2})={∅,{0},{1},{2},{0,1},{1,2},{0,2},{0,1,2}}
Note the empty set and set itself are members of this set of subsets
If a set has n elements, then its power set has 2n elements
105
Proving Set Identities: Using Builder notation
Prove it with builder notation
A B {x | x A B} (def of complement )
{x | ( x ( A B ))} (def of not belong to)
{x | ( x A x B )} (def of intersecti on)
{x | ( x A) ( x B )} (De Morgan' s law)
{x | x A x B} (def of not belong to)
{x | x A x B} (def of complement )
{x | x A B} (def of union)
A B
106
Example
Prove A ( B C ) ( A B ) ( A C )
(→): Suppose that x A ( B C ) then x A
and x B C .
By definition of union, it follows that x A , and x B
or x C . Consequently, x A and x B or x A and x C
By definition of intersection, it follows x A B
or x A C
By definition of union, x ( A B ) ( A C )
107
Example
(←): Suppose that x ( A B) ( A C )
By definition of union,x A B or x A C
By definition of intersection, x A and x B , or x A
andx C
From this, we seex A , and x B or x C
By definition of union, x A and x B C
By definition of intersection, x A ( B C )
108
Proving Set Identities: Using Membership Tables
Analog to truth tables in propositional logic.
Columns for different set expressions.
Rows for all combinations of memberships in constituent
sets.
Use “1” to indicate membership in the derived set, “0” for
non-membership.
Prove equivalence with identical columns
110
Example
Show that A ( B C ) (C B ) A
111
Generalized union and intersection
Since union & intersection are commutative and associative,
we can extend them from operating on pairs of sets A and B to
operating on sequences of sets A1,…, An, or even on sets of sets,
X = {A | P(A)}.
A={0,2,4,6,8}, B={0,1,2,3,4}, C={0,3,6,9}
A⋃B⋃C={0,1,2,3,4,6,8,9}
A⋂B⋂C={0}
117
Functions
Definition: A function f from A to B, f:A→B, is an assignment
of exactly one element of f(x)∈B to each element of x∈A
Def2: Let A and B be sets. A function (mapping, map) f from A
to B, denoted f:A→B, is a subset of AXB
such that ∀x (x ∈ A → ∃y [y ∈ B ∧ <x,y> ∈ f])
and (<x,y1> ∈ f ∧ <x,y2> ∈ f → y1=y2
Note: f associates with each x in A one and only one y in B.
A is called the domain and B is called the codomain.
118
Functions
If it is written that f : A → B, and f(a) = b(where a∈A and b∈B),
then we say:
A is the domain of f
B is the codomain of f
b is the image of a under f
a can not have more than 1 image
a is a pre-image of b under f
b may have more than 1 pre-image
The range R⊆B of f is R = {b | ∃a f(a) = b }
119
Functions
If S is a subset of A then f(S) = {f(s) | s in S}.
Example:
f(a) = Z
the image of d is Z
the domain of f is A = {a, b, c, d}
the codomain is B = {X, Y, Z}
f(A) = {Y, Z}
the preimage of Y is b
the preimages of Z are a, c and d
f({c,d}) = {Z}
120
Types of Functions:
One-to-One Functions(Injective):
A function f is one-to-one (1–1), or injective,or an injection, iff f(a) = f(b)
implies that a = b for all a and b in the domain of f (i.e. every element of its
range has only 1 pre-image).
Formally, given f : A→B,
“f is injective”: ∀a,b ( f(a) = f(b) → a = b) or
equivalently ∀a,b (a ≠ b → f(a) ≠ f(b))
Only one element of the domain is mapped to any given one element of the
range.
Domain & range have the same cardinality.
What about codomain?
121
Types of Functions:
One-to-One Functions(Injective):
Is the function f : {a, b, c, d} → {1, 2, 3, 4, 5} with f(a) = 4, f(b) = 5, f(c) = 1, and
f(d) = 3 one-to-one?
Let f : Z → Z such that f(x) = x2.
Is f one-to-one?
For functions f over numbers, we say:
f is strictly (or monotonically) increasing
iff x > y → f(x) > f(y) for all x, y in domain;
f is strictly (or monotonically) decreasing
iff x > y → f(x) < f(y) for all x, y in domain;
If f is either strictly increasing or strictly decreasing, then f is one-to-one.
122
Types of Functions:
Onto (Surjective) Functions
A function f : A → B is onto or surjective or a surjection iff for every element b∈B
there is an element a∈A with f(a) = b (∀b∈B, ∃a∈A: f(a) = b) (i.e. its range is equal
to its codomain).
Think: An onto function maps the set A onto (over, covering) the entirety of the set B,
not just over a piece of it.
E.g., for domain & codomain R, x3 is onto, whereas x2 isn’t. (Why not?)
123
Types of Functions:
Onto (Surjective) Functions
Is the function f(x) = x + 1 from the set of integers to the set of integers onto
Is the function f : {a, b, c, d} → {1, 2, 3} with f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3 onto?
124
Types of Functions:
Bijection Functions
A function f is said to be a one-to-one correspondence, or a bijection, or
reversible, or invertible, iff it is both one-to-one and onto.
Is the function f : {a, b, c, d} → {1, 2, 3,4} with f(a) = 4, f(b) = 2, f(c) = 1, and f(d) = 3
bijection?
125
Types of Functions:
Inverse Functions
Let f : A → B be a bijection. The inverse function of f is the function that assigns to
an element b∈B the unique element a∈A such that f(a) = b.
The inverse function of f is denoted by f -1 : B → A.
Hence, f -1(b) = a when f(a) = b.
Ex: Let f : {a, b, c} → {1, 2, 3} such that
f(a) = 2, f(b) = 3, f(c) = 1. Is f invertible, and if it is,
what is its inverse?
Yes. f–1(1) = c, f–1(2) = a, f–1(3) = b
Let f be the function from Z to Z with f(x) = x2.
Is f invertible?
No. f is not a one-to-one function. So it’s not invertible.
126
Types of Functions:
Composition of Functions
Let g be a function from A to B and f be a function from B to C,
the composition of the functions f and g, denoted by f ◦ g, is
defined by (f ◦ g)(a)=f(g(a))
First apply g to a to obtain g(a)
Then apply f to g(a) to obtain (f ◦ g)(a)=f(g(a))
Note f ◦ g cannot be defined unless the
range of g is a subset of the domain of f
127
Types of Functions:
Composition of Functions
Ex:Let g: {a, b, c} → {a, b, c}, g(a)=b, g(b)=c, g(c)=a, and f:{a,b,c} →{1,2,3},
f(a)=3, f(b)=2, f(c)=1. What are f ◦ g and g ◦ f?
(f◦g)(a)=f(g(a))=f(b)=2,(f◦g)(b)=f(g(b))=f(c)=1, (f ◦g)(c)=f(a)=3
(g◦f)(a)=g(f(a))=g(3) not defined.
g◦f is not defined
Ex2: Let f(x)=2x+3, g(x)=3x+2. What are f ◦ g and g ◦ f?
(f ◦ g)(x)=f(g(x))=f(3x+2)=2(3x+2)+3=6x+7
(g ◦ f)(x)=g(f(x))=g(2x+3)=3(2x+3)+2=6x+11
Note that f ◦ g and g ◦ f are defined in this example, but they are not equal
The commutative law does not hold for composition of functions
128
Graphs of Functions
We can represent a function f : A → B as a set of ordered pairs {(a, f(a)) | a∈A}.
For functions over numbers, we can represent an ordered pair (x, y) as a
point on a plane.
A function is then drawn as a curve (set of points), with only one y for each x.
130