CS101 Chapter 1 - Week 1_MG
CS101 Chapter 1 - Week 1_MG
Week 1 - Chapter 1
Slides are adopted from “Discrete Mathematics and It's Applications” Kenneth H. Rosen; 7th edition, 2012.
WEEK 1 1
How to do well in this course?
BEFORE every lecture
o Read the relevant portion of the textbook
DURING every lecture
o Ask questions if anything is not clear
AFTER every lecture
o Review the lecture slides.
o Solve all exercises assigned after each section
❑ Counting
❑ Relations
❑ Graph theory
❑ Trees
WEEK 1 3
What is Discrete Mathematics?
• Discrete mathematics is mathematics that deal
with discrete objects.
2. Cryptography
Discrete mathematics, particularly number theory and combinatorics, is crucial for
modern cryptography. Techniques like RSA encryption are based on the difficulty of
factoring large numbers and solving problems in finite fields.
Security: Cryptography uses properties of prime numbers, modular arithmetic, and
complexity theory from discrete mathematics to secure communications.
WEEK 1 5
Why is Discrete Mathematics so crucial?
5. Coding Theory
Error detection and correction in communication systems depend on discrete
mathematics, particularly through coding theory. This is essential for data transmission
and storage, from CDs and DVDs to digital communication networks.
6. Algorithmic Thinking
Discrete mathematics trains individuals in algorithmic thinking, which is crucial for solving
problems in computer science, engineering, and operations research. Propositional logic
problems in discrete mathematics lead directly to algorithms used in real-world
applications.
WEEK 1 6
Chapter 1
WEEK 1 7
1.1 Propositional Logic
1- A proposition:
Is a declarative sentence (that is, a sentence that declares a fact) that is either true or false,
but not both or somewhere “in between!” . Commands and questions are not propositions.
❑ EXAMPLE 1: All the following declarative sentences are propositions.
1. Washington, D.C., is the capital of the USA.
2 . Cairo is the capital of Egypt.
3.1+1=2.
4.2+2=3.
➢ Propositions 1 and 3 are true, whereas 2 and 4 are false
WEEK 1 8
1.1 Propositional Logic
2-Propositional variables (or statement variables):
are letters used to represent propositions, not used to denote numerical variables.
➢The conventional letters used for propositional variables are p, q , r, s, . . . .
➢The truth value of a proposition is denoted by:
•T if it is a true proposition
•F if it is a false proposition
4- Negation operator:
Let p be a proposition. The negation of p, denoted by p, is the statement "It is not the
case that p."
•The proposition p is read "not p."
•The truth value of the negation of p, p, is the opposite of the truth value of p.
WEEK 1 9
1.1 Propositional Logic
❑ EXAMPLE 3:
Find the negation of the proposition
"Today is Friday.“ and express this in simple English.
Solution: The negation is "It is not the case that today is Friday."
This negation can be more simply expressed by
•"Today is not Friday,“ Or,
•"It is not Friday today.”
WEEK 1 10
1.1 Propositional Logic
5-Compound:
Propositions, are formed from existing propositions using logical operators.
6-Conjunction Operator
WEEK 1 11
1.1 Propositional Logic
❑ Truth Table for p q
❑ Example 5:
Find the conjunction of the propositions p and q where:
– p is the proposition "Today is Friday “
– q is the proposition "It is raining today“
WEEK 1 13
1.1 Propositional Logic
❑ Example:
Find the disjunction of the propositions p and q where:
• p is the proposition "Today is Friday “
• q is the proposition "It is raining today“
Solution:
The disjunction p v q is the proposition:
"Today is Friday or it is raining today.“
WEEK 1 14
1.1 Propositional Logic
A) Inclusive Or (normal or)
– A disjunction is True when at least one of the two propositions is true.
❑ Example:
"Students who have taken calculus or computer science can take this class“
• That is, students that can take the class are:
– Who have taken both calculus and computer science,
– Who have taken calculus
– Who have taken computer science
WEEK 1 15
1.1 Propositional Logic
B) Exclusive Or
Let p and q be propositions.
The exclusive OR of p and q, denoted by p q (p XOR q),is the proposition that is:
• False otherwise.
WEEK 1 16
1.1 Propositional Logic
❑ Example:
1-"Students who have taken calculus or computer science, but not both,
can enroll in this class"
• That is, students who can take the class are: Who have taken calculus, Who have
taken computer science but not those who have taken both calculus and a
computer science course are allowed to take the class.
WEEK 1 17
1.1 Propositional Logic
8-Conditional Statements:
Let p and q be propositions. The conditional statement p → q is the
proposition "if p, then q" .The conditional statement p → q is:
WEEK 1 18
1.1 Propositional Logic
❑ The truth table for the conditional statement p → q is shown in Table.
➢ Note that:
The statement (p → q) is true when:
-both p and q are true, and when:
-p is false (no matter what truth value q has).
WEEK 1 19
1.1 Propositional Logic
ways to express this conditional statement:
• "if p, then q"
• "if p, q "
• "p is sufficient for q"
• "q if p"
• "q when p"
• "a necessary condition for p is q"
• "q unless → p"
• "p implies q"
• "p only if q"
• "a sufficient condition for q is p"
• "q whenever p"
• "q is necessary for p"
• "q follows from p" WEEK 1 20
1.1 Propositional Logic
❑ Example:
Let p be the statement “Ahmad learns discrete mathematics" and q the
statement “Ahmad will find a good job“.
Express the statement p → q in English
• Solution:
The statement p → q can be expressed in English by several ways:
–If Ahmad learns discrete mathematics, then he will find a good job
–Ahmad will find a good job when he learns discrete mathematics
–For Ahmad to get a good job, it is sufficient for him to learn discrete
mathematics
–Ahmad will find a good job unless he does not learn discrete
mathematics
WEEK 1 21
1.1 Propositional Logic
9-Converse, Contrapositive, and Inverse
There are three related conditional statements to statement p → q:
• The converse of p → q is q → p
• The contrapositive of p → q is ¬ q → ¬ p
• The inverse of p → q is ¬ p → ¬ q
➢ Note that
•Conditional statement and its contrapositive are equivalent.
•The converse and the inverse of a conditional statement are also equivalent
WEEK 1 22
1.1 Propositional Logic
❑ Example 9:
What are the contrapositive, the converse, and the inverse of the conditional
statement
"The home team wins whenever it is raining."?
Solution:
Because "q whenever p" is one of the ways to express the conditional
statement p → q , the original statement can be rewritten as
WEEK 1 23
1.1 Propositional Logic
Consequently,
• The contrapositive of this conditional statement is
"If the home team does not win, then it is not raining."
•The converse is
"If the home team wins, then it is raining.“
• The inverse is
"If it is not raining, then the home team does not win.“
➢ Note that:
Only the contrapositive is equivalent to the original statement.
WEEK 1 24
1.1 Propositional Logic
10-Biconditional
WEEK 1 25
1.1 Propositional Logic
❑ Example 10:
Let p be the statement "You can take the flight" and let q be the
statement "You buy a ticket.“
This statement is true if p and q are either both true or both false,
That is:
• if you buy a ticket and can take the flight or
•if you do not buy a ticket and you cannot take the flight.
•It is false when p and q have opposite truth values.
WEEK 1 26
1.1 Propositional Logic
• There are some other common ways to express p q:
– "p is necessary and sufficient for q"
– "if p then q, and conversely"
– "p iff q.“
➢ Note that:
WEEK 1 27
1.1 Propositional Logic
❑ Example 11:
Construct the truth table of the compound proposition
(p v ¬ q) → (p q).
WEEK 1 28
1.1 Propositional Logic
11-Logic and Bit Operations
Computers represent information using bits (binary digits)
A bit is a symbol with two possible values: 0 and 1
WEEK 1 29
1.1 Propositional Logic
Bit Operations correspond to Logical Connectives
After replacing true by 1 and false by 0 in the truth tables, we can use
the bit operators OR, AND, and XOR as follow:
WEEK 1 30
1.1 Propositional Logic
12-Bit string
A bit string is a sequence of zero or more bits. The length of this string is
the number of bits in the string.
101010011 is a bit string of length nine.
WEEK 1 31
13-Bit Operations
01011010
10110100
11101110
WEEK 1 32
❑ Example :
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
0 1 1 0 1 1 0 1 1 0 and 1 1 000 1 1 1 0 1 .
(Note that: bit strings will be split into blocks of four bits to make them easier to
read.)
Solution:
The bitwise OR, bitwise AND, and bitwise XOR of these strings are obtained by
taking the OR, AND, and XOR of the corresponding bits, respectively.
01 1011 0110
11 0001 1101
1 1 1 0 1 1 1 1 1 1 bitwise OR
0 1 0 0 0 1 0 1 0 0 bitwise AND
1 0 1 0 1 0 1 0 1 1 bitwise XOR
WEEK 1 33