ITEC-322 Discrete Structures: Introduction To Subject
ITEC-322 Discrete Structures: Introduction To Subject
Structures
Lecture 1
Introduction to subject
Class Information
• Instructor: Dr. Abdul Waheed Mahesar
• Email: [email protected]
• Grading
Final exam: 50%
Midterm Exam: 30%
Homework assignments: 10%
Attendance: 5%
Objectives of This Course
• 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)
3x3=8 False
Non-examples: x+y>0
x2+y2=z2
• Unary operators take one operand (e.g., −3); Binary operators take two
operands (e.g. 3 + 4).
• 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 pq
p q pq p q pq
The Negation Operator
p q T
T
T
F
T
F
F T F
F F F
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.”
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)
Parent: if you don’t clean your room, then you can’t watch a DVD.
C D
p q pq
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”.
¬ p: F
p q: F
p ¬q: T
pvq: T
p q: T
p q: F
q p: T
Operator Precedence
1¬
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.
p q q (pv P q (p v ¬ q) → (p ∧ q)
q)
Constructing Truth Tables
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.
pp
(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.
[ ( 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 pq p pq (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
• pqpq
• pqqp
• pqpq
• p q (p q)
• p q (p q) (q p)
• pqpq
• 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
3 students in a group