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

Lecture No. 1

The document discusses various topics in discrete mathematics including propositions, logical operators, sets, functions, graphs and trees. It provides an overview of topics covered in the discrete mathematics course along with their applications in computer science areas such as artificial intelligence and networks.
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)
8 views

Lecture No. 1

The document discusses various topics in discrete mathematics including propositions, logical operators, sets, functions, graphs and trees. It provides an overview of topics covered in the discrete mathematics course along with their applications in computer science areas such as artificial intelligence and networks.
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/ 57

Discrete

Mathematics
CC1041

ADEEL ASHRAF
CMP-101 DISCRETE MATHEMATICS TEXT
BOOK
GRADING
SCHEME Total 100 marks

Assignment and quizzes 25 marks

Mid term 35 marks

Final term 40 marks


CMP-101
DISCRETE MATHEMATICS
TOPICS
• Propositional and predicate calculus • Induction
• Proof methods • Recursion
• Set theory and functions • Basic counting techniques
• Sequences and summations • Relations
• Growth of functions and complexity of • Equivalence classes and partial orderings
algorithms, • Basic graph theory
• Basic number theory • Introduction to trees.
WHY DISCRETE
MATH
• Used in proving correctness of a program.
• Used in computer networks lots of topics about graph theory is used.
• In artificial intelligence lots of ideas about logic is used.
WHAT IS DISCRETE
MATHEMATICS

• Discrete Mathematics part of mathematics devoted to study of discrete objects.

• Discrete means consisting of distinct or unconnected elements.


• Such as:
• Set
• Permutations
• Graphs etc.
DISCRETE VS.
CONTINUOUS
DISCRETE VS.
CONTINUOUS
Set of
Integers:
• • • • • •
-3 -2 -1 0 1 2

Set of Real
Numbers:
• • • •
• •
-1 0 1 2
-3 -2
LOGI
C

Logic is the rule which are used to distinguish between


valid and invalid argument.
PROPOSITION

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.

There are four finger in a


hand
What time is it?

Sum of two odd is even.

6+5=10
EXAMPLE
S Example Proposition Truth value

Grass is green. YES T

n is a prime number. NO

He is very rich. NO

There are four finger in a YES F


hand.
What time is it? NO

Sum of two odd is even. YES T

6+5=10 YES F
PROPOSITION REPRESENTATION

Proposition are symbolically represented by letters such as p, q, r,...

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

• Islamabad is the capital of Pakistan AND 1+1=2


• Islamabad is the capital of Pakistan OR 1+1=2
• IF Islamabad is the capital of Pakistan Then
1+1=2
NEGATION
(NOT)
• If p is a proposition, then negation of p, “not p”, is denoted as “~p, p”, It
has opposite truth value from p i.e., if p is true, then ~ p is false; if p is false,
then ~ p is true.
• “It is not the case that p.”
TRUTH TABLE FOR (~
P)
P ~P
T F
F T
EXAMPL
E
1. p= Today is Friday. F
p=it is not the case that today is Friday.
p=today is not Friday. T
p=it is not Friday today.
2. q= 2+5=7. T
q= 2+5≠7.
T
CONJUNCTION
(AND):

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

p and q= “Islamabad is the capital of Pakistan and 2+2=3.”


p and r=“Islamabad is the capital of Pakistan and grass is
green.
TRUTH TABLE FOR P∧
Q
ROWS: 2𝑛
VALUES
p q p∧ q
T T T
T F F
F T F
F F F
CONJUNCTION
EXAMPLE
1. p = “Islamabad is the capital of
Pakistan”
2. q = “2+2=3”
3. r=“Grass is green.”

p and q= “Islamabad is the capital of Pakistan and 2+2=3.” F


p and r=“Islamabad is the capital of Pakistan and grass is T
green.
DISJUNCTION
(∨)

• If p &q are statements, then the disjunction of p and q is “p or q”, denoted


as
“p∨ q”.
DISJUNCTION
EXAMPLE
1. p = “Islamabad is the capital of Pakistan”
2. q = “2+2=3”
3. r=“Grass is green.”

p or q= “Islamabad is the capital of Pakistan or 2+2=3.”


p or r=“Islamabad is the capital of Pakistan or grass is
green.
TRUTH TABLE FOR P ∨
Q p q p∨ q

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

p or q= “Islamabad is the capital of Pakistan or 2+2=3.” T


p or r=“Islamabad is the capital of Pakistan or grass is T
green.
EXCLUSIVE OR

• When OR is used in its exclusive sense, The statement “p or q” means “p or q


but not both” It is abbreviated as p ⊕ q or p XOR q.
TRUTH TABLE FOR EXCLUSIVE
OR P q p⊕ q

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)

• Solution: Because 2 + 2 = 4 is true, the assignment statement x := x + 1


is executed. Hence, x has the value 0 + 1 = 1 after this statement is
encountered.
INVERSE OF A CONDITIONAL
STATEMENT
•The inverse of the conditional statement p → q is ~p → ~q

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.

• Then p ↔ q is the statement


“You can take the flight if and only if you buy a ticket.”
TRUTH TABLE FOR P↔Q.
p q p ↔q

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

q) p q ¬q p∨¬ p∧ (p∨¬q) →(p∧ q)


q q
T T F

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

• Variable with value either true or


false.
• Represented by bits.
TRUTH VALUE BITS

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

1100011001 bitwise AND


1101111101 bitwise OR
0001100100 bitwise XOR

57

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy