0% found this document useful (0 votes)
329 views

Discrete Mathematics: Unit-I-Chapter-1 Logic-Sets-Functions

Rebecca’s PC has more than 16 GB free hard disk space and the processor in Rebecca’s PC runs faster than 1GHz. Truth Table: p q p∧q T T T T F F F T F F F F So the conjunction operator is represented by the symbol ∧ in propositional logic. BE III Sem-DM - CSE - 2020-21 - MJCET 17

Uploaded by

Khaja Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
329 views

Discrete Mathematics: Unit-I-Chapter-1 Logic-Sets-Functions

Rebecca’s PC has more than 16 GB free hard disk space and the processor in Rebecca’s PC runs faster than 1GHz. Truth Table: p q p∧q T T T T F F F T F F F F So the conjunction operator is represented by the symbol ∧ in propositional logic. BE III Sem-DM - CSE - 2020-21 - MJCET 17

Uploaded by

Khaja Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 128

Discrete Mathematics

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

 Computations - are too big to be comprehended all at once.

 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!!!

BE III Sem-DM - CSE - 2020-21 - MJCET 2


Goals of this course
Course Objectives
To Learn mathematical concepts as applied in computer science for solving logical problems.
To model relationships, analyse data, apply probability concepts and use functions to solve problems.
To develop the mathematical skills needed for advanced quantitative courses.

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.

BE III Sem-DM - CSE - 2020-21 - MJCET 3


Syllabus in a Nutshell.
Unit 1: Ch-I:Logic-Sets and Functions:
Logic, Propositional equivalences – Predicates Unit 3: Ch-I:Discrete Probability: An Introduction to
and quantifiers – Nested Quantifiers-Sets-Set Discrete Probability theory, Expected Value and Variance.
Operations, Functions. Ch-II: Advanced Counting Techniques: Recurrence
Ch-II: Algorithms-Integers-Matrices: relations – Solving Recurrence Relations, - Divide and conquer
Algorithms, Complexity of Algorithms. The relations – and Recurrence Relations, Generating function –
Integers and Division, Integers and Algorithms, Inclusion – Exclusion – Applications of Inclusion – Exclusion.
Applications of Number Theory, Matrices.
Unit 4: Ch-I: Relations: Relations & their Properties, n-ray
Unit 2: relations and applications, Representing relations – Closures,
Ch-I:Mathematical Reasoning, equivalence relations, partial orderings.
Induction, and Recursion: Proof Strategy, Ch-II: Graphs: Introduction, Graph terminology, representing
Sequence and Summation, Mathematical Graphs and Graph Isomorphism, Connectivity, Euler and Hamiltonian
Induction, Recursive Definitions and Structural paths, Shortest path problems, Planar graphs, Graph coloring.
Induction, Recursive Algorithms.
Ch-II: Counting: Basics, Pigeonhole Unit 5: Ch-I:Trees: Introduction to Trees, Application of
principle, Permutations and combinations – Trees, Spanning Trees, Minimum Spanning Trees.
Binomial Coefficients, Generalized Ch-II: Boolean Algebra: Boolean function, Representing
Permutations and combinations, Generating Boolean functions, Logic Gates
permutations and combinations.
BE III Sem-DM - CSE - 2020-21 - MJCET 5
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.

BE III Sem-DM - CSE - 2020-21 - MJCET 6


Why Study Discrete Mathematics?
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., …

BE III Sem-DM - CSE - 2020-21 - MJCET 7


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!
BE III Sem-DM - CSE - 2020-21 - MJCET 8
Mathematical Logic
 

BE III Sem-DM - CSE - 2020-21 - MJCET 9


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.
 Gives precise meaning to mathematical statements.

 Propositional Logic is the logic that deals with statements (propositions) and compound statements

built from simpler statements using so-called Boolean connectives.


 Rules of logic – give precise meaning to mathematical statements.
 Rules are used to distinguish between valid (true) and invalid arguments/ Statements

 Some applications of logic in computer science:


 Design of Digital Electronic circuits,

 Expressing conditions in computer programs,

 Queries to databases and search engines.

 Verification of correctness of a program, etc.

BE III Sem-DM - CSE - 2020-21 - MJCET 10


Propositional Logic
Proposition

 Basic building block of Logic.


 A declarative sentence (a sentence that declares a fact) that is either true or

false, but not both.


 
Are these propositions? Are these propositions?
a) New Delhi is capital city of India. a) What time is it?
b) Today is Monday. b) Read this carefully.
c) 1+1=2
d) 2+2=3
BE III Sem-DM - CSE - 2020-21 - MJCET 11
Propositional Logic
 Propositional Variables – variables that represent propositions.
 English letters like: p, q, r, s, t, u, v, .. are used for Propositional variables.

p: New Delhi is capital city of India


q: John’s PC runs on Linux operating system.
r: This phone has 8GB of RAM.

• Truth value of a proposition is true, denoted as T, if it is a true


proposition.
• Truth value of a proposition is false, denoted as F, if it is a false
proposition.
Note: The area of logic that deals with propositions is called as Propositional
Calculus or Propositional Logic
BE III Sem-DM - CSE - 2020-21 - MJCET 12
Truth Tables
 An operator or connective combines one or more operand expressions
into a larger expression. (e.g., “+” in numeric expressions.)
 Unary operators take one operand (e.g.,−3); Binary operators take two
operands (e.g.3 x 4).
 Propositional or Boolean operators operate on propositions (or their
truth values) instead of on numbers.
 The Boolean domain is the set {T, F}. Either of its elements is called a
Boolean value. An n-tuple (p1,…,pn) of Boolean values is called a
Boolean n-tuple.
 An n-operand truth table is a table that assigns a Boolean value to the
set of all Boolean n-tuples.
BE III Sem-DM - CSE - 2020-21 - MJCET 13
Some Popular Boolean Operators

BE III Sem-DM - CSE - 2020-21 - MJCET 15


The Negation Operator
The unary negation operator “¬” (NOT) transforms a
proposition into its logical negation.

Definition:
  Let p be a proposition. The negation of p, denoted by or is the
statement: “ it is not the case that p”.

•  Proposition is read as “not p” . Truth Table: shows


• Truth value of is opposite of truth truth or falsity of a
value of p. compound proposition
based on truth or falsity Fig: Truth table
• of simple propositions
  for
 • p: John’s PC runs Linux OS
: It is not the case that John’s PC runs Linux OS. (or) from which it is built.
• : John’s PC does not run Linux OS.

BE III Sem-DM - CSE - 2020-21 - MJCET 16


Compound Propositions: The Conjunction Operator
 Definition: Let p and q be propositions. The Conjunction of p and q, denoted by , is the
proposition “p and q”. The conjunction is true only when both p and q are true and is
false otherwise.

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

BE III Sem-DM - CSE - 2020-21 - MJCET 17


Compound Propositions: The Disjunction Operator
 Definition: Let p and q be propositions. The Disjunction of p and q, denoted by , is the
proposition “p or q”. The disjunction is false only when both p and q are false and is true
otherwise.

Note: Connective or in disjunction corresponds to


one of two ways the word or is used in English,
namely inclusive or.
• For ex: “students who have taken Calculus or
Computer Science can enroll in this class”. (it is
inclusive or)
• For ex: “students who have taken Calculus or CS,
but not both can enroll in this class”. (it is
exclusive or)
• Inclusive or exclusive?: “Tea or Coffee comes free   Truth Table for :
with main course in this restaurant”

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.

For each of these sentences, state what the sentence


means if the logical connective or is an inclusive or (that
is, a disjunction) versus an exclusive or.
a. To take discrete mathematics, you must have taken
calculus or a course in computer science.
b. When you buy a new car from Acme Motor Company,
you get $2000 back in cash or a 2% car loan.   Truth table for
c. Dinner for two includes two items from column A or
three items from column B. This operation is called
d. School is closed if more than 2 feet of snow falls or if exclusive or, because it
the wind chill is below −100. excludes the possibility
that both p and q are
true.
BE III Sem-DM - CSE - 2020-21 - MJCET 19
Conditional Statements: The Implication Operator
Definition: Let p and q be propositions. The conditional statement p → q is the proposition
“if p, then q.” The conditional statement p → q is false when p is true and q is false, and
true otherwise.

•  In conditional statement , p is called hypothesis


(premise) and q is called the conclusion
(consequence).
• asserts that q is true on the condition that p holds.
• Conditional statement is aka Implication.

Truth Table for


As implication is a very important connective, different terminology   is used to express
it: “if p, then q”, “p implies q”, “if p, q”, “p only if q”, “p is sufficient for q”, “a sufficient condition for q
is p”, “q if p”, “q whenever p”, “q when p”, “q is necessary for p”, “a necessary condition for p is q”, “q
follows from p” “q unless ¬ p”.
•If p is true, then q is true; but if p is not true, then q could be either true or false.
•p → q does not require that p or q are ever true!
BE III Sem-DM - CSE - 2020-21 - MJCET 20
Understanding Implication!!
  
 Example 1: “ If I am elected I will lower the taxes”
 Example 2: “ If you get 100% on the final then you will get A grade”
 Example 3: “If it is raining then road is wet”
 Example 4: “If Mohd learns DM, then he will get a good job”
 New Conditional Statements from Implication:
 Converse : The proposition is called Converse of implication

 Inverse: The proposition is called the Inverse of implication .

 Contrapositive: The proposition is called Contrapositive of implication .

 Contrapositive of conditional statement always has same truth value as

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.

• Biconditional statements are also called bi-implications.


• The statement p ↔ q is true when both the conditional
statements p → q and q → p are true and is false
otherwise.
• That is the reason, it is also read as “if and only if”.
• p ↔ q has exactly the same truth value as (p → q) ∧ (q →
p). Truth table for Biconditional
• Note this truth table is the exact opposite of ⊕’s! Thus, p ↔ q
means ¬(p ⊕ q).

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.”

BE III Sem-DM - CSE - 2020-21 - MJCET 23


Truth Tables of Compound Propositions
 Construct the truth table of the compound proposition (p ∨¬q) → (p ∧ q).

 
• Construct the truth table of the compound proposition

BE III Sem-DM - CSE - 2020-21 - MJCET 24


Exercises
1. Let p and q be the propositions “Swimming at the New Jersey shore is allowed” and “Sharks have
been spotted near the shore,” respectively. Express each of these compound propositions as an
English sentence.
a) ¬q b) p ∧ q c) ¬p ∨ q d) p →¬q e) ¬q → p f ) ¬p →¬q g) p ↔¬q h) ¬p
∧ (p∨ ¬q)
2. Let p and q be the propositions p :You drive over 65 miles per hour. q :You get a speeding ticket.
Write these propositions using logical connectives.
a). You do not drive over 65 miles per hour.
b) You drive over 65 miles per hour, but you do not get a speeding ticket.
c) You will get a speeding ticket if you drive over 65 miles per hour.
d) If you do not drive over 65 miles per hour, then you will not get a speeding ticket.
e) Driving over 65 miles per hour is sufficient for getting a speeding ticket.
f ) You get a speeding ticket, but you do not drive over 65 miles per hour.

BE III Sem-DM - CSE - 2020-21 - MJCET 25


Boolean Operations Summary

BE III Sem-DM - CSE - 2020-21 - MJCET 26


Precedence of logic operators
Precedence also can be
indicated by parentheses.
e.g. ¬p ∧ q means (¬p) ∧ q,
not ¬(p ∧ q)

BE III Sem-DM - CSE - 2020-21 - MJCET 27


Exercise
Construct a truth table for each of these compound propositions.

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).

BE III Sem-DM - CSE - 2020-21 - MJCET 28


Applications of Propositional Logic

 Statements in maths, science and natural language are often ambiguous.


 To make them precise, use language of Logic!!
 For example: software/hardware specifications, computer programs, expert

systems, circuits specifications, etc. often need to be precise.

• Translating English Sentences:


• English sentences are often ambiguous, translating in compound propositions
removes ambiguity.
• And also, using compound proposition, we can know its truth value.

BE III Sem –DM-Cse - 2020-21 - MJCET 29


Translating English Sentences into Compound Propositions
 Translate: “You can access the Internet from campus only if you are a

computer science major or you are not a freshman.”


 Let us break the sentence into parts (simple propositions).
 a: You can access Internet from Campus.

 c: You are a computer science major.

 f: You are a freshman.

 Let us look at connectives in sentence:


a c
You can access the Internet from campus Only if you are a computer science or
major
not You are a freshman 𝑎  ⟶(𝑐 ∨¬ 𝑓 )
f

BE III Sem - DM - 2020-21 - MJCET 30


Translating English Sentences
 Translate: “You cannot ride the roller coaster if you are under 4 feet tall unless you

are older than 16 years old.”


 Lets break it into parts (simple propositions)
 q: you can ride the roller coaster.

 r: you are under 4 feet tall.

 s: you are older than 16 years old.

q r s
not You can ride the roller coaster if you are under 4 feet tall unless You r older than 16.

  ∧¬ 𝑠)→ ¬ 𝑞
(𝑟

BE III Sem -DM - 2020-21 - MJCET 31


Translating English Sentences
Let p = “It rained last night”,
q = “The sprinklers came on last night,”
r = “The lawn was wet this morning.”
Translate each of the following into English:
¬p= “It didn’t rain last night.”
r ∧ ¬p= “The lawn was wet this morning, and it didn’t rain
last night.”
¬r ∨ p ∨ q =“The lawn wasn’t wet this morning, or it rained
last night, or the sprinklers came on last night.”
BE III Sem-DM - CSE - 2020-21 - MJCET 32
Determining using Logic

BE III Sem-DM - CSE - 2020-21 - MJCET 33


Logic and Bit Operations
A bit is a binary (base 2) digit: 0 or 1.
Bits may be used to represent truth values.
By convention: 0 represents “False”; 1 represents “True”.
A bit string of length n is an ordered sequence of n≥0 bits.
By convention, bit strings are (sometimes) written left to
right:
e.g. the “first” bit of the bit string “1001101010” is 1.
What is the length of the above bit string?
BE III Sem-DM - CSE - 2020-21 - MJCET 34
Bitwise Operations
Boolean operations can be extended to operate on bit
strings as well as single bits.
Example:
01 1011 0110
11 0001 1101
----------------------
11 1011 1111 ----Bitwise OR
01 0001 0100 ----Bitwise AND
10 1010 1011 ----Bitwise XOR

BE III Sem-DM - CSE - 2020-21 - MJCET 35


Propositional Equivalences
An important step in mathematical argument is replacement of one
statement with another statement with same truth value.
A compound proposition that is always true, no matter what the truth
values of the propositional variables that occur in it, is called a
Tautology.
A compound proposition that is always false is called a Contradiction.
A compound proposition that is neither a tautology nor a contradiction
is called a Contingency.
Consider the truth tables of p ∨¬p and p ∧¬p.

BE III Sem-DM - CSE - 2020-21 - MJCET 36


Logical Equivalences
 Compound propositions that have the same truth values in all possible cases are called
logically equivalent.

The compound propositions p and q are called logically equivalent if p ↔ q is a


tautology. The notation p ≡ q denotes that p and q are logically equivalent.
 One way to determine whether two compound propositions are equivalent is to use a
truth table.
 Compound propositions p and q are logically equivalent to each other iff p and q
contain the same truth values as each other in all corresponding rows of their
truth tables.

BE III Sem-DM - CSE - 2020-21 - MJCET 37


Logical Equivalences
 Show that ¬(p ∨ q) and ¬p ∧¬q are logically equivalent.

 Show that p → q and ¬p ∨ q are logically equivalent.

 In general, 2n rows are required if a compound proposition involves n propositional variables.

BE III Sem-DM - CSE - 2020-21 - MJCET 38


An example..
 Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent.

 Let us now look at some important well known Equivalences.

BE III Sem-DM - CSE - 2020-21 - MJCET 39


Well Known Logical Equivalences…

BE III Sem-DM - CSE - 2020-21 - MJCET 40


Logical Equivalences using implications & Biconditionals

BE III Sem-DM - CSE - 2020-21 - MJCET 41


An Example Problem
1.Show that ¬(p → q) and p ∧ ¬q are logically equivalent.
¬(p → q)
 ≡ ¬(¬ p ∨ q) [By definition of (p → q) ≡ ¬p ∨ q]
≡ ¬(¬p) ∧ ¬q [By De Morgan’s Law]
≡ p ∧ ¬q [By Double Negation Law]

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

BE III Sem-DM - CSE - 2020-21 - MJCET 42


Exercise
 Show that (p ∧ q) → (p ∨ q) is a tautology.
 Show that p ↔ q and (p ∧ q) ∨ ( ¬ p ∧ ¬ q) are logically equivalent.
 Show that ¬ (p ↔ q) and p ↔ ¬ q are logically equivalent.
 Show that p → q and ¬ q → ¬ p are logically equivalent.
 Show that ¬ p ↔ q and p ↔ ¬ q are logically equivalent.
 Show that ¬ (p ⊕ q) and p ↔ q are logically equivalent.
 Show that ¬ (p ↔ q) and ¬ p ↔ q are logically equivalent.
 Show that (p → q) ∧ (p → r) and p → (q ∧ r) are logically equivalent.
 Show that (p → r) ∧ (q → r) and (p ∨ q) → r are logically equivalent.
 Show that (p → q) ∨ (p → r) and p → (q ∨ r) are logically equivalent.
 Show that (p → r) ∨ (q → r) and (p ∧ q) → r are logically equivalent.
 Show that ¬ p → (q → r) and q → (p ∨ r) are logically equivalent.
 Show that p ↔ q and (p → q) ∧ (q → p) are logically equivalent.
 Show that p ↔ q and ¬ p ↔ ¬ q are logically equivalent

BE III Sem-DM - CSE - 2020-21 - MJCET 43


Exercise
 Show that (p ∧ q) → (p ∨ q) is a tautology.
By def of impl

 Show that p ↔ q and (p ∧ q) ∨ ( ¬ p ∧ ¬ q) are logically equivalent.

 Show that (p → r) ∨ (q → r) and (p ∧ q) → r are logically equivalent.

BE III Sem-DM - CSE - 2020-21 - MJCET 44


Predicates and Quantifiers
Predicate Logic – Definition
 A predicate is an expression of one or more variables defined on some specific domain. A
predicate with variables can be made a proposition by either assigning a value to the
variable or by quantifying the variable.
 Can be used to express the meaning of a wide range of statements
 Example: x > 3 . Can you answer them as T or F?
 The variable x is the subject of the statement
 Predicate “is greater than 3” refers to a property that the subject of the statement can have
 Can denote the statement by P(x) where P denotes the predicate “is greater than 3” and x is
the variable.
 P(x): also called the value of the propositional function P at x
 Once a value is assigned to the variable x, P(x) becomes a proposition and has a truth value
 P(2) is a predicate, P(4) is a predicate, etc.

BE III Sem-DM - CSE - 2020-21 - MJCET 45


Predicates
 Let R(x): x+y=z, what is the truth value of R(1,2,3) and R(0,0,1).

BE III Sem-DM - CSE - 2020-21 - MJCET 46


N-ary Predicate
A statement involving n variables, x1, x2, …, xn, can be
denoted by P(x1, x2, …, xn)
P(x1, x2, …, xn) is the value of the propositional
function P at the n-tuple (x1, x2, …, xn)
P is also called n-ary predicate

BE III Sem-DM - CSE - 2020-21 - MJCET 47


Quantifiers
 Assigning values to variables in predicates results in propositions.
 One more way to do this: convert propositional functions into propositions by

Quantification.
 Quantification expresses the extent to which a predicate is true over a range of elements.

(like is it true for all, some, none, etc)


 Two types of quantifications to be studied:
 Universal – tells that predicate is true for every element from a set under consideration

 Existential – a predicate is true for one or more elements under consideration.

 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

discourse satisfy the given predicate.


BE III Sem-DM - CSE - 2020-21 - MJCET 48
Universal Quantifier
The collection of values that a variable x can take is called x’s universe of

discourse or the domain of discourse(often just referred to as the domain).


Many mathematical statements assert that a property is true for all values

of a variable in a particular domain.


Such statements are expressed using Universal Quantification
The universal quantification of P(x) for a particular domain is the

proposition that asserts that P(x) is true for all values of x in this
domain.

BE III Sem-DM - CSE - 2020-21 - MJCET 49


Universal Quantifier
 The universal quantification of P(x) is the statement “P(x) for all values of x in the
domain.”
 The notation ∀x P(x) denotes the universal quantification of P(x). Here ∀ is called the
Universal Quantifier.
 We read ∀x P(x) as “for all x P(x)” or “for every x P(x).”
 A statement ∀x P(x) is false if and only if p(x) is not always true
 An element for which P(x) is false is called a counterexample of ∀x P(x).
 A single counterexample is all we need to establish that ∀x P(x) is not true
 When all the elements can be listed, e.g., x1, x2, …, xn, it follows that the universal
quantification ∀x P(x) is the same as the conjunction P(x1) ˄P(x2) ˄…˄P(xn).
1. Let P(x) be the statement “x + 1 > x.” What is the truth value of ∀x P(x), where the
domain consists of all real numbers?
2. Let Q(x) be the statement “x < 2.” What is the truth value of ∀x Q(x), where the
domain consists of all real numbers?

BE III Sem-DM - CSE - 2020-21 - MJCET 50


Universal Quantifier
1. What is the truth value of ∀x P(x) where P(x) is the statement
“x2 < 10” and the domain consists of positive integers not
exceeding 4?
2. What is the truth value of ∀x (x2 ≥ x) if the domain consists of
all real numbers and what is the truth value if the domain
consists of all integers?

BE III Sem-DM - CSE - 2020-21 - MJCET 51


Existential quantifier
 Many mathematical statements assert that there is an element( one or more)
with certain property. Such statements are expressed using existential
quantifiers.
• In addition to “there exists”, we can also express existential
quantifier as “for some”, “for at least one”, “there is”, etc.
• It is read as : “there is an x such that P(x)”, “there is at least one x
such that P(x)”, or “for some x P(x)”

The existential quantification of P(x) is the proposition “There exists an


element x in the domain such that P(x).”
We use the notation ∃x P(x) for the existential quantification of P(x). Here ∃
is called the existential quantifier.

BE III Sem-DM - CSE - 2020-21 - MJCET 52


Existential quantifier
∃x P(x) is
 True if P(x) is true for at least one x in the domain
 False if P(x) is false for every x in the domain

 When all elements in the domain can be listed—say, x1, x2, . . . , xn—the

existential quantification ∃x P(x) is the same as the disjunction


 P(x1) ∨ P(x2) ∨ · · · ∨ P(xn), because this disjunction is true if and only if at least

one of P(x1), P(x2), . . . , P(xn) is true.

BE III Sem-DM - CSE - 2020-21 - MJCET 53


Existential quantifier
 Let P(x) denote the statement “x > 3.” What is the truth value of the

quantification ∃xP(x), where the domain consists of all real numbers?


 Let Q(x) denote the statement “x = x + 1.”What is the truth value of the

quantification ∃xQ(x), where the domain consists of all real numbers?


 What is the truth value of ∃x P(x), where P(x) is the statement “x2 > 10” and

the universe of discourse consists of the positive integers not exceeding 4?

BE III Sem-DM - CSE - 2020-21 - MJCET 54


Quantifiers- Summary

BE III Sem-DM - CSE - 2020-21 - MJCET 55


Quantifiers- Some facts

x p( x )  q ( x)  (x p ( x ))  q ( x) rather tha n x ( p ( x)  q ( x ))

BE III Sem-DM - CSE - 2020-21 - MJCET 56


Quantifiers
 What is the truth value of ∃xP(x), where P(x) is the statement “x2 > 10” and
the domain consists of positive integers not exceeding 4?
∃xP(x), is the same as P(1) ˅P(2) ˅P(3) ˅ P(4)

BE III Sem-DM - CSE - 2020-21 - MJCET 57


Negating Quantified Expression
Negating Universal Quantifier and Existential Quantifier
 Consider: “Every student in your class has taken a course in Calculus.”
 This stmt is universal quantification ∀x P(x) , where P(x) is the stmt “x
has taken a course in Calculus.” The negation of this stmt is “There is a
student who has not taken a course in calculus.” i.e; ∃x ¬ P(x).
 So ¬ ∀ x P(x) ≡ ∃x ¬ P(x)
 Similarly ¬ ∃ x P(x) ≡∀x ¬ P(x)

BE III Sem-DM - CSE - 2020-21 - MJCET 58


Negating Quantified Expression
Exercise :
What are negations of following propositions:
There is an honest politician.

All American eat Cheeseburgers.

What are the negations of the statement ∀x (x2 > x) and ∃x (x2 > 2)

BE III Sem-DM - CSE - 2020-21 - MJCET 59


Translating From English into Logical Expressions
 Ex: Express the stmt “Every student in this class has studied calculus” using
predicates and quantifiers
Sol: Let C(x) be the statement that “x has studied calculus”.
 If domain for x consists of the students in this class, then
 it can be translated as ∀ x C(x)
 If domain for x consists of all people
 Let S(x)be the predicate: “x is in this class”
 Translation: ∀ x(S(x) → C(x))

BE III Sem-DM - CSE - 2020-21 - MJCET 60


Translating From English into Logical Expressions
 Consider these statements. The first two are called premises and the third is
called the conclusion. The entire set is called an argument.
 “All lions are fierce.”
 “Some lions do not drink coffee.”
 “Some fierce creatures do not drink coffee.”

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).

BE III Sem-DM - CSE - 2020-21 - MJCET 62


Converting into Quantified Expressions
Exercise
 Translate each of these statements into logical expressions using predicates,
quantifiers, and logical connectives.

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.

BE III Sem-DM - CSE - 2020-21 - MJCET 63


Nested Quantifiers
 Example:
 Let the domain of x and y be people.
 Let L(x,y) = “x likes y” (A statement with 2 free variables – not a proposition)
 Then ∃y L(x,y) = “There is someone whom x likes.” (A statement with 1 free
variable x– not a proposition)
 Then ∀x (∃y L(x,y)) =“Everyone has someone whom they like.”
 (A proposition with zero free variables.)
Definition:
 Nested quantifiers are quantifiers that occur within the scope of other
quantifiers.

BE III Sem-DM - CSE - 2020-21 - MJCET 64


Nested Quantifiers
 Examples:
1. ∀x∃y(x+y=0) where x,y are real numbers.
2. ∀x∀y∀z(x+(y+z)=(x+y)+z) x,y,z real. (associative law for addition).
3. Translate into English the stmt ∀x∀y((x>0) ˄ (y<0) → (xy<0)), x,y are real
 For all x and for all y if x is positive and y is negative then their product
must be negative.
 The product of a positive and a negative real number is negative.

4. Translate this sentence into a logical expressions.


 “If a person is female and is a parent, then she is someone’s mother.”
Sol: F(x) is “x is female”, P(x) is “x is someone’s parent”, M(x,y), “x is the mother of y”
∀x((F(x) ˄ P(x)) → ∃yM(x,y)

BE III Sem-DM - CSE - 2020-21 - MJCET 65


Order of Nested Quantifiers
 The order of the quantifiers is important, unless all the quantifiers are
universal quantifiers or all are existential quantifiers.
 ∃y∀xP(x,y) and ∀x∃yP(x,y) are not logically equivalent.
 Example: Find the truth values of ∃y∀xP(x,y)(x+y=0) and ∀x∃yP(x,y)(x+y=0)
when x,y are real.
 ∃y∀xP(x,y)(x+y=0) : There is a y such that for all x (x+y=0). (F)
 ∀x∃yP(x,y)(x+y=0) : For all x there is a y such that x+y=0 (T)
 Therefore both are not logically equivalent.

 What do we learn? The order is important!

BE III Sem-DM - CSE - 2020-21 - MJCET 66


Order of Nested Quantifiers

BE III Sem-DM - CSE - 2020-21 - MJCET 67


Exercise…
 Translate the statement “The sum of two positive integers is always positive”

into a logical expression.


 Translate the statement “Every real number except zero has a multiplicative

inverse”.
 Express the statement “Everyone has exactly one best friend”
 Use quantifiers to express the statement “There is a woman who has taken a

flight on every airline in the world.”

BE III Sem-DM - CSE - 2020-21 - MJCET 68


Rules of Inference
 Theorems often involve proving that an argument is valid.
 Proof: Valid arguments that establish the truth of a mathematical statement
 Argument: An argument is a sequence of statements ending in a conclusion.
 Some forms of argument (“valid”) never lead from correct statements to an incorrect conclusion.
 Some other forms of argument (“fallacies”) can lead from true statements to an incorrect conclusion.
 A logical argument consists of a list of (possibly compound) propositions called
premises/hypotheses and a single proposition called the conclusion.
 Logical rules of inference: Methods that depend on logic alone for deriving a new statement from a
set of other statements. (Templates for constructing valid arguments.)
 Rules of Inference are basic tools for establishing truth of statements.
 Consider this argument:
 “If you have current Wi-Fi password, then you can access Campus Internet”

 “You have current Wi-Fi password.”

 Therefore: “You can access Campus Internet.”

BE III Sem-DM - CSE - 2020-21 - MJCET 69


Rules of Inference
 

BE III Sem-DM - CSE - 2020-21 - MJCET 70


Rules of Inference
 

BE III Sem-DM - CSE - 2020-21 - MJCET 71


Rules of Inference
 Example: A logical argument
 If I study all night, then I get tired.
 I studied all night.
 Therefore I got tired.
 Logical representation of underlying variables:
 p: I study all night. q: I get tired.
 Logical analysis of argument:
 p→q premise 1
 p premise 2
 ∴ q conclusion

BE III Sem-DM - CSE - 2020-21 - MJCET 72


Rules of Inference
 An Inference Rule is
 A pattern establishing that if we know that a set of premise statements of certain forms are all true,
then we can validly deduce that a certain related conclusion statement is true.
 premise 1
 premise 2
 ………………..
 ∴ conclusion “∴” means “therefore”

 Each valid logical inference rule corresponds to an implication that is a tautology.


 premise 1
 premise 2 Inference rule
 ··· .
 ∴ conclusion
 Corresponding tautology:
 ((premise 1) ∧ (premise 2) ∧ ….) → conclusion

BE III Sem-DM - CSE - 2020-21 - MJCET 73


Rules of Inference
 Modus Ponens:
Rule of Modus ponens (a.k.a. law of detachment) “the mode of affirming”
p
p→q
∴q
(p ∧ (p →q)) → q is a tautology
p q p →q (p ∧ (p →q)) (p ∧ (p →q)) → q
T T T T T
T F F F T
F T T F T
F F T F T
Notice that the first row is the only one where premises are all true

BE III Sem-DM - CSE - 2020-21 - MJCET 74


Rules of Inference
Modus Ponens Example
p → q : “If n is divisible by 3 then n2 is divisible by 3”
p : “n is divisible by 3”
∴q : “n2 is divisible by 3”

BE III Sem-DM - CSE - 2020-21 - MJCET 75


Rules of Inference
Modus Tollens:
Rule of Modus tollens (the mode of denying)
¬q
p→q
∴¬p
(¬q ∧ (p →q)) → ¬p is a tautology
Example:
p → q : “If this jewel is really a diamond then it will scratch glass”
¬q : “The jewel doesn’t scratch glass”
∴ ¬p : “The jewel is not a diamond”

BE III Sem-DM - CSE - 2020-21 - MJCET 76


Rules of Inference

BE III Sem-DM - CSE - 2020-21 - MJCET 77


Rules of Inference
 State which rule of inference is the basis of the following arguments:
 It is below freezing now. Therefore, it is either below freezing or raining now.
 It is below freezing and raining now. Therefore, it is below freezing now.

p: It is below freezing now.


q: It is raining now.
p → (p ∨ q) (rule of addition)
(p ∧ q) → p (rule of simplification)

BE III Sem-DM - CSE - 2020-21 - MJCET 78


Rules of Inference
Example: State the rule of inference used in the argument:
 “If it rains today, then we will not have a barbecue today. If we do not have a
barbecue today, then we will have a barbecue tomorrow. Therefore, if it rains
today, then we will have a barbecue tomorrow.”
 Ed’s wallet is in his back pocket or it is on his desk. Ed’s wallet is not in his
back pocket. Therefore, Ed’s wallet is on his desk.
 “Jasmine is skiing or it is not snowing” and “It is snowing or Bart is playing
hockey” imply that “Jasmine is skiing or Bart is playing hockey”
 Suppose we have the following premises:
 “It is not sunny and it is cold.”“We will swim only if it is sunny.”“If we do not swim,
then we will canoe.”“If we canoe, then we will be home by sunset.” Given these
premises, prove the conclusion “We will be home by sunset” using inference rules.

BE III Sem-DM - CSE - 2020-21 - MJCET 79


Rules of Inference for Quantified Statements

Universal instantiation
Used to conclude that P(c) is true, where c is a particular member of the domain, given the
premise ∀xP(x).
Universal instantiation is used when we conclude from the statement “All women are wise” that “Lisa is
wise,” where Lisa is a member of the domain of all women.

Universal generalization
States that ∀xP(x) is true, given the premise that P(c) is true for all elements c in the domain.
Universal generalization is used when we show that ∀xP(x) is true by taking an arbitrary element c from
the domain and showing that P(c) is true.

Existential instantiation
The rule that allows us to conclude that there is an element c in the domain for which P(c) is true if we
know that ∃xP(x) is true.

Existential generalization
The rule of inference that is used to conclude that ∃xP(x) is true when a particular
element c with P(c) true is known.
That is, if we know one element c in the domain for which P(c) is true, then we know that ∃xP(x) is true.

BE III Sem-DM - CSE - 2020-21 - MJCET 80


Rules of Inference for Quantified Statements

BE III Sem-DM - CSE - 2020-21 - MJCET 81


Rules of Inference for Quantified Statements
Show that the premises “Everyone in this discrete mathematics class has taken
a course in computer science” and “Marla is a student in this class” imply the
conclusion “Marla has taken a course in computer science.”
Sol: Let D(x) denote “x is in this discrete mathematics class,” and let C(x)
denote “x has taken a course in computer science.” Then the premises are
∀x(D(x) → C(x)) and D(Marla). The conclusion is C(Marla).
The following steps can be used to establish the conclusion from the premises.
Step Reason
1.∀x(D(x) → C(x)) Premise
2.D(Marla) → C(Marla) Universal instantiation from(1)
3.D(Marla) Premise
4.C(Marla) Modus ponens from (2) and (3)

BE III Sem-DM - CSE - 2020-21 - MJCET 82


Rules of Inference for Quantified Statements
Show that the premises “A student in this class has not read the book,” and “Everyone in this class passed
the first exam” imply the conclusion “Someone who passed the first exam has not read the book.”
Let C(x) be “x is in this class,” B(x) be “x has read the book,” and P(x) be “x passed the first exam.” The
premises are ∃x(C(x) ∧ ¬B(x)) and ∀x(C(x) → P(x)). The conclusion is ∃x(P(x) ∧ ¬B(x)).
These steps can be used to establish the conclusion from the premises.
Step Reason
1. ∃x(C(x) ∧ ¬B(x)) Premise
2. C(a) ∧¬B(a) Existential instantiation from (1)
3. C(a) Simplification from (2)
4. ∀x(C(x) → P(x)) Premise
5. C(a) → P(a) Universal instantiation from (4)
6. P(a) Modus ponens from (3) and (5)
7. ¬B(a) Simplification from (2)
8. P(a)∧ ¬B(a) Conjunction from (6) and (7)
9. ∃x(P(x) ∧ ¬B(x)) Existential generalization from (8)

BE III Sem-DM - CSE - 2020-21 - MJCET 83


Sets
A set is a new type of structure, representing an unordered
collection (group) of zero or more distinct (different) objects. The
objects are called elements or members of the set.
Notation: x ∈ S, x is an element of set S.
Used to group objects together
Ex:
 The set of all vowels in the English alphabet can be written as V={a, e, i, o, u}
 The set of odd positive integers less than 10 can be expressed by O={1, 3, 5, 7, 9}
 Nothing prevents a set from having seemingly unrelated elements, {a, 2, Fred, New
Jersey}
 The set of positive integers<100: {1,2,3,…, 99}

BE III Sem-DM - CSE - 2020-21 - MJCET 84


Sets-Basic Notations
 For sets, we’ll use variables S, T, U,…
 We can denote a set S in writing by listing all of its elements in curly braces:
 {a,b,c} is the set whose elements are a, b, and c
 Set builder : characterize the elements by stating the property or properties
 For any statement P(x) over any domain,
 {x | P(x)} is the set of all x such that P(x) is true

Example: {1, 2, 3, 4}
= {x | x is an integer where x > 0 and x < 5 }
= {x∈Z | x > 0 and x < 5 }

BE III Sem-DM - CSE - 2020-21 - MJCET 85


Definition of Set Equality
 Two sets are declared to be equal if and only if they contain exactly
the same elements.
That is if A and B are sets, then A and B are equal if and only
if ∀x (x ∈ A ↔ x ∈ B). We write A=B if A and B are equal sets
The sets {1, 3, 5} and {3, 5, 1} are equal
 In particular, it does not matter how the set is defined or denoted.
Example: The set {1, 2, 3, 4}
= {x | x is an integer where x > 0 and x < 5}
= {x | x is a positive integer where x2 < 20}

BE III Sem-DM - CSE - 2020-21 - MJCET 86


Infinite Sets
Conceptually, sets may be infinite(i.e., not finite, without
end, unending).
Symbols for some special infinite sets:
N = {0, 1, 2,…} the set of Natural numbers.
Z = {…, –2, –1, 0, 1, 2,…} the set of Integers.
Z+ = {1, 2, 3,…} the set of positive integers.
Q = {p/q | p,q ∈ Z, and q ≠ 0} the set of Rational numbers.
R = the set of “Real” numbers.

BE III Sem-DM - CSE - 2020-21 - MJCET 87


Basic Set Relations: Member of
x∈S (“x is in S”) is the proposition that object x is an
element or member of set S. e.g. 3 ∈ N,
 a ∈ {x | x is a letter of the alphabet}
Can define set equality in terms of ∈ relation:
 ∀S,T: S = T ↔ [∀x (x∈S ↔ x∈T)]
“Two sets are equal iff they have all the same members.”
 x∉S ≡ ¬(x∈S) “x is not in S”

BE III Sem-DM - CSE - 2020-21 - MJCET 88


The Empty Set & Singleton
Empty (null) set: It is the unique set that contains no elements
whatsoever. It is denoted by {} or ∅ (“null”, “the empty set”)
 Ex: The set of positive integers that are greater than their squares is the
null set
∅ = { } = {x | False}
No matter the domain of discourse, we have the axiom
 ¬∃x: x∈∅.
A common mistake is to confuse Ø with {Ø}
{ } ≠ {∅} = { { } }
 {∅} it isn’t empty because it has ∅ as a member!
Singleton: A set with one element
BE III Sem-DM - CSE - 2020-21 - MJCET 89
Venn diagram
Rectangle: Universal set that contains all the objects
Circle: sets
 U: 26 letters of English alphabet
 V: a set of vowels in the English alphabet

BE III Sem-DM - CSE - 2020-21 - MJCET 90


Subset and Superset
Subset: The set A is a subset of B if and only if every element of A is
also an element of B
 Denote by A⊆B
 A⊆B ≡ ∀x (x∈A → x∈B)

 ∅⊆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)

BE III Sem-DM - CSE - 2020-21 - MJCET 91


Cardinality and Finiteness
Let S be a set. If there are exactly n distinct elements in
S where n is a non-negative integer
S is a finite set
|S|=n, n is the cardinality of S
Let A be the set of odd positive integers < 10, |A|=5
Let S be the set of letters in English alphabet, |S|=26
The null set has no elements, thus |∅|=0

BE III Sem-DM - CSE - 2020-21 - MJCET 92


Infinite set and Power set
A set is said to be infinite if it is not finite
 The set of positive integers is infinite
 N, Z, Q, R

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

BE III Sem-DM - CSE - 2020-21 - MJCET 93


Ordered n-tuples
Sets are unordered
The ordered n-tuple (a1, a2, …, an) is the ordered collection
that has a1 as its first element, a2 as its second element, and
an as its nth element
(a1, a2, …, an)= (b1, b2, …, bn) if and only if ai=bi for i=1, 2, .., n
2-tuples are called ordered pairs
(a, b) and (c, d) are equal if and only if a=c and b=d
Note that (a, b) and (b, a) are not equal unless a=b

BE III Sem-DM - CSE - 2020-21 - MJCET 94


Cartesian product of Sets
The Cartesian product of sets A and B, denoted by A x B, is
the set of all ordered pairs (a, b), where a ∊ A and b ∊ B
A × B = { (a, b) | a∈A ∧ b∈B }.
 Ex:1: A: students of MJ, B: all courses offered at MJ
 A x B consists of all ordered pairs of (a, b), i.e., all possible enrollments of
students at MJ
 Ex2:{a, b} × {1, 2} = { (a, 1), (a, 2), (b, 1), (b, 2) }

Note that for finite A, B, |A × B| = |A||B|.


Note that the Cartesian product is not commutative:
 i.e., ¬∀A,B (A × B = B × A).

BE III Sem-DM - CSE - 2020-21 - MJCET 95


Set Operations: Union
Union: For sets A and B, their union A∪B is the set containing
all elements that are either in A, or in B (or in both).
Formally, ∀A,B: A∪B = {x | x∈ A ∨ x∈ B}.
A={1,3,5}, B={1,2,3}, A⋃B={1,2,3,5}

BE III Sem-DM - CSE - 2020-21 - MJCET 96


Set Operations: Intersection
Intersection : For sets A and B, their intersection A∩B is the set
containing all elements that are simultaneously in A and in B.
Formally, ∀A,B: A∩B = {x | x∈ A ∧ x∈ B}.
A={1,3,5}, B={1,2,3}, A⋂B={1,3}

BE III Sem-DM - CSE - 2020-21 - MJCET 97


Disjoint set
Two sets A, B are called disjoint (i.e., unjoined) iff their
intersection is empty. (A ∩ B = ∅)
A={1,3}, B={2,4}, A and B are disjoint
Example: the set of even integers is disjoint with the set of odd
integers.

BE III Sem-DM - CSE - 2020-21 - MJCET 98


Inclusion-Exclusion Principle
How many elements are in A∪B?
|A∪B| = |A| + |B| - |A∩B|
Example: How many students in the class major in Computer
Science or Mathematics?
 Consider set E = C ∪ M,
 C = {s | s is a Computer Science major}
 M = {s | s is a Mathematics major}
 Some students are joint majors!
 |E| = |C ∪ M| = |C| + |M| - |C ∩ M|

BE III Sem-DM - CSE - 2020-21 - MJCET 99


Set Operations: Set Difference
For sets A and B, the difference of A and B, written A - B, is the
set of all elements that are in A but not in B.
Formally: A - B = {x | x∈ A ∧ x∉ B}
Also called: The complement of B with respect to A.
A={1,3,5},B={1,2,3}, A-B={5}

BE III Sem-DM - CSE - 2020-21 - MJCET 100


Set Operations: Set Complements
The universe of discourse (or the domain)can itself be
considered a set, call it U.
When the context clearly defines U, we say that for any set
A ⊆ U, the complement of A, written as A , is the complement
of A with respect to U, i.e., it is U - A.
A ={x | x∉ A}
E.g., If U = N, {3, 5} = {0,1, 2, 4, 6, 7,...}

BE III Sem-DM - CSE - 2020-21 - MJCET 101


Set Identities:

BE III Sem-DM - CSE - 2020-21 - MJCET 102


Proving Set Identities
To prove statements about sets, of the form
E1 = E2 (where the Es are set expressions), here are some useful
techniques:
1. Prove E1 ⊆ E2 and E2 ⊆ E1 separately.
2. Use set builder notation &logical equivalences.
3. Use a membership table.

BE III Sem-DM - CSE - 2020-21 - MJCET 103


Proving Set Identities: Using Mutual Subsets
Prove A  B  A  B
Will show that A  B  A  B and A  B  A  B
(→): Suppose thatx  A  B , by definition of
complement and using De Morgan’s law
( x  A  x  B )
 (( x  A))  (( x  B ))
 ( x  A)  ( x  B )
By definition of complement x  A or x  B
By definition of union x  A   B
104
Proving Set Identities: Using Mutual Subsets
(←): Suppose that x A B
By definition of union x  A  x  B
By definition of complement x  A  x  B
Thus ( x  A)  ( x  B )
By De Morgan’s law: ( x  A)  ( x  B )
 ( x  A  x  B )
 ( x  ( A  B ))
By definition of complement, x  A  B

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

BE III Sem-DM - CSE - 2020-21 - MJCET 109


Proving Set Identities: Using Membership Tables

110
Example
Show that A  ( B  C )  (C  B )  A

A  ( B  C )  A  B  C (De Morgan' s law)


 A  ( B  C ) (De Morgan' s law)
 ( B  C )  A (commutati ve law)
 (C  B)  A (commutati ve law)

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}

BE III Sem-DM - CSE - 2020-21 - MJCET 112


Generalized union

BE III Sem-DM - CSE - 2020-21 - MJCET 113


Generalized Union Example

BE III Sem-DM - CSE - 2020-21 - MJCET 114


Generalized Intersection

BE III Sem-DM - CSE - 2020-21 - MJCET 115


Generalized Intersection Example

BE III Sem-DM - CSE - 2020-21 - MJCET 116


Computer representation of sets
U={1,2,3,4,5,6,7,8,9,10}
A={1,3,5,7,9} (odd integer ≤10),B={1,2,3,4,5} (integer ≤5)
Represent A and B as 1010101010, and 1111100000
Complement of A: 0101010101
A⋂B: 1010101010˄1111100000=1010100000 which
corresponds to {1,3,5}

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.

The graph of f(n) = 2n + 1 The graph of f(x) = x2


from Z to Z from Z to Z 129
Floor & Ceiling Functions:
In discrete math, we frequently use the following two functions
over real numbers:
 The floor function ⎣ ・⎦ : R → Z, where ⎣x⎦ (“floor of x”) means the
largest integer ≤ x,
i.e., ⎣x⎦ = max( {i∈Z | i ≤ x} ).
 E.g. ⎣2.3⎦= 2, ⎣5⎦= 5, ⎣ -1.2⎦ = –2
 The ceiling function ⎡ ・⎤ : R → Z, where ⎡x⎤ (“ceiling of x”) means
the smallest integer ≥ x,
i.e., ⎡x⎤ = min( {i∈Z | i ≥ x} )
 E.g. ⎡2.3⎤ = 3, ⎡5⎤ = 5, ⎡–1.2⎤ = –1

130

You might also like