Lecture No. 1
Lecture No. 1
Mathematics
CC1041
ADEEL ASHRAF
CMP-101 DISCRETE MATHEMATICS TEXT
BOOK
GRADING
SCHEME Total 100 marks
Set of Real
Numbers:
• • • •
• •
-1 0 1 2
-3 -2
LOGI
C
A proposition (aka statement) is a declarative sentence that is either true or false but
not both.
EXAMPLES:
1. 1+1=2
2. 2+2=3
3. Islamabad is the capital of Pakistan.
4. It is Friday today.
TRUTH
VALUE
• If a proposition is true, we say that it has a truth value of "true”.
• If a proposition is false, its truth value is "false".
• The truth values “true” and “false” are, respectively, denoted by the letters T
and F.
EXAMPLE
S Example Proposition Truth value
Grass is green.
n is a prime number.
He is very rich.
6+5=10
EXAMPLE
S Example Proposition Truth value
n is a prime number. NO
He is very rich. NO
6+5=10 YES F
PROPOSITION REPRESENTATION
EXAMPLES:
1. p = “Islamabad is the capital of Pakistan”
2. q = “2+2=3”
3. r=“It is hot today.”
TRANSLATING ENGLISH SENTENCES INTO LOGICAL
EXPRESSIONS
You can access the internet from campus only if you are a computer science major or
you are not a freshmen.
●p= You can access the internet from campus
●q= You are a computer science major
●r = You are a freshmen
●Logical Relation
p→ (q∨¬ r)
COMPOUND PROPOSITION
Simple propositions are combined with Logical operators (aka logical connectives) to form new
proposition, called compound proposition.
LOGICAL OPERATORS
(CONNECTIVES)
•We will examine the following logical operators:
• Negation (NOT)
• Conjunction (AND)
• Disjunction (OR)
• Exclusive or (XOR)
• Implication (if – then)
• Biconditiona (if and only if)
l
•Truth tables can be used to show how these operators can combine propositions to
compound propositions.
EXAMPL
E
• If p and q are statements, then the conjunction of p and q is “p and q”, denoted
as “p ∧ q”.
CONJUNCTION
EXAMPLE
1. p = “Islamabad is the capital of Pakistan”
2. q = “2+2=3”
3. r=“Grass is green.”
T T T
T F T
F T T
F F F
DISJUNCTION
EXAMPLE
1. p = “Islamabad is the capital of
Pakistan”
2. q = “2+2=3”
3. r=“Grass is green.”
T T F
T F T
F T T
F F F
USAGE OF
OR
•OR in an inclusive sense (p or q or both). (DISJUNCTION)
Example: I shall buy a pen or a book.
•OR in an exclusive sense (p or q but not both).
(EXCLUSIVE OR)
Example: Tomorrow at 9, I’ll be in Lahore or Islamabad
“Students who have taken calculus or computer science, but
not both, can enroll
in this class.”
CONDITIONAL
STATEMENTS
• If p and q are proposition, then conditional statement “If p is true then q is
true” or “If p then q” or “p implies q” is denoted by p → q.
• Also known as implication.
• In p → q, the statement p is called the hypothesis (or antecedent) and q
is called the conclusion (or consequent).
TRUTH
TABLE p q p→q
T T T
T F F
F T T
F F T
EXAMPL
E
1. “If 1 = 1, then 3 = 3.” T
2. “If 1 = 1, then 2 = 3.”
3. “If 1 = 1,then 1 = 2 and 2 = F
3.”
T
T
4. “If 1 = 3 or 1 = 2 then 3 = 3.”
WAYS OF EXPRESSING
IMPLICATIONS
The implication p → q could be expressed in many alternative ways
as:
•“if p then q”
•“not p unless q”
•“p implies q”
•“q follows from p”
•“if p, q”
•“q if p”
•“p only if q”
•“q whenever p”
•“p is sufficient for q”
•“q is necessary for p”
EXAMPL
E
• P = Maria learns discrete mathematics
• Q = Maria will find a good job
• “If Maria learns discrete mathematics, then she will find a good job.”
• “Maria will find a good job when she learns discrete mathematics.”
• “For Maria to get a good job, it is sufficient for her to learn discrete mathematics.”
• “Maria will find a good job unless she does not learn discrete mathematics.”
• q is necessary for p : To get an A in this class it is necessary for you to get an A on the final.
• p implies q : you get the job implies that you have the best credentials.
ASSIGNMENT
STATEMENT
• What is the value of the variable x after the statement
if 2 + 2 = 4 then x := x +
1 (:= assignment operator)
Examples:
•If today is Friday, then 2 + 3 = 5. If
today is not Friday, then 2 + 3 ≠ 5.
• If it snows, the traffic moves slowly
If it does not snow the traffic moves
quickly.
CONVERSE OF A CONDITIONAL
STATEMENT
•The converse of the conditional statement
p → q is q →p.
Examples:
•If today is Friday, then 2 + 3 = 5.
If 2 + 3 = 5, then today is Friday
•If it snows, the traffic moves slowly.
If the traffic moves slowly then it
snows
CONTRAPOSITIVE OF A CONDITIONAL
STATEMENT
The contra-positive of the conditional statement p → q is ~ q → ~
p
Examples:
• If today is Friday, then 2 + 3 = 5.
If 2 + 3 ≠ 5, then today is not Friday
• If it snows, the traffic moves slowly.
If the traffic does not move slowly then it does not snow
BICONDITIONA
L
• If p and q are statement variables, the biconditional of p and q is “p if and
only if q”.
• Denoted by p↔q. “if and only if” is abbreviated as iff.
• The double headed arrow " ↔ " is the biconditional operator.
EXAMPL
E
• P = You can take the flight
• Q = You buy a ticket.
T T T
T F F
F T F
F F T
EXAMPLE
S
• “1+1 = 3 if and only if earth is flat”
T
• “Sky is blue iff 1 = 0”
F
• “Milk is white iff birds lay eggs”
T
• “33 is divisible by 4 if and only if horse has four legs”
F
REPHRASING
BICONDITIONAL
p↔q is also expressed as:
• “p is necessary and sufficient for q”
• “If p then q, and conversely”
• “p is equivalent to q”
CONSTRUCTING THE TRUTH
TABLEa truth table for: (p∨¬q) → (p
• Construct
∧
q)
p q ¬q p∨¬q p ∧ (p∨¬q)
→ (p ∧
q q)
T T
T F
F T
F F
CONSTRUCTING THE TRUTH
TABLE
•Precedence of logical operator Operator Precedence
•p ∧ q ∨ r means
(p ∧ q) ∨ r ¬ 1
•p ∨ q → r is the ∧ 2
same as (p ∨ q) → r v 3
→ 4
↔ 5
CONSTRUCTING THE TRUTH
TABLE a truth table for: (p∨¬q) → (p ∧
Construct
T F T
F T F
F F T
CONSTRUCTING THE TRUTH
•TABLE
Construct a truth table for: (p∨¬q) → (p
∧
p q ¬q p∨¬q p∧ (p∨¬q) →
q) (p ∧ q)
q
T T F T
T F T T
F T F F
F F T T
CONSTRUCTING THE TRUTH
TABLEa truth table for: (p∨¬q) → (p
Construct
∧ p q ¬q p∨¬q p∧ (p∨¬q) →
q) (p ∧ q)
q
T T F T T
T F T T F
F T F F F
F F T T F
CONSTRUCTING THE TRUTH
•TABLE
Construct a truth table for: (p∨¬q) → (p
∧ p q ¬q p∨¬q p∧ (p∨¬q) →
q) (p ∧ q)
q
T T F T T T
T F T T F F
F T F F F T
F F T T F F
BOOLEAN
VARIABLE
T 1
F 0
TRUTH TABLE FOR BIT
OPERATOR
x y x∨y x∧y x⊕ y
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0
BIT
STRING
• Sequence of bit.
• Length= number of bits in
string
EXAMPLE:
• 01 1011 0110
• 11 0001 1101
BITWISE OPERATION
EXAMPLE
• 01 1011 0110 and 11 0001 1101.
56
BITWISE OPERATION
EXAMPLE
• 1101111001 and 1100011101
• solution
1101111001
1100011101
57