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

ITEC-322 Discrete Structures: Introduction To Subject

This document provides an introduction to the ITEC-322 Discrete Structures course. It outlines the course objectives of learning basic mathematical concepts like sets, functions and graphs. It also covers formal logic, proofs and problem solving skills. The document discusses key topics in the course including propositional logic, truth tables, logical operators like negation and implication. It provides examples and definitions of concepts like propositions, statements, compound statements and the relationship between a statement and its converse, contrapositive and inverse.

Uploaded by

Syed Hamza
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)
113 views

ITEC-322 Discrete Structures: Introduction To Subject

This document provides an introduction to the ITEC-322 Discrete Structures course. It outlines the course objectives of learning basic mathematical concepts like sets, functions and graphs. It also covers formal logic, proofs and problem solving skills. The document discusses key topics in the course including propositional logic, truth tables, logical operators like negation and implication. It provides examples and definitions of concepts like propositions, statements, compound statements and the relationship between a statement and its converse, contrapositive and inverse.

Uploaded by

Syed Hamza
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/ 73

ITEC- 322 Discrete

Structures
Lecture 1
Introduction to subject
Class Information
• Instructor: Dr. Abdul Waheed Mahesar
• Email: [email protected]

• Textbook: Discrete Mathematics and Its Applications (7


th Edition), by Kenneth H. Rosen, McGraw-Hill

• Grading
Final exam: 50%
Midterm Exam: 30%
Homework assignments: 10%
Attendance: 5%
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 Information Technology


What is Discrete Structures
• What are “discrete structures” anyway?
“Discrete” - Composed of distinct, separable
parts. (Opposite of continuous.) e.g., integers, people,
house,Vs. Continuous objects: e.g., real number

“Structures” - Objects built up from simpler


objects according to some definite pattern.

“Discrete Mathematics” - The study of discrete,


mathematical (i.e. well-defined conceptual)
objects and structures.
Propositional Logic
• Logic
Study of reasoning.
Specifically concerned with whether reasoning is correct.
• It helps us to understand how to construct a valid
argument
Logic defines:
• Syntax of statements
• The meaning of statements
• The rules of logical inference (manipulation)
• Focuses on the relationship among statements, not on
the content of any particular statement.
Gives precise meaning to mathematical statements.
Propositional Logic
• Propositional Logic is the logic that deals with statements
(propositions) and compound statements built from simpler
statements using so-called Boolean connectives.

• Some applications in computer science:


• Design of digital electronic circuits.
• Expressing conditions in programs.
• Queries to databases & search engines
Definition of a Proposition
• Definition: A proposition (denoted p, q, r, …) is simply:

• A statement (i.e., a declarative sentence) with some


definite meaning, (not vague or ambiguous) having a truth
value that’s either true (T) or false (F) it is never both,
neither, or somewhere “in between!”

• However, you might not know the actual truth value, and,
the truth value might depend on the situation or context.
Examples of Propositions
• It is raining.
• Beijing is the capital of China.
• 2 + 2 = 5.
• 1 + 2 = 3.
• Karachi is the capital of Saudi Arabia
• Every cow has 4 legs.
Examples of Non-Propositions
• The following are NOT propositions:
• Who’s there? (interrogative, question)
• Just do it! (imperative, command)
• La la la la la. (meaningless)
• 1 + 2 (expression with a non-true/false value)
• x + 2 = 5 (declaration about semantic tokens of non-
constant value)
• How many students in this class?
• Bring me coffee!
Statement (Proposition)

A Statement is a sentence that is either True or False

Examples: 2+2=4 True

3x3=8 False

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.
Propositions (Cont..)
• A statement that has a truth value
• Which of the following are propositions?
– Karachi is the capital of Pakistan.
– Every cow has four legs.
– New Delhi is the capital of India.
– How many students in this class?
– Bring me coffee.
– Propositional variables: p, q, r, s, . . .
– Truth values: T for true, F for false
Propositions (Cont…)
• A statement that has a truth value
• Which of the following are propositions?
– 2 +3 = 45
– 4+3=7
–x+2= 3
–x+y=z
– Propositional variables: p, q, r, s, . . .
– Truth values: T for true, F for false
Truth Tables
• An operator or connective combines one or more operand expressions into a
larger expression. (e.g., “+” in numeric expressions.)

• Unary operators take one operand (e.g., −3); Binary operators take two
operands (e.g. 3 + 4).

• Propositional or Boolean operators operate on propositions (or their truth


values) instead of on numbers.

• The Boolean domain is the set {T, F}. Either of its elements is called a
Boolean value.
• An n-tuple (p1 ,…,pn ) of Boolean values is called a Boolean n-tuple.

• An n-operand truth table is a table that assigns a Boolean value to the set of
all Boolean n-tuples.
Truth Tables
p p p q pq

p q pq p q pq
The Negation Operator

• The Negation Operator


• The unary negation operator “¬” (NOT)
transforms a proposition into its logical negation.
• E.g. If p = “I have brown hair.”
then ¬p = “It is not the case that I have brown
hair” or “I do not have brown hair.”
• The truth table for NOT:
Composite Statements
• More complex propositional statements can be build
from elementary statements using logical connectives.
• Logical connectives:
– Negation
– Conjunction
– Disjunction
– Exclusive or
– Implication
– Biconditional
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


p q P q

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

• Make a truth table of OR and AND.


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
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
T F T
F T T
F F F
Implication
• Definition: Let p and q be propositions. The proposition "p
implies q" denoted by is called implication. It is
false when p is true and q is false and is true otherwise.
• In , p is called the hypothesis and q is called
the conclusion.
• The statement p → q is called a conditional statement
because p → q asserts that q is true on the condition
that p holds. A conditional statement is also called an
implication.

p is called the hypothesis; q is called the conclusion


Implication
• is read in a variety of equivalent ways:
• if p then q
• p only if q
• p is sufficient for q
• q whenever p .
Implication (Example)

“If I am elected, then I will lower taxes.”


p=I’m elected.
q= I’ll lower taxes.

p q p→ q
T T T
T F F
F T T
F F T
Logic Operator

 :: IMPLIES
P Q P Q
T T T
T F F
F T T
F F T

Convention: if we don’t say anything wrong, then it is not false, and thus true.
Implication (Example)

“If you get 100% on the final, then you will get an A.”

p q p→ q
T T T
T F F
F T T
F F T
Implication
• Let p be the statement “Maria learns discrete
mathematics” and q the statement “Maria will find a good
job.”
• Express the statement p → q as a statement in English..
• From the definition of conditional statements, we see
that when p is the statement “Maria learns discrete
mathematics” and q is the statement “Maria will find a
good job,” p → q represents the statement “If Maria
learns discrete mathematics, then she will find a good
job.”

p is called the hypothesis; q is called the conclusion


Implication
• There are many other ways to express this conditional
statement in English.
• Among the most natural of these are:
• “Maria will find a good job when she learns discrete
mathematics.”
OR
• “For Maria to get a good job, it is sufficient for her to
learn discrete mathematics.”

p is called the hypothesis; q is called the conclusion


CONVERSE, CONTRAPOSITIVE, AND INVERSE

• We can form some new conditional statements starting with


a conditional statement p → q.
• In particular, there are three related conditional statements
that occur so often that they have special names.

• The proposition q → p is called the converse of p → q.


• The contrapositive of p → q is the proposition ¬q → ¬p.
• The proposition ¬p → ¬q is called the inverse of p → q.

• We will see that of these three conditional statements


formed from p → q, only the contrapositive always has the
same truth value as p → q..”
Converse, Contrapositive,
Inverse
• Implication: p  q
• Converse: q  p
• Contrapositive:  q   p
• Inverse:  p   q

• Are these the same?


Contrapositive

The contrapositive of “if p then q” is “if ~q then ~p”.

Statement: If you are a CS year 1 student,


then you are taking CTS002.

Contrapositive: If you are not taking CTS002,


then you are not a CS year 1 student.

Fact: A conditional statement is logically equivalent to its contrapositive.


When two compound propositions always have the same truth value we call them
equivalent, so that a conditional statement and its contrapositive are equivalent.

Statement: If P, then Q

Contrapositive: If Q, then P.

T T T F F T
T F F T F F
F T T F T T
F F T T T T
CONVERSE, CONTRAPOSITIVE, AND INVERSE( Example)

Example: 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 “If it is raining, then the home team wins.”
• 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.”
Only the contrapositive is equivalent to the original statement.
If, Only-If

• You will succeed if you work hard.


• You will succeed only if you work hard.

R if S means “if S then R” or equivalently “S implies R”

We also say S is a sufficient condition for R.

R only if S means “if R then S” or equivalently “R implies S”

We also say S is a necessary condition for R.


Math vs English

Parent: if you don’t clean your room, then you can’t watch a DVD.

C D

This sentence says


So
In real life it also means

Mathematician: if a number x greater than 2 is not an odd number,


then x is not a prime number.

This sentence says


Biconditional
The biconditional statement p q states that p if and only
if (iff) q.

• p = “It is below freezing.”


• q = “It is snowing.”
• p q = “It is below freezing if and only if it is snowing.”
or = “That it is below freezing is necessary and sufficient
for it to be snowing.”
Biconditional
The biconditional statement p q states that p if and only if
(iff) q.

• p = “ You can take the flight.”


• q = “ You buy a ticket.”
• p q = “ You can take the flight if and only if you buy a
ticket.”
Biconditional p  q
• p iff q
• p is equivalent to q
• p implies q and q implies p

p q pq
T T T
T F F
F T F
F F T
Necessary AND Sufficient Condition

 :: IFF
P Q P Q
T T T
T F F
F T F
F F T
Note: p q is equivalent to (p q) (q p)
Some Popular Boolean Operators
Boolean Operations Summary
• Conjunction: p q, (read p and q), “discrete math is a required
course and I am a computer science major”.

• Disjunction: , p v q, (read p or q), “discrete math is a required


course or I am a computer science major”.

• Exclusive or: p  q, “discrete math is a required course or I am


a computer science major but not both”.

• Implication: p q, “if discrete math is a required course then I


am a computer science major”.

• Biconditional: p q, “discrete math is a required course if and


only if I am a computer science major”.
Boolean Operations Summary
• Let p: 2 is a prime ….. T
q: 6 is a prime ….. F
• Determine the truth value of the following statements:

¬ p: F
p q: F
p ¬q: T
pvq: T
p  q: T
p q: F
q p: T
Operator Precedence

• We can construct compound propositions using the negation


operator and the logical operators defined so far.
• We will generally use parentheses to specify the order in
which logical operators in a compound proposition are to be
applied.
• For instance, (p ∨ q) ∧ (¬r) is the conjunction of p ∨ q and ¬r.
• However, to reduce the number of parentheses, we specify
that the negation operator is applied before all other logical
operators.
• This means that ¬p ∧ q is the conjunction of ¬p and q,
namely,(¬p) ∧ q, not the negation of the conjunction of p and
q, namely ¬(p ∧ q)”.
Operator Precedence

• Another general rule of precedence is that the


conjunction operator takes precedence over the
disjunction operator, so that p ∧ q ∨ r means (p ∧ q) ∨ r
rather than p ∧ (q ∨ r).

• Because this rule may be difficult to remember, we will


continue to use parentheses so that the order of the
disjunction and conjunction operators is clear.
Operator Precedence

• Finally, it is an accepted rule that the conditional and


biconditional operators → and ↔ have lower precedence
than the conjunction and disjunction operators, ∧ and ∨.

• Consequently, p ∨ q → r is the same as (p ∨ q) → r.

• We will use parentheses when the order of the


conditional operator and biconditional operator is at
issue, although the conditional operator has precedence
over the biconditional operator.
Operator Precedence

Precedence of Logical Operators.


2∧
3∨
4→
5↔
Exercise
Ex: Let p and q be the propositions “Swimming at the New Jersey
shore is allowed” and “Sharks have been spotted near the shore,”
respectively.
Express each of these compound propositions as an English
sentence.
a) ¬q
b) p∧q
c) ¬p ∨ q
d) p → ¬q
e) ¬q → p
f) ¬p → ¬q
g) p ↔ ¬q
h) ¬p ∧ (p ∨ ¬q)
Exercise
a) Sharks have not been spotted near the shore.
b) Swimming at the New Jersey shore is allowed, and sharks have been
spotted near the shore.
c) Swimming at the New Jersey shore is not allowed, or sharks have been
spotted near the shore.
d) If swimming at the New Jersey shore is allowed, then sharks have not
been spotted near the shore.
e) If sharks have not been spotted near the shore, then swimming at the New
Jersey shore is allowed.
f) If swimming at the New Jersey shore is not allowed, then sharks have not
been spotted near the shore.
g) Swimming at the New Jersey shore is allowed if and only if sharks have
not been spotted near the shore.
h) Swimming at the New Jersey shore is not allowed, and either swimming at
the New Jersey shore is allowed or sharks have not been spotted near the
shore. (Note that we were able to incorporate the parenheses by using the
word “either” in the second half of the sentence.)
Exercise
Ex: Let p and q be the propositions
p : You drive over 65 miles per hour.
q : You get a speeding ticket.

Write these propositions using p and q and logical connectives (including


negations).
a) You do not drive over 65 miles per hour.
b) You drive over 65 miles per hour, but you do not get a speeding ticket.
c) You will get a speeding ticket if you drive over 65 miles per hour.
d) If you do not drive over 65 miles per hour, then you will not get a
speeding ticket.
e) Driving over 65 miles per hour is sufficient for getting a speeding ticket.
f) You get a speeding ticket, but you do not drive over 65 miles per hour.
g) Whenever you get a speeding ticket, you are driving over 65 miles per
hour.
Exercise
Ex: Let p and q be the propositions
p : You drive over 65 miles per hour.
q : You get a speeding ticket.

Write these propositions using p and q and logical connectives


(including negations).
a) ¬p
b) p ∧ ¬q
c) p → q
d) ¬p → ¬q
e) p → q
f) q ∧ ¬p
g) q → p
Constructing Truth Tables

Ex: Construct the truth table of the compound propositions.


a) (p v ¬q) → (p ∧ q)
Constructing truth tables

p q  q (pv P q (p v ¬ q) → (p ∧ q)
q)
Constructing Truth Tables

Ex: Construct the truth table of the compound propositions.


a) (p ∧ q) ∨ (¬q ∧ r)
Constructing truth tables
p q r (p ∧ q) ¬ q (¬ q ∧ r) (p ∧ q) ∨ (¬q ∧ r)
Constructing Truth Tables

Ex: How many rows appear in a truth table for each of


these compound propositions?
a) (q → ¬p) ∨ (¬p → ¬q)
b) (p ∨ ¬t) ∧ (p ∨ ¬s)
c) (p → r) ∨ (¬s → ¬t) ∨ (¬u → v)
d) (p ∧ r ∧ s) ∨ (q ∧ t) ∨ (r ∧ ¬t)
Constructing Truth Tables

Ex: Construct a truth table for each of these compound


propositions.

a) (p ∨ q) → (p ⊕ q)
b) (p ⊕ q) → (p ∧ q)
c) (p ∨ q) ⊕ (p ∧ q)
d) (p ↔ q) ⊕ (¬p ↔ q)
e) (p ↔ q) ⊕ (¬p ↔ ¬r)
f) (p ⊕ q) → (p ⊕ ¬q)
Computer representation of
True and False
• We need to encode two values True and False:
• Computers represents data and programs using 0s and 1s
• Logical truth values – True and False
• A bit is sufficient to represent two possible values: – 0
(False) or 1(True)
• A variable that takes on values 0 or 1 is called a Boolean
variable.
• Definition: A bit string is a sequence of zero or more bits.
The length of this string is the number of bits in the string.
Table for the Bit Operators OR,
AND, and XOR
x y xvy x  y x  y
Bit wise operators
Ex# Find the bitwise OR, bitwise AND, and bitwise XOR of the bit
strings 01 1011 0110 and 11 0001 1101. (Here, and throughout this
book, 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.

This gives us 01 1011 0110


11 0001 1101
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
Logical equivalence
• Terminology: A compound proposition is a
– Tautology : A compound proposition which is true no
matter what the truth values of its simple components.
– Contradiction: A compound proposition which is false no
matter what the truth values of its simple components.
– Contingency : if it can be either true or false

pp

(p  q )  p

(p   q)  ( p  q)
Truth Tables
p q p q (p ( p  ( p  q )) ( p  ( p  q ))  
q) q

T T F F T F T

T F F T F F T

F T T F T T F

F F T T T T T

p q p q ( p  q ) ( p  ( p  q )) ( p  ( p  q )) 
q
T p 
Tp FP v  F
p T F T
T F F T F F T
F T T F T T F
F F T T T T T
Tautology
Ex# Determine whether ( p  ( p  q ))   q is a tautology.

Ex# Use a truth table to verify the first De Morgan law


 (p  q ) =  p v  q

Ex# show that conditional statement is a tautology by using truth table.

[ ( p v q)  ( p  r )  ( q  r ) ]  r
[ ( p v q)  ( p  r )  ( q  r ) ]  r

( p v q) ( p  r ) ( q  r ( p v ( p v q)  ( p [ ( p v q) 
p q ) q)   r) ( q (p r) (
r (p  r) q r)]
 r
r)
T T TT T T T T T
T T FT F F F F T
T F TT T T T T T
T F FT F T F F T
F T TT T T T T T
F T FT T F T F T
F F TF T T F F T
F F FF T T F F T
Logical Equivalence
• Compound propositions that have the
same truth values in all possible cases are
called logically equivalent.
• The notation p  q denotes p and q are
logically equivalent
• Example: (p q)  ( p  q)
p q pq p pq (p q)  ( p  q)
Properties of logical connectives
• Identity p∧T≡p p∨F≡p
• Domination p∨T≡T p∧F≡F
• Idempotent p∨p≡p p∧p≡p
• Commutative p∨q≡q∨p p∧q≡q∧p
• Associative (p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
• Distributive p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
• De Morgan’s laws ¬(p ∧ q) ≡ ¬p ∨ ¬q ¬(p ∨ q) ≡ ¬p ∧ ¬q
• Absorption p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
• Negation Laws p ∨ ¬p ≡ T p ∧ ¬p ≡ F
• Double negation law ¬(¬p) ≡ p
De Morgan’s Laws
•  (p  q)   p   q
•  (p  q)   p   q
Equivalences relating to
implication
• pqpq
• pqqp
• pqpq
• p  q   (p   q)
• p  q  (p q)  (q  p)
• pqpq
• p  q  (p  q)  ( p   q)
•  (p  q)  p   q
• Show (p  q)  r and p  (q  r) are not
equivalent.

• Show (p  q)  (p  q) is a tautology
Predicate Calculus
• Predicate or Propositional Function
– A function that returns a truth value
• “x is a cat”
• “x is prime”
• “student x has taken course y”
• “x > y”
• “x + y = z”
Quantifiers
•  x P(x) : P(x) is true for every x in the
domain
•  x P(x) : There is an x in the domain for
which P(x) is true
Statements with quantifiers
Domain:
Positive Integers
•  x Even(x)
Even(x)
Odd(x)
•  x Odd(x) Prime(x)
Greater(x,y)
Equal(x,y)
•  x (Even(x)  Odd(x))

•  x (Even(x)  Odd(x))

•  x Greater(x+1, x)

•  x (Even(x)  Prime(x))
Nested Quantifiers
• Iteration over multiple variables
• Nested loops
• Details
– Use distinct variables
•  x( y(P(x,y)   x Q(y, x)))
– Variable name doesn’t matter
•  x  y P(x, y)   a  b P(a, b)
– Positions of quantifiers can change (but order is
important)
•  x (Q(x)   y P(x, y))   x  y (Q(x)  P(x, y))
Quantification with two variables
Expression When true When false

 x  y P(x,y)

 x  y P(x,y)

 x  y P(x, y)

 y  x P(x, y)
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

You might also like