0% found this document useful (0 votes)
24 views81 pages

CH 01

Uploaded by

sorsu2548
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)
24 views81 pages

CH 01

Uploaded by

sorsu2548
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/ 81

CSC165

Discrete Mathematics

CS@SIT, KMUTT
2024

1
Image credit: https://i.ytimg.com/vi/cz4nPSA9rlc/maxresdefault.jpg
Discrete math is …

2
https://bard.google.com/
Discrete vs. Continuous

3
Credit: https://www.quora.com/The-probability-distribution-of-discrete-and-continuous-random-variable-
can-be-defined-in-terms-of-what
Type of variables

4
https://www.bitcoininsider.org/article/23740/continuous-vs-discrete-variables-context-machine-learning
Section 1.1

Puzzles, Patterns, and


Mathematical Thinking
5
A matter of life and death
In the Jewish revolt against Rome, Josephus and
39 of his comrades were holding out against the Romans
in a cave. With defeat imminent, they resolved that, like
the rebels at Masada, they would rather die than be
slaves to the Romans. They decided to arrange
themselves in a circle. One man was designated as
number one, and they proceeded clockwise killing every
seventh man.
Josephus (according to the story) was among
other things a mathematician; so he instantly figured out
where he ought to sit in order to be the last to go. But
when the time came, instead of killing himself he joined
the Roman side. 6
https://www.geogebra.org/m/ExvvrBbR
Example 1

If there are 10 people


numbered 1 to 10 in a
circle, and every other
person is killed starting
Person 1
with number 2, which
person is left?

7
If there are 10 people
numbered 1 to 10 in a
circle, and every other
person is killed starting
with number 2, which
person is left?

8
If there are 10 people
numbered 1 to 10 in a
circle, and every other
person is killed starting
with number 2, which
person is left?

Final one.

9
Example 2
5

3 4

1 2
10
A Simple Envelope
Discussion Questions

Draw the puzzle without lifting your


pencil/pen and without retracing any lines.

Is there more than one way to do it?

Is it possible to do it starting at the topmost


point?

11
Hint: Euler Trail; it begins and ends with the two nodes of odd degree.
Example 3

Use a tree structure to list all possible


results of the process of tossing three
coins, e.g., red, green and blue coins.
What percentage of these consist of more
heads than tails? Are you surprised?

12
Ans: 50%
Example 4

Suppose a tennis match is a “best of five”.


Draw the complete game tree. If each of the
outcomes is equally likely, what percentage
of the time would you expect the match to
last five sets?
Note: “best of five” means the
need to win 3 games in total, e.g.,
3-0, 3-1, or 3-2 sets.

13
S1.1P4
Answer: 12/20 or 60%; note that the winner must win the last game.
Section 1.2

Number Puzzles and Sequences

14
Guess the next number in the
sequence
1. 1, 3, 5, 7, 9, 11, _____

2. 1, 9, 17, 25, 33, 41, _____

3. 1, 4, 9, 16, 25, 36, _____

4. 2, 4, 8, 16, 32, 64, _____

5. 1, 2, 6, 24, 120, 720, _____

15
Two well-known sequences and series

 Arithmetic sequence & series


The general formula for the nth term of an arithmetic
sequence is an = a1 + (n - 1)d, where a1 is the first term, d
is the common difference, and n is the index of the term.

The general formula for the sum of the first n terms of an


arithmetic series is Sn = (n/2)(a1 + an), where a1 is the first
term, an is the nth term, and n is the number of terms.

For example, the sequence 1, 4, 7, 10, 13 is an arithmetic


sequence with a common difference of 3.

16
https://bard.google.com/
Two well-known sequences and series

 Geometric sequence & series


The general formula for the nth term of a geometric
sequence is an = a1 * r^(n-1), where a1 is the first term, r
is the common ratio, and n is the index of the term.

Geometric
series

17
https://en.wikipedia.org/wiki/Geometric_series
Notation and Terminology

 Recursive formula
Each term is described in relation to a previous term (or
terms) of the sequence. Must have info how the list
begins for the recursive relationship.
 Closed formula
Each term is described only in relation to its position in
the list.
 Sequence notation
Use lowercase letter (a, b, c, etc.) to name sequences,
and use subscripting to indicate position. an indicates
the nth term of the sequence of a. It is read as “a sub n”.
18
Example 1
1, 3, 5, 7, 9, ….
 A recursive formula for the sequence

 A closed formula for the sequence

 A description of the set of numbers

19
Practice Problem 1
Consider the sequence 4, 6, 8, 10, 12, …
1. Describe the sequence in each of the three
ways we just listed (recursive, closed, a known
set)

2. If you know a certain term of this sequence is


898, what would the next three terms be?

3. What is the 1000th term of the sequence?

20
Example
an = 3 n + n
 Compute the first five terms

 Compute the 10th term

 Determine a formula for ak-1

 Determine a formula for a2m-3


21
Example

b1 = 3, and bn = bn-1 + 2 for n  2


 Compute the first five terms

 Guess a closed formula from the first five


terms

 Use both closed and recursive formulas to


find b10
22
More Examples
Find closed and recursive formulas for the
following sequences:

• 2, 5, 10, 17, 26, …

• 1, 3, 9, 27, 81, …

• 3, 7, 11, 15, 19, 23, …

23
Practice Problem 2
Give the next term in the sequence and
several descriptions for each of the
following:
 5, 10, 15, 20, 25, ___, …

 5, 10, 20, 40, 80, ___, …

 4, 9, 16, 25, 36, ___, …

24
Fibonacci numbers
The Fibonacci numbers are a famous sequence
for which a recursive formula is easy to find and
an explicit formula is much more difficult. The
Fibonacci numbers are:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …

Find a recursive formula for this sequence.

 
n
 
n
1  1 5   1 5  
Closed form: Fn    2    2   25
5     

Sums and sigma notation

Examples
1. Write 2 + 4 + 6 + 8 + 10 + 12 using
sigma notation.

5
2. Evaluate the sum
2
k 0
k

n
Geometric series:  ar
i 0
i

a (1 r n1 )
1 r 26
Example
Find a recursive formula for the sequence
whose closed formula is
an = 2n – 3

27
Example
Find a closed formula for the sequence
whose recursive formula is
s1 = 1, and sn = sn-1 + n for n  2

28
Practice Problem 3
Verify that the sequence given by the closed
formula
an = n2 + n
satisfies the recurrence relation
an = an-1 + 2n for all n  2

29
Exercise

Determine the next number in the sequence


1. 1, 3, 7, 15, 31, 63, ___
2. 2, 5, 10, 50, 500, ___

30
Section 1.3

The basics of propositional logic

31
Liars and Truthtellers

Raymond Smullyan has written a number of


wonderful books filled with challenging logic
puzzles. A recurring theme in these books is an
Island where each inhabitant is either a Liar or a
Truthteller. Here is an example:
 You come across two inhabitants of the
island, let’s call them A and B. A says, “We
are both telling the truth,” and B says, “A is
lying.” Can you tell who is a liar and who is a
truthteller?
32
Liars and Truthtellers

To solve the puzzle, we consider in table form


the four possibilities for the types of people A
and B are:

Scenario #1 A is a TruthTeller B is a TruthTeller

Scenario #2 A is a TruthTeller B is a Liar

Scenario #3 A is a Liar B is a TruthTeller

Scenario #4 A is a Liar B is a Liar

33
Liars and Truthtellers
In each of these situations, we consider the two statements that
were made. To keep from getting dizzy, we will initially make our
assessment purely with regard to the actual statements and with
no regard to who makes the statements.

Both A and B
A is a Liar
are TruthTellers

Scenario A is a B is a
#1 TruthTeller TruthTeller

Scenario A is a
B is a Liar
#2 TruthTeller
Scenario B is a
A is a Liar
#3 TruthTeller
Scenario
A is a Liar B is a Liar
#4
34
Truth Table
Liars and Truthtellers
In each of these situations, we consider the two statements that
were made. To keep from getting dizzy, we will initially make our
assessment purely with regard to the actual statements and with
no regard to who makes the statements.

Both A and B
A is a Liar
are TruthTellers

Scenario A is a B is a Truth
T F
#1 TruthTeller Teller

Scenario A is a
B is a Liar F F
#2 TruthTeller
Scenario B is a Truth
A is a Liar F T
#3 Teller
Scenario
A is a Liar B is a Liar F T
#4
35
Truth Table
Proposition

Proposition is ….
a sentence that is unambiguously true or false,
and not both.

E.g.,
 Today is Friday.
 Bangkok is in Thailand.

36
Propositional logic

Propositional logic is essentially a shorthand for


the expression of sentences along with some
rules that govern when compound expressions
are true or false.
 In the previous example, we might use the
propositional variable p for the statement, “A
is a truthteller,” and the propositional variable q
for the statement, “B is a truthteller.”

37
Propositional logic

Propositional logic is essentially a shorthand for


the expression of sentences along with some
rules that govern when compound expressions
are true or false.
 The logical connectives , , and  stand for
the English words “and,” “or,” and “not,”
respectively. So the statement “A and B are
both Truthtellers” can be expressed p  q, and
the statement, “A is lying” can be expressed as
 p.
38
Truth tables for formal propositions
Using these shorthand conventions, we can write the
table that allowed us to solve the previous problem in
the following concise form:
p q pq p

T T T F

T F F F

F T F T

F F F T

39
Propositional logic
Practice Problem. Write each of the following
statements in propositional logic using the
propositional variable c for “Sue is a CS/IT major”
and the variable j for “Sue is a junior.”
1. Sue is a junior CS/IT major.

2. Sue is a CS/IT major, but she is not a junior.

3. Sue is a junior or a CS/IT major but not both.

Exclusive or; (c  j )  (c  j )  (c  j )  (c  j )

Or using a shorthand, c  j 40
Truth tables for compound statements
The key to making a truth table is to analyze the truth of
statements from simple to complex in each of the possible
scenarios for the values of the propositional variables.
Example. Give the truth table for the statement,
“ (p  q)”
p q pq  (p  q)

T T

T F

F T

F F
41
Truth tables for compound statements

Practice. Give the truth table for the statement,


“( p)  ( q)”

p q p q ( p)  ( q)

T T

T F

F T

F F

42
Negations of formal propositions

When a propositional statement is false, its


negation is a true propositional statement. For
example, if the statement “Sue is a junior CS/IT
major” is false, then the statement “Sue is not a
junior or Sue is not a CS/IT major” is true.
An advantage of formal logic is that we can
present formal rules for negating compound
statements like this.

43
Negations of formal propositions

The truth table examples we saw earlier


give us one such rule for negation. The
truth tables for the statements (p  q)
and ( p)  ( q) were identical.

44
Logical equivalence

When two statements have exactly the


same truth table, we say that the two
statements are logically equivalent.
The pair (p  q) and ( p)  ( q) of
logically equivalent statements is one of
DeMorgan’s Laws, and it gives us a
handy way to rewrite potentially clumsy
negated statements.

45
Exercise

You come across three inhabitants of


Smullyan’s Island. A says, “B or C is
lying,” B says, “C is lying,” and C says, “A
and I are both telling the truth.” Who if
anyone is telling the truth?

S1.3P1b
46
Answer: A is, also either B or C, but not both.
Section 1.4

Predicate logic

47
Predicates

A predicate P(x) over a domain D is a


statement which includes the variable x so
that whenever x is replaced by an element
of D, the result is unambiguously true or
false, and becoming a proposition.

48
Exercise

Write each of the following predicates using


the simple predicates x > 0 and y > 0
along with the propositional connectives ʌ,
˅, and ¬:
1. At least one of x and y is positive.
2. Exactly one of x and y is positive.
3. Neither x nor y is positive.

49
Examples

S(x) ... “x2 > 2”


D … The set of all real numbers

C(x) ... “x is a CS/IT major”


D … The set of all KMUTT students

P(x) ... “x is evenly divisible by 3”


D … The set of all integers
50
Practice
Let D = {2, 3, 4, 5, 6, 7, 8}
For each of the following predicates, list
those elements of D that make the
statement true:
1. P(x) is “x2 + 3 is evenly divisible by 5”

2. Q(t) is “t > 1 and 2t ≤ 10”

3. R(z) is “z is even or prime”

51
Practice
Let D = {4, 5, 6, 7, 8, 9, 10, 11}
Which of the following predicates are true for
all elements of D? Which are false for all
elements of D?

1. P(x) is “x is prime or x is a perfect square”

2. Q(t) is “2t > 5 and t2 < 200”

3. R(z) is “z is prime and z + 1 is a perfect square”

52
Quantifiers
Let D = {4, 5, 6, 7, 8, 9, 10, 11}
Which of the following statements
are true?

 For all x in D, x is prime or x is a perfect


square
x  D, Pm( x)  Pe( x)
 There exists a t in D such that 2t > 5 and
t2 < 200.
t  D, Q1 (t )  Q2 (t )
 There exists z in D, z is prime and z + 1 is
a perfect square.
z  D, P( z )  S ( z  1)
53
Negating quantifiers
The following two statements are equivalent:

x  D, P( x)  x  D, P( x)

We express this in English by saying that the negation of “all x


do satisfy P(x)” is “some x does not satisfy P(x)”

Or more briefly, the opposite of “all do” is “some don’t.”

54
Negating quantifiers
The following two statements are equivalent:

x  D, P( x)  x  D, P( x)

We express this in English by saying that the negation of “some


value of x satisfies P(x)” is “no values of x satisfy P(x)”

Or more briefly, the opposite of “some do” is “all don’t.”

55
Practice
Write the following using predicate logic notation:

1. For every integer n, 2n ≠ 5.

2. There exists a triangle T that has area 6 and perimeter 12.

3. Every circle has diameter 3 or area 3.

4. There is no natural number n for which n is prime and n + 1 is a


perfect square.

n  N , ( P(n)  S (n  1))

n  N , P(n)  S ( n  1) 56
Practice
Write the negation of each of the following using predicate logic
notation and then using an English sentence. Which is true, the
original statement or the negated statement?

1. For every integer n, 2n ≠ 5.

2. There exists a triangle T that has area 6 and perimeter 12.

3. Every circle has diameter 3 or area 3.

4. There is no natural number n for which n is prime and n + 1 is a


perfect square.
n  N , P(n)  S (n  1) 57
Negation of more than one quantifier

Apply the negation (¬) to each quantifier


from left to right order.
E.g.,
x  Z , y  Z , x  2 y  3

Its negation is

x  Z , y  Z , x  2 y  3

58
Negation of more than one quantifier

More example:

x  Z , y  Z , x  y  13, and xy  36

Its negation is

x  Z , y  Z , ( x  y  13)  ( xy  36)

59
Exercise

Let Z indicate the set of all integers. Which


of the following statements are true?

1. x  Z , y  Z , x  2 y  3

2. x  Z , y  Z , x  y  15

3. y  Z , x  Z , x  y  15

60
Answer: 1. False; 2. True, and 3. False.
Section 1.5

Implications

61
Mathematical statements
Which of the following mathematical statements seem to
state “universal truths” about the positive integers?
1. If n ends in the digit “2”, then n is divisible by 2.
2. If n ends in the digit “3”, then n is divisible by 3.
3. If n is odd, then n2 – 1 is evenly divisible by 8.
4. If n is evenly divisible by 3, then n2 + n is evenly
divisible by 4.
5. If n or m is odd, then n + m is odd.
6. If n or m is even, then n × m is even.

62
Truth of implicational statements
Using the false statements below as models, complete the
sentence that follows in your own words.
 If n is evenly divisible by 3, then n2 + n is evenly
divisible by 4.
 If n ends in the digit “3”, then n is divisible by 3.
 If n or m is odd, then n + m is odd.
To show that a predicate of the form P(x)  Q(x) is false
on the domain D, we must …

Note: Negation of p  q is (p ʌ ¬q) 63


Truth of implicational statements
Using the true statements below as models, complete the
sentence that follows in your own words.
 If n is odd, then n2 – 1 is evenly divisible by 8.
 If n or m is even, then n × m is even.
 If n ends in the digit “2”, then n is divisible by 2.

A predicate of the form P(x)  Q(x) is true for all elements


of the domain D if …

Note: Negation of p  q is (p ʌ ¬q) 64


The Law: If you are drinking beer,
then you are at least 21 years old.
Each of four customers gets a coaster:
One side has his/her age, and the other has what
he/she is drinking.

Alan Betty Cindy Dan


19 Coke Beer 25
Which coasters must be flipped over to verify that
everyone is obeying the law?

65
Truth tables for if,then statements

Example. Here is the truth table for the


statement, “p  q”
p q pq

T T T

T F F

F T T

F F T

Note: The only time that p  q is false is when p is


true and q is false.
66
Practice: Which value of n do we need to
check?
1. If n is a positive integer then n 3  n is a multiple
of 4.

2. For all integers n, if 3n=9 then n squared is 9.

67
Truth tables for contrapositive

Practice. Complete the truth table for the


compound statement, “(¬q)  (¬p)”
p q p q ¬q ¬p (¬q)  (¬p)

T T T F F

T F F T F

F T T F T

F F T T T

68
Truth tables for biconditional
Practice. Give the truth table for the compound
statement, p ↔ q ≡ (p  q) ʌ (q p)

p q pq qp (p  q) ʌ (q p)

T T

T F

F T

F F

Any relationship to p  q?
69
Implication in English
The English construction “If property 1 holds, then property 2 holds”
states a relationship between properties 1 and 2. In the
investigation of this type of relationship, there is some standard
terminology you should know:

 The statements p  q and q  p are called converses of each


other. It is possible but not unusual for only one statement in
such a pair to be true.

 The statements p  q and (¬q)  (¬p) are called


contrapositives of each other. These statements are always
logically equivalent.

 The statements p  q and (¬p)  (¬q) are called inverses of


each other. It is possible but not unusual for only one statement
in such a pair to be true.

70
Examples

Form the converse, inverse, and


contrapositive of each of the following
statements:
1. If n ends in a “2”, then n is divisible by 2.
2. If n ends in a “3”, then n is divisible by 3.
3. If n ends in an even digit, then n is even.

71
Examples

If n ends in a “2”, then n is divisible by 2.


Converse: If n is divisible by 2, then n
ends in a “2”.
Inverse: If n does not end in a “2”, then n
is not divisible by 2.
Contrapositive: If n is not divisible by 2,
then n does not end in a “2”.

72
Examples

If n ends in an even digit, then n is even.


Converse: If n is even, then n ends in an
even digit.
Inverse: If n does not end in an even digit,
then n is not even.
Contrapositive: If n is not even, then n
does not end in an even digit.

73
Implication in predicate logic
The majority of mathematical
statements can be written
in the form
x  D, P( x)  Q( x) 

The negation of this


statement is the formal
statement
x  D, P( x)  Q( x) 

74
Examples in English

If a student at Shippensburg majors in


math, then that student takes Discrete
Math.

1. Write this using formal predicate logic.

2. What is the negation of this sentence?

75
Contrapositive, Converse, and Inverse

Given x  D, P( x)  Q( x) 
Its converse is
x  D, Q( x)  P ( x) 
Its inverse is
x  D, P( x)  Q( x) 

Its contrapositive is
x  D, Q( x)  P( x) 

Note: p  q is logically equivalent to (¬q  ¬p) 76


Section 1.6

Validity of Arguments

77
Ways to say about implications

“If p is true, then q is true” can be expressed in


different ways as follows:
 p is true only if q is true
 For q to be true, it is sufficient that p is true
 For p to be true, it is necessary that q is true
Think about this example:
“If I live in BKK, then I live in Thailand”
It is equivalent to:
- “It is necessary to live in Thailand for me to live in BKK”
- “It is sufficient to live in BKK for me to be living in Thailand”
78
Valid Form of Reasoning

 Modus Ponens
p  q,
p,
q

Modus Tollens
p  q,
q ,
 p
79
Invalid Form of Reasoning

 Converse fallacy
p  q,
q,
p

 Inverse fallacy
p  q,
p ,
 q
80
Exercise

For each of the following, identify the


reasoning as valid or invalid.
 If n is even, then n2 is even. I know n2 is even.
Therefore, n is even.
 If you eat your supper, we will play miniature golf. You
didn’t eat your supper. Therefore, we will not play
miniature golf.
 If I don’t get an A on the final exam, I won’t get an A for
the course. I got an A for the course. Therefore, I got an
A on the final.
81

You might also like