Ch 1 - Logic Theory
Ch 1 - Logic Theory
Discrete
Structures
12/06/24 1
What is Discrete Structure?
Discrete Objects
Separated from each other (Opposite of
continuous)
e.g., integers, people, house,
Continuous objects: e.g., real number
Discrete Structures
The abstract mathematical structures used to
represent
discrete objects and relationships between
the objects
e.g. sets, relations, graphs
12/06/24 2
Why do we study Discrete Structures?
12/06/24 3
Uses of Discrete Structures in
Computer Science
Networking
Database
Image Processing
Programming Languages
Compilers & Interpreters
Software Engineering
Artificial Intelligence
Computer Architecture
Operating Systems
Security & Cryptography
Advanced Algorithms & Data Structures
Graphics & Animation
…… 4
12/06/24
Tentative Syllabus & Text Book
Logic Theory
Fundamental Structures
Proof Techniques
Basics of Counting
Graph Theory
Discrete Probability
Text Books
1. Discrete Mathematics and Its Applications, 7th
edition by Kenneth H. Rosen, McGraw Hill, 2007.
12/06/24 5
Logic Theory
12/06/24 6
Propositional Logic
Proposition: A proposition is a declarative
statement ( a statement that declares a fact) that
is either TRUE or FALSE, but not both.
The area of logic that deals with propositions is
called propositional logic.
12/06/24 8
Propositional Logic - Negation
We use letters to denote propositional variables
Truth value of true proposition is denoted by T
Truth value of false proposition is denoted by F
Negation: Suppose p is a proposition. The
negation of p is written p and has meaning: “It
is not the case that p.”
The proposition p is read “NOT p”
Example: p: “Today is Friday”
p: “Today is NOT Friday”
Truth table for negation: p p
Notice that p is a F T
proposition! T F
12/06/24 9
Propositional Logic - Conjunction
12/06/24 12
Propositional Logic – Conditional
Statement
It corresponds to English “if p then q” or “p implies q.”
Conditional: Let p and q be two propositions. The
conditional statement (implication) p q is the
proposition “if p, then q”. The conditional statement
p q is false when p is true and q is false, otherwise
true.
Example: If it is raining, then it is cloudy.
If I am elected, then I will lower taxes.
If you get 100% in the final, then you will get Grade
A+.
Truth table for implication: p q pq
F F T
F T T
12/06/24
T F F 13
T T T
Propositional Logic - Special
Definitions
Converse: q p is converse of p q.
Ex. p q: “If it is noon, then I am hungry.”
q p: “If I am hungry, then it is noon.”
Contrapositive: q p is contapositive of p q.
Ex. p q: “If it is noon, then I am hungry.”
q p: “If I am not hungry, then it is not
noon.”
Inverse: p q is inverse of p q.
Ex. p q: “If it is noon, then I am hungry.”
p q: “If it is not noon, then I am not
hungry.”
p q has same truth values as q
p
12/06/24 14
Propositional Logic – Biconditional
Statement
It corresponds to English “p if and only if q”.
Biconditional: Let p and q be two propositions.
The biconditional statement (bi-implication) p ↔ q
is the proposition “p if and only if q”. The
biconditional statement p ↔ q is true when p and
q have the same truth values, otherwise false.
p ↔ q has same truth value as (p q) (q p).
Example: p: “You can take the flight”
q : “You buy a ticket”
p q p↔q
p↔q : “You can take the
F F T
flight if and only if
F T F
you buy a ticket”
T F F
T T T 15
12/06/24
Propositional Logic – Precedence
Precedence of Logical Operators:
Precedenc
Operator
e
¬ 1
p p p p p p
Λ 2
F T T F
ν 3
T F T F
→ 4
A compound proposition that is: ↔ 5
(1) always true is called a tautology
(2) always false is called a contradiction
(3) neither a tautology nor a contradiction is called
contingency or satisfiable.
12/06/24 16
Propositional Logic – Compound
Propositions
Construct truth table for (p q) → (p q).
p q q p q p q (p q) → (p q)
F F T T F F
T F T T F F
F T F F F T
T T F T T T
12/06/24 17
Propositional Equivalences – Logical
Equivalences
Equivalence: The compound propositions p and q
are logically equivalent if p↔q is a tautology. In
other words, p and q are logically equivalent if
their truth tables are the same. We write p q.
Example: (p q) p q.
Truth tables for (p q) and p q :
p q p q (p q) p q p q
F F F T T T T
T F T F F T F
F T T F T F F
T T T F F F F
12/06/24 18
Propositional Equivalences – Logical
Equivalences
Example: p q p q.
Truth tables for p q and p q:
p p p q
p q
q
F F T T T
T F F F F
F T T T T
T T T F T
Q4: Show that p (q r) (p q) (p r)
12/06/24 19
Propositional Equivalence – Prove
the following Logical Equivalences
Equivalence Name
p Λ T p and p ν F p Identity laws
p ν T T and p Λ F F Domination laws
p ν p p and p Λ p p Idempotent laws
Double negation
¬( ¬ p) p
law
Commutative
p ν q q ν p and p Λ q q Λ p
laws
(p ν q) ν r p ν (q ν r) and (p Λ q) Λ r p Λ
Associative laws
(q Λ r)
p (q r) (p q) (p r)
Distributive laws
p (q r) (p q) (p r)
¬(p ν q) ¬p Λ ¬q and ¬(p Λ q) ¬p ν ¬q De Morgan’s laws
12/06/24 20
p (p q) p and p (p q) p Absorption laws
Propositional Equivalence – Prove
the following Logical Equivalences
12/06/24 21
Propositional Logic – Translating
English Sentences
The sentence “The automated reply cannot be
sent when the file system is full” can be
translated as
q → p
where p: “The automated reply can be sent ”
q: “The file system is full”
The sentence “You cannot drive a car if you are
under 4 feet tall unless you are older than 16
years old” can be translated as
(q r) → p
where p: “You can drive a car ”
q: “You are under 4 feet tall ”
r: “You are older than 16 years old”
12/06/24 22
Propositional Logic – Translating
English Sentences
The sentence “You can access the Internet from
campus only if you are a computer science major or
you are not a freshman” can be translated as
p → (q r)
where p: “You can access the Internet from campus”
q: “You are a computer science major”
r: “You are a freshman”
Q5: Translate the following sentences into logical
expressions:
“Access is granted whenever the user has paid the
subscription fee and enters a valid password”
“If the user has not entered a valid password but
has paid the subscription fee, then access is
granted”
12/06/24 23
Propositional Equivalences – Logic
and Bit Operations
Bit: A bit is a symbol with two possible values,
namely, 0 (zero) and 1 (one).
A bit can be used to represent a truth value as 1
for T and 0 for F
Bit string: A bit string is a sequence of bits. The
length of the string is number of bits in the string.
Example: 10101001 is a bit string of length eight
We define the bitwise OR, AND, and XOR of two
strings of same length to be the strings that have
as their bits the OR, AND, and XOR of the
corresponding bits in the two strings, respectively.
We use the symbols , , and ⊕ to represent
bitwise OR, AND, and XOR, respectively.
12/06/24 24
Propositional Equivalences – Logic
and Bit Operations
Truth table for bitwise OR, AND, and XOR:
xy xy x⊕
x y
y
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0
12/06/24 32
Predicates and Quantifiers –
Existential Quantifiers
Def: The existential quantification of P(x) is the
statement “There exists an element x in the
domain such that P(x)”. The notation x P(x)
denotes the existential quantification of P(x).
Here is called existential quantifier.
Example: Let P(x) = “x > 3”. What is the truth
value of the quantification x P(x), where the
domain consists of all real numbers?
Sol: Because P(x) is sometimes true - for
instance, when x=4 – the existential
quantification of P(x), which is x P(x), is true.
12/06/24 33
Predicates and Quantifiers –
Existential Quantifiers
Example: Let P(x) = “x = x+1”. What is the truth
value of the quantification x P(x), where the
domain consists of all real numbers?
Sol: Because P(x) is false for every real number x,
the quantification x P(x) is false.
Q11: Let Q(x) = “x2 > 10”. What is the truth value
of the quantification x Q(x), where the domain
consists of positive integers not exceeding 4?
Q12: Let R(x) = “x2 ≥ x”. What is the truth value
of the quantification x R(x), where the domain
consists of all real numbers? What is the truth
value of the quantification if the domain consists
of all integers?
12/06/24 34
Predicates and Quantifiers –
Translating English into Logical
Expression
Example: Express the statement “Every student
in this class has studied calculus” using
predicates and quantifiers.
Sol: We rewrite as “For every student in this
class, the student has studied calculus”.
=> “For every student x in this class, x has
studied calculus”.
Let P(x) = “x has studied calculus”, then our
statement is represented by xP(x).
Q13: Express the statements “Some students in
this class visited Dubai” and “Every student in
this class has visited either Makkah or Madina”
using predicates and quantifiers.
12/06/24 35
Predicates and Quantifiers –
Quantifiers with Restricted Domain
Example: What do the statements x < 0(x2 > 0),
y≠0(y3 ≠ 0), and z > 0(z2 = 2) mean, where the
domain in each case consists of all real numbers?
Sol: The statement x < 0(x2 > 0) states that for
every number x with x < 0, x2 > 0. That is, it states
“The square of a negative real number is positive”.
The statement is the same as x (x < 0 → x2 > 0).
The statement y ≠ 0(y3 ≠ 0) states that for every
real number y with y ≠ 0, we have y3 ≠ 0. That is, it
states “The cube of every nonzero real is nonzero”.
The statement is the same as y (y ≠ 0 → y3 ≠ 0).
Finally, the statement z > 0(z2 = 2) states that
there exist a real number z with z > 0 such that
z2=2. That is, it states “There is positive square
root of 2”. The statement is the same as z (z > 0
⌃z 2
12/06/24
= 2). 36
Predicates and Quantifiers –
Quantifiers with Restricted Domain
Note: The restriction of a universal quantification is
the same as the universal quantification of a
conditional statement. For instance, x < 0(x2 > 0)
is another way of expressing x (x < 0 → x2 > 0).
On the other hand, the restriction of an existential
quantification is the same as the existential
quantification of a conjunction. For instance,
z>0(z2=2) can be expressed as z (z > 0 ⌃ z2 =
2).
Precedence of Quantifiers: The quantifiers and
have higher precedence then all logical operators
from propositional calculus. For example, xP(x) v
Q(x) is the disjunction of xP(x) and Q(x). In other
words, it means (xP(x)) v Q(x) rather than x
(P(x) v Q(x))
12/06/24 37
Predicates and Quantifiers –
Negating Quantified Expression
Example: x P(x) means “P(x) is true for every
x”. What about x P(x) ?
Sol: x P(x) = Not [“P(x) is true for every x.”]
=> “There is an x for which P(x) is not true.”
=> x P(x)
So, x P(x) is logically equivalent to x P(x).
Example: x P(x) means “P(x) is true for some
x”. What about x P(x) ?
Sol: x P(x) = Not [“P(x) is true for some x.”]
=> “P(x) is not true for all x.”
=> x P(x)
So, x P(x) is logically equivalent to x P(x).
12/06/24 38
Predicates and Quantifiers –
Negating Quantified Expression
De Morgan’s laws for quantifiers:
xy (x + y = y + x)
says that x + y = y + x for all real numbers x
and y. This is commutative law for addition of
real numbers.
12/06/24 43
Nested Quantifiers – Example
Example:
Similarly, the statement
xy (x + y = 0)
says that for every real number x there is a
real number y such that x + y = 0. This states
that every real number has an additive
inverse.
Similarly, the statement
xyz (x + (y + z) = (x + y) + z)
is associative law for addition of real
numbers.
12/06/24 44
Nested Quantifiers – Order of
Quantifiers
Example: Let P(x, y) be the statement “x + y = y +
x”. What are the truth values of the quantifications
xyP(x, y) and yxP(x, y), where the domain for
all variables consists of all real numbers?
Sol: xyP(x, y) = “For all real numbers x, for all
real numbers y, x + y = y + x”.
Since P(x, y) is true for all real numbers x and y,
the proposition xyP(x, y) is also true.
Also, yxP(x, y) = “For all real numbers y, for all
real numbers x, x + y = y + x” = xyP(x, y).
Note: Order of nested universal quantifiers in a
statement without other quantifiers can be
changed without changing meaning of quantified
statement.
12/06/24 45
Nested Quantifiers – Order of
Quantifiers
Example: Let Q(x, y) be the statement “x + y =
0”. What are the truth values of the
quantifications yxQ(x, y) and xyQ(x, y),
where the domain for all variables consists of all
real numbers?
Sol: yxQ(x, y) = “There is a real number y such
that for every real number x, x + y = 0”.
Since there is no real number y such that x + y =
0, for all real numbers x, the proposition yxQ(x,
y) is false.
xyQ(x, y) = “For every real number x, there is a
real number y such that x + y = 0”.
Given a real number x, there is a real number y,
namely y = -x, such that x + y =0. So, xyQ(x,
y) is true.
12/06/24 46
Nested Quantifiers – Quantification
of Two Variables
Statemen When True? When False?
t
xyP(x, P(x, y) is true for every There is a pair x, y for
y) pair x, y. which P(x, y) is false
yxP(x,
y)
xyP(x, For every x there is a y There is an x such that
y), for which P(x, y) is true P(x, y) is false for every y
xyP(x, There is an x such that For every x there is a y
y) P(x, y) is true for every y for which P(x, y) is false
Q17: Let Q(x, y) = “x + y = y”. What are the truth
xyP(x, There is a pair x, y for P(x, y) is false for every
y) values of the P(x,
which quantifications
y) is true pair x, y. y) and
yxQ(x,
xyQ(x, y), where the domain for all variables
yxP(x,
y)
consists of all real numbers?
12/06/24 47
Nested Quantifiers – Order of
Quantifiers
Example: Let Q(x, y, z) be the statement “x + y =
z”. What are the truth values of the
quantifications xyzQ(x, y, z) and zxyQ(x,
y, z), where the domain for all variables consists
of all real numbers?
Sol: xyzQ(x, y, z) = “For all real numbers x
and for all real numbers y there is a real number z
such that x + y = z” is true.
The order of quantification is important here.
Since zxyQ(x, y, z) = “There is a real number
z such that for all real numbers x and for all real
numbers y, x + y = z”, is false, because there is
no z that satisfies the equation x + y = z for all
for all real numbers x and y
12/06/24 48
Nested Quantifiers – Translating
Statements
Example: Translate the statement “The sum of two
positive integers is always positive” into a logical
expression.
Sol: Let x and y be two positive integers, then we
can write the statement as “For all positive
integers x and y, x + y is positive”. This can be
expressed as xy((x > 0) ⌃ (y > 0) → (x + y >
0)), where the domain for both variables consists of
integers. We can also express this as xy(x + y >
0), where the domain for both variables consists of
positive integers.
Q18: Translate the statement “Every real number
except zero has a multiplicative inverse” into a
logical expression.
12/06/24 49
Nested Quantifiers – Translating
From Nested Quantifiers
Example: Translate the statement
x(C(x) v y(C(y) ⌃ F(x, y)))
into English, where C(x)=“x has a computer”, F(x, y)
= “x and y are friends”, and the domain for both x
and y consists of all students in your class.
Sol: The statement says that for every student x in
your class, x has a computer or there is a student y
such that y has computer and x and y are friends. In
other words, every student in your class has a
computer or has a friend who has a computer.
Q19: Translate the statement
xyz((F(x, y) ⌃ F(x, z) ⌃ (y ≠ z)) → F(y, z))
into English, where F(a, b) means a and b are
friends and the domain for x, y and z consists of all
students in your class.
12/06/24 50
End of
Chapter I
12/06/24 51