[go: up one dir, main page]

0% found this document useful (0 votes)
5 views38 pages

Discrete Intro

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

Discrete Intro

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

CSE 1107: Discrete Mathematics

M.M.A Hashem, PhD


Professor,
Department of Computer Science and Engineering
Khulna University of Engineering & Technology
(KUET)
Khulna 9203, Bangladesh
Email: hashem@cse.kuet.ac.bd

18 August 2025 CSE 1107: Discrete Mathematics 1


Introduction to Discrete Mathematics

A B

a = qb+r gcd(a,b) = gcd(b,r)

18 August 2025 CSE 1107: Discrete Mathematics 2


Abstraction

• Abstraction A mental model that


removes complex details
• This is a key concept. Abstraction will
reappear throughout the text – be sure
you understand it!

18 August 2025 CSE 1107: Discrete Mathematics 3


Internal View

18 August 2025 CSE 1107: Discrete Mathematics 4


Abstract View

18 August 2025 CSE 1107: Discrete Mathematics 5


18 August 2025 CSE 1107: Discrete Mathematics 6
Why Mathematics?

Design efficient computer systems.

• How did Google manage to build a fast search engine?

• What is the foundation of internet security?

algorithms, data structures, database,


parallel computing, distributed systems,
cryptography, computer networks…

Logic, number theory, counting, graph theory…

18 August 2025 CSE 1107: Discrete Mathematics 7


Topic 1: Logic and Proofs

How do computers think?

Logic: propositional logic, first order logic

Proof: induction, contradiction

Artificial intelligence, database, circuit, algorithms

18 August 2025 CSE 1107: Discrete Mathematics 8


Topic 2: Number Theory

• Number sequence
• (Extended) Euclidean algorithm
• Prime number, modular arithmetic, Chinese remainder theorem
• Cryptography, RSA protocol

Cryptography, coding theory, data structures

18 August 2025 CSE 1107: Discrete Mathematics 9


Topic 3: Counting

• Sets and Functions


• Combinations, Permutations, Binomial theorem
• Counting by mapping, pigeonhole principle
• Recursions

A B

Probability, algorithms, data structures

18 August 2025 CSE 1107: Discrete Mathematics 10


Topic 3: Counting

How many steps are needed to sort n numbers?

Algorithm 1 (Bubble Sort):


Every iteration moves the i-th smallest number to the i-th position

Algorithm 2 (Merge Sort):

Which algorithm runs faster?

18 August 2025 CSE 1107: Discrete Mathematics 11


Topic 4: Graph Theory

• Graphs, Relations
• Degree sequence, Eulerian graphs, isomorphism
• Trees
• Matching
• Coloring

Computer networks, circuit design, data structures


18 August 2025 CSE 1107: Discrete Mathematics 12
Topic 4: Graph Theory

How to color a map?

How to send data efficiently?

18 August 2025 CSE 1107: Discrete Mathematics 13


Objectives of This Course

•To learn basic mathematical concepts, e.g. sets, functions, graphs

•To be familiar with formal mathematical reasoning, e.g. logic, proofs

•To improve problem solving skills

•To see the connections between discrete mathematics and computer science

18 August 2025 CSE 1107: Discrete Mathematics 14


Pythagorean theorem

b c

a
a +b =c
2 2 2

Familiar?
Obvious?

18 August 2025 CSE 1107: Discrete Mathematics 15


Good Proof

b c
b-a
a b-a
We will show that these five pieces can be rearranged into:

(i) a cc square, and then


(ii) an aa & a bb square

And then we can CSE


18 August 2025
conclude that
1107: Discrete Mathematics 16
Good Proof

The five pieces can be rearranged into:

(i) a cc square

c c

a b
c

18 August 2025 CSE 1107: Discrete Mathematics 17


Good Proof

How to rearrange them into an axa square and a bxb square?

b c
b-a
a b-a

18 August 2025 CSE 1107: Discrete Mathematics 18


Good Proof

a
b
a
b-a a

74 proofs in http://www.cut-the-knot.org/pythagoras/index.shtml
18 August 2025 CSE 1107: Discrete Mathematics 19
Bad Proof
A similar rearrangement technique shows that 65=64…

What’s wrong with the proof?

18 August 2025 CSE 1107: Discrete Mathematics 20


Mathematical Proof

To prove mathematical theorems, we need a more rigorous system.

The standard procedure for proving mathematical theorems is invented by


Euclid in 300BC. First he started with five axioms (the truth of these
statements are taken for granted). Then he uses logic to deduce the truth
of other statements.

1.It is possible to draw a straight line from any point to any other point.
2.It is possible to produce a finite straight line continuously in a straight line.
3.It is possible to describe a circle with any center and any radius.
4.It is true that all right angles are equal to one another.
5.("Parallel postulate") It is true that, if a straight line falling on two straight lines make the interior angles on the same side less than two right angles,
the two straight lines, if produced indefinitely, intersect on that side on which are the angles less than the two right angles.

Euclid’s proof of Pythagorean’s theorem http://en.wikipedia.org/wiki/Pythagorean_theorem

18 August 2025 CSE 1107: Discrete Mathematics 21


Statement (Proposition)

A Statement is a sentence that is either True or False

Examples: 2+2=4 True

3x3=8 False

787009911 is a prime

Non-examples: x+y>0

x2+y2=z2

They are true for some values of x and y


but are false for some other values of x and y.
18 August 2025 CSE 1107: Discrete Mathematics 22
Logic Operators

 ::= NOT ~p is true if p is false

 ::= AND  ::= OR


P Q P Q P Q P Q
T T T T T T
T F F T F T
F T F F T T
F F F F F F
18 August 2025 CSE 1107: Discrete Mathematics 23
Compound Statement

p = “it is hot” q = “it is sunny”

It is hot and sunny

It is not hot but sunny

It is neither hot nor sunny

18 August 2025 CSE 1107: Discrete Mathematics 24


Exclusive-Or

coffee “or” tea exclusive-or

How to construct a compound statement for exclusive-or?

Idea 1: Look at the true rows


p q p q
T T F Want the formula to be true
exactly when the input belongs
T F T
to a “true” row.
F T T
F F F
The input is the second row exactly if this sub-formula is satisfied

And18the formula
August 2025 is true exactly
CSEwhen the input
1107: Discrete is the second row or the third25row.
Mathematics
Exclusive-Or

coffee “or” tea exclusive-or

How to construct a compound statement for exclusive-or?

Idea 2: Look at the false rows


p q p q
T T F Want the formula to be true
exactly when the input does
T F T
not belong to a “false” row.
F T T
F F F
The input is the first row exactly if this sub-formula is satisfied

And18the formula
August 2025 is true exactly
CSEwhen the input
1107: Discrete is not in the 1st row and the 4th
Mathematics 26row.
Logical Equivalence

Idea 3: Guess and check

p q
T T F T F F
T F T T T T
F T T T T T
F F F F T F

Logical equivalence: Two statements have the same truth table

As you see, there are many different ways to write the same logical formula.
One can always use a truth table
18 August 2025
to check whether two statements are equivalent.
CSE 1107: Discrete Mathematics 27
Writing Logical Formula for a Truth Table

Digital logic:

Given a digital circuit, we can construct the truth table.

Now, suppose we are given only the truth table (i.e. the specification),
how can we construct a circuit (i.e. formula) that has the same function?

18 August 2025 CSE 1107: Discrete Mathematics 28


Writing Logical Formula for a Truth Table

Use idea 1 or idea 2. Idea 1: Look at the true rows


and take the “or”.

p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F

The2025
18 August formula is true exactly when
CSE 1107: theMathematics
Discrete input is one of the true rows. 29
Writing Logical Formula for a Truth Table

Idea 2: Look at the false rows,


negate and take the “and”.

p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F

18 The
Augustformula
2025 is true exactly when
CSE 1107: the input
Discrete is not one of the false row.
Mathematics 30
DeMorgan’s Laws

Logical equivalence: Two statements have the same truth table

De Morgan’s Law

Statement: Tom is in the football team and the basketball team.


Negation: Tom is not in the football team or not in the basketball team.

De Morgan’s Law

Statement: The number 783477841 is divisible by 7 or 11.


Negation: The number 783477841 is not divisible by 7 and not divisible by 11.

18 August 2025 CSE 1107: Discrete Mathematics 31


DeMorgan’s Laws

Logical equivalence: Two statements have the same truth table

De Morgan’s Law

T T F F
T F T T
F T T T
F F T T

De Morgan’s Law
18 August 2025 CSE 1107: Discrete Mathematics 32
Simplifying Statement

DeMorgan

Distributive

See textbook for more identities.


18 August 2025 CSE 1107: Discrete Mathematics 33
Tautology, Contradiction
A tautology is a statement that is always true.

A contradiction is a statement that is always false. (negation of a tautology)

In general it is “difficult” to tell whether a statement is a contradiction.


It is one of the most important problems in CS – the satisfiability problem.
18 August 2025 CSE 1107: Discrete Mathematics 34
Quick Summary

Key points to know.

1. Write a logical formula from a truth table.

2. Check logical equivalence of two logical formulas.

3. DeMorgan’s rule and other simple logical rules (e.g. distributive).

4. Use simple logical rules to simplify a logical formula.

18 August 2025 CSE 1107: Discrete Mathematics 35


Course Project

Pick an interesting mathematical topic,

write a report of about 10 pages.

3 students in a group

Can use any references, but cite them.

Choose 1-3 groups to present, up to 5% bonus

18 August 2025 CSE 1107: Discrete Mathematics 36


A Project

Tell an interesting story related to mathematics.

More about good topic and nice presentation, than mathematical difficulty.

▪ Interesting or curious problems, interesting history

▪ Surprising or elegant solutions

▪ Nice presentation, easy to understand

18 August 2025 CSE 1107: Discrete Mathematics 37


Project Ideas

▪ Magic tricks

▪ More games, more paper folding, etc

▪ Logic paradoxes

▪ Prime numbers

▪ Game theory

Please, Study Text and Reference Materials for


Enhancing your Understanding and Knowledge
18 August 2025 CSE 1107: Discrete Mathematics 38

You might also like