CS104 : Discrete Structures
Chapter I
Introduction & Logic Theory
2
Introduction to
Discrete
Structures
3
What is Discrete Structure?
 Discrete Objects
 Separated from each other (Opposite of
continuous)
 e.g., integers, people, house,
 Vs. 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
4
Why do we study Discrete Structures?
 Information is stored and manipulated by
computers in a discrete fashion. 0101101…
 As a student in computer science major, you
need to know the basic language and conceptual
foundation for all of the computer science, i.e.,
Discrete Structures!
 Discrete structure concepts are also widely
used throughout math, science, engineering,
economics, biology, etc., …
 Get training for rational thought!
5
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
 ……
6
 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.
Tentative Syllabus & Text Book
7
Logic Theory
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.
8
Propositions
Not Propositions
1. Riyadh is the capital
of Saudi Arabia
1. How many students in
this class?
2. Every cow has 4 legs.
2. Bring me coffee!
3. 3 + 2 = 32
4. 4 + 3 = 7
3. X + 2 = 3
4. Y + Z = X
Propositional Logic - Applications
9
 We are using propositional logic as a foundation for
formal proofs.
 Propositional logic is also the key to writing good
code…you can’t do any kind of conditional (if)
statement without understanding the condition
you’re testing.
 All the logical connectives we will discuss are also
found in hardware and are called “gates.”
Propositional Logic - Negation
10
 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
F
T
T
F
Notice that p is a
proposition!
Propositional Logic - Conjunction
11
 Conjunction corresponds to English “and.”
 Conjunction: Let p and q be two propositions. The
conjunction of p and q, denoted by p  q, is the
proposition “p and q”. The p  q is true when both p
and q are true, otherwise false.
 Example: p: “Today is Friday”
q: “It is raining today”
p  q: “Today is Friday and it is raining today”
 Truth table for conjunction: p
q
p  q
F
F
T
T
F
T
F
T
F
F
F
T
Propositional Logic - Disjunction
12
 Disjunction corresponds to English “or.”
 Disjunction: Let p and q be two propositions. The
disjunction of p and q, denoted by p  q, is the
proposition “p or q”. The p  q is false when both p
and q are false, otherwise true.
 Example: p: “Today is Friday”
q: “It is raining today”
p  q: “Today is Friday or it is raining today”
 Truth table for disjunction: p
q
p  q
F
F
T
T
F
T
F
T
F
T
T
T
Propositional Logic – Exclusive Or
13
 Exclusive Or: Let p and q be two propositions. The
exclusive or of p and q, denoted by p ⊕ q, is the
proposition that is true when exactly one of p and q
is true, otherwise false.
 Truth table for Exclusive Or: p
q
p ⊕ q
F
F
T
T
F
T
F
T
F
T
T
F
Propositional Logic – Conditional
Statement
14
 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
p  q
F
F
T
T
F
T
F
T
T
T
F
T
Propositional Logic - Special Definitions
15
 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
Propositional Logic - Questions
16
 Q1: Give some examples of p  q, then tell what is
 q  p
 q  p
 p  q
 Q2: State the converse, contrapositive, and inverse
of each of them
 If it rains today, then I will stay at home
 I come to class whenever there is going to be a examination
 A positive integer is prime only if it has no divisors other
than 1 and itself.
Propositional Logic – Biconditional
Statement
17
 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 : “You can take the
flight if and only if
you buy a ticket”
p
q
p q
↔
F
F
T
T
F
T
F
T
T
F
F
T
Propositional Logic – Precedence
18
 Precedence of Logical Operators:
 A compound proposition that is:
(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.
Operator
Precedence
¬
Λ
ν
→
↔
1
2
3
4
5
p
p
p  p
p  p
F
T
T
F
T
F
T
F
Propositional Logic – Compound
Propositions
p
q
q
p  q
p  q
(p  q) → (p  q)
F
T
F
T
F
F
T
T
T
T
F
F
T
T
F
T
F
F
F
T
F
F
T
T
19
 Construct truth table for (p  q) → (p  q).
 Q3: Construct truth table for
(p  q) ↔ (p  q).
 (p ⊕ q) → (p ⊕ q).
Propositional Equivalences – Logical
Equivalences
p
q
p  q
(p  q)
p
q
p  q
F
T
F
T
F
F
T
T
F
T
T
T
T
F
F
F
T
F
T
F
T
T
F
F
T
F
F
F
20
 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 :
Propositional Equivalences – Logical
Equivalences
p
q
p  q
p
p  q
F
T
F
T
F
F
T
T
T
F
T
T
T
F
T
F
T
F
T
T
21
 Example: p  q  p  q.
 Truth tables for p  q and p  q:
 Q4: Show that p  (q  r)  (p  q)  (p  r)
Propositional Equivalence – Prove the
following Logical Equivalences
22
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
¬( ¬ p)  p
Double negation law
p ν q  q ν p and p Λ q  q Λ p
Commutative laws
(p ν q) ν r  p ν (q ν r) and (p Λ q) Λ r  p Λ (q Λ
r)
Associative laws
p  (q  r)  (p  q)  (p  r)
p  (q  r)  (p  q)  (p  r)
Distributive laws
¬(p ν q)  ¬p Λ ¬q and ¬(p Λ q)  ¬p ν ¬q
De Morgan’s laws
p  (p  q)  p and p  (p  q)  p
Absorption laws
p ν ¬p  T and p Λ ¬p  F
Negation laws
Propositional Equivalence – Prove the
following Logical Equivalences
23
Propositional Logic – Translating English
Sentences
24
 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”
Propositional Logic – Translating English
Sentences
25
 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”
Propositional Equivalences – Logic and
Bit Operations
26
 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.
Propositional Equivalences – Logic and
Bit Operations
x
y
x  y
x  y
x ⊕
y
0
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
27
 Truth table for bitwise OR, AND, and XOR:
 Q6: Find bitwise OR, AND, and XOR of the bit
strings
01 0011 0100 and 10 1001 0101
00 1011 1010 and 11 1010 0101
11 0101 0110 and 10 1101 0010
Predicates and Quantifiers - Predicates
28
 The statements “x > 3”, “x = y + 3”, and “computer x
is functioning properly” are not propositions
 This section discusses how proposition can be
produced from such statements
 The statement “x > 3” has two parts –
the variables x, the subject of the statement
is greater than 3, the predicate, the property
that the subject of the statement can have
 We denote P(x) = “x > 3”, where P denotes the
predicate “is greater than 3” and x is the variable
 Once we assign a value to x, it becomes proposition
Predicates and Quantifiers - Predicates
29
 Def: A predicate, or propositional function, is a
function that takes some variable(s) as arguments
and returns True or False.
 Example: Let P(x) = “x > 3”, what are the truth values
of P(2) and P(4)?
 Sol: P(2) = “2 > 3” is false and P(4) = “4 > 3” is true
 Example: Let Q(x, y) = “x = y + 3”, what are the
truth values of Q(1, 2) and Q(3, 0)?
 Sol: Q(1,2)= “1=2+3” is false, Q(3,0)= “3=0+3” is true
 Def: A statement of the form P(x1, x2, …., xn) is the
value of the propositional function P at the n-tuple
(x1, x2, …., xn), and P is called n-ary predicate
Predicates and Quantifiers- Predicates
30
 Example: Consider the statement
if x > 0 then x := x + 1.
Here P(x) = “x > 0”. If P(x) is true for the value of
x, then the assignment statement x := x + 1 is
executed, x is increased by 1. If P(x) is false for the
value of x, then the assignment statement is not
executed, x remains same
 The statements that describe valid input are known
as preconditions, and the conditions that the output
should satisfy when it has run are known as
postconditions
 Q7: Let R(x, y, z) = “x + y = z”, what are the truth
values of R(1, 2, 3) and R(0, 0, 1)?
Predicates and Quantifiers - Quantifiers
31
 Another way of changing a predicate into a
proposition is called quantification
 In English, the words all, some, many, none, and few
are used in quantifications
 Two types of quantifications:
Universal quantifications – a predicate is true for
every element under consideration
Existential quantifications – there is one or more
element under consideration for which predicate
is true
 The area of logic that deals with predicates and
quantifiers is called predicate calculus
Predicates and Quantifiers – Universal
Quantifiers
Statement
When True?
When False?
x P(x)
 x P(x)
P(x) is true for every x
There is an x for which
P(x) is true
There is an x for
which P(x) is false
P(x) is false for
every x
32
 Def: The universal quantification of P(x) is the
statement “P(x) for all values of x in the domain”.
The notation x P(x) denotes the universal
quantification of P(x). Here  is called universal
quantifier. An element for which P(x) is false is
called a counterexample of x P(x).
 Quantifiers:
Predicates and Quantifiers – Universal
Quantifiers
33
 Example: Let P(x) = “x+1 > x”. What is the truth value
of the quantification x P(x), where the domain
consists of all real numbers?
 Sol: Because P(x) is true for all real numbers x, the
quantification x P(x) is true.
 Example: Let Q(x) = “x < 2”. What is the truth value
of the quantification x Q(x), where the domain
consists of all real numbers?
 Sol: Because Q(x) is not true for every real number
x, because, for instance, Q(3) is false. That is, x=3
is a counterexample for the statement x Q(x).
Predicates and Quantifiers – Universal
Quantifiers
34
 Q8: Let P(x) = “x2
> 0”. What is the truth value of
the quantification x P(x), where the domain
consists of all real numbers?
 Q9: Let Q(x) = “x2
< 10”. What is the truth value of
the quantification x Q(x), where the domain
consists of positive integers less than 4?
 Q10: 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?
Predicates and Quantifiers –
Existential Quantifiers
35
 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.
Predicates and Quantifiers –
Existential Quantifiers
36
 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?
Predicates and Quantifiers – Translating
English into Logical Expression
37
 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.
Predicates and Quantifiers –
Quantifiers with Restricted Domain
38
 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 ⌃z2
= 2).
Predicates and Quantifiers –
Quantifiers with Restricted Domain
39
 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))
Predicates and Quantifiers – Negating
Quantified Expression
40
 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).
Predicates and Quantifiers – Negating
Quantified Expression
Negation
Equivalent
Statement
When is
Negation True?
When False?
 x
P(x)
x P(x)
x P(x)
 x P(x)
For every x,
P(x) is false
There is an x for
which P(x) is
false
There is an x
for which
P(x) is true
P(x) is true
for every x
41
 De Morgan’s laws for quantifiers:
Predicates and Quantifiers – Negating
Quantified Expression
42
 Example: What are the negations of the statements
“There is a religious man” and “All Saudi eat Rice”?
 Sol: Let P(x) = “x is a religious”,
=> “There is a religious man”= xP(x), where the
domain consists of all men
Now, xP(x) = xP(x) =“Every man is nonreligious”.
Next, let Q(x) = “x eats Rice”
=> “All Saudi eat Rice” = xQ(x), where the domain
consists of all Saudi
Now,  xQ(x) = xQ(x) = “Some Saudi does not
eat rice”.
 Q14: What are the negations of the statements
x (x2
> x) and x (x2
= 2)”?
Predicates and Quantifiers – Negating
Quantified Expression
43
 Example: Let L(x) = “x is a lion”, F(x) = “x is fierce”,
and C(x) = “x drinks coffee”. Show the quantifiers
for the statements (i) All lions are fierce, (ii) Some
lions don’t drink coffee, (iii) Some fierce creatures
don’t drink coffee.
 Sol: (i) x (L(x)  F(x)), ii) x (L(x)  C(x)), and
(iii) x (F(x)  C(x))
 Q15: Let B(x) = “x is a hummingbird”, L(x) = “x is a
large bird”, H(x) = “x lives on honey”, and R(x) = “x is
richly colored”. Show the quantifiers for the
statements (i) All hummingbirds are richly colored,
(ii) No large birds live on honey, (iii) Birds that do
not live on honey are dully colored, and (iv) Not all
large birds live on honey.
Predicates and Quantifiers – Logical
Equivalences
44
 Example: Show that x (P(x)  Q(x)) and xP(x)  x
Q(x) are logically equivalent.
 Sol: Let x (P(x)  Q(x)) is true
=> if a is in the domain, then P(a)  Q(a) is true
=> P(a) and Q(a) are true, for all a in the domain
=> xP(x) and xQ(x) are true
=> xP(x)  xQ(x) is true
So, they are logically equivalent.
 Q16: Show that x(P(x)Q(x)) and x(P(x) 
Q(x)) are logically equivalent.
Nested Quantifiers – Definition
45
 Def: Two quantifiers are said to be nested if one is
within the scope of the other, such as
xy (x + y = 0)
 Note that xy (x + y = 0) is same as xQ(x),
where Q(x) is yP(x, y), where P(x, y) is x + y = 0.
 Example: Assume that the domain for the variables
x and y consists of all real numbers.
The statement
xy (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.
Nested Quantifiers – Example
46
 Example:
Similarly, the statement
xy (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
xyz (x + (y + z) = (x + y) + z)
is associative law for addition of real numbers.
Nested Quantifiers – Order of
Quantifiers
47
 Example: Let P(x, y) be the statement “x + y = y +
x”. What are the truth values of the quantifications
xyP(x, y) and yxP(x, y), where the domain for
all variables consists of all real numbers?
 Sol: xyP(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 xyP(x, y) is also true.
Also, yxP(x, y) = “For all real numbers y, for all
real numbers x, x + y = y + x” = xyP(x, y).
 Note: Order of nested universal quantifiers in a
statement without other quantifiers can be changed
without changing meaning of quantified statement.
Nested Quantifiers – Order of
Quantifiers
48
 Example: Let Q(x, y) be the statement “x + y = 0”.
What are the truth values of the quantifications
yxQ(x, y) and xyQ(x, y), where the domain for
all variables consists of all real numbers?
 Sol: yxQ(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 yxQ(x, y)
is false.
xyQ(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, xyQ(x, y) is
true.
Nested Quantifiers – Quantification of
Two Variables
Statement
When True?
When False?
xyP(x, y)
yxP(x, y)
P(x, y) is true for every
pair x, y.
There is a pair x, y for
which P(x, y) is false
xyP(x,
y),
For every x there is a y for
which P(x, y) is true
There is an x such that
P(x, y) is false for every y
xyP(x, y)
There is an x such that
P(x, y) is true for every y
For every x there is a y for
which P(x, y) is false
xyP(x, y)
yxP(x, y)
There is a pair x, y for
which P(x, y) is true
P(x, y) is false for every
pair x, y.
49
 Q17: Let Q(x, y) = “x + y = y”. What are the truth
values of the quantifications yxQ(x, y) and
xyQ(x, y), where the domain for all variables
consists of all real numbers?
Nested Quantifiers – Order of
Quantifiers
50
 Example: Let Q(x, y, z) be the statement “x + y = z”.
What are the truth values of the quantifications
xyzQ(x, y, z) and zxyQ(x, y, z), where the
domain for all variables consists of all real numbers?
 Sol: xyzQ(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
zxyQ(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
Nested Quantifiers – Translating
Statements
51
 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
xy((x > 0) ⌃ (y > 0) → (x + y > 0)), where the domain
for both variables consists of integers. We can also
express this as xy(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.
Nested Quantifiers – Translating From
Nested Quantifiers
52
 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
xyz((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.
53
End of
Chapter I

More Related Content

PPT
good teaching skills and other beautiful things
PPT
lectures in prolog in order to advance in artificial intelligence
PPT
Chapter 1: The Foundations: Logic and Proofs
PPT
Discrete mathematics Chapter1 presentation.ppt
PPT
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
PPT
1019Lec1.ppt
PPT
First order predicate logic - Artificial Intelligence
PPTX
Chapter1p1
good teaching skills and other beautiful things
lectures in prolog in order to advance in artificial intelligence
Chapter 1: The Foundations: Logic and Proofs
Discrete mathematics Chapter1 presentation.ppt
Discrete mathematics Ch2 Propositional Logic_Dr.khaled.Bakro د. خالد بكرو
1019Lec1.ppt
First order predicate logic - Artificial Intelligence
Chapter1p1

Similar to Best presentation about discrete structure (20)

PPT
PPTX
Drinkfromme.pptx
PDF
Chapter 01 - p1.pdf
PPTX
Discrete_Mathematics_Chapter1_Part1.pptx
PPT
desmath(1).ppt
PPT
Discrete Structures_Logic and Proofs_Saleh.ppt
PDF
Propositional Logic Discrete Mathematics
PDF
Chapter1p1.pdf
PPT
CS202Ch1.ppt
PPTX
Unit 4 Propositional logic Discrete Mathematics
PPTX
DMS UNIT-1 ppt.pptx
PPT
Lecture 01.ppt
PPT
Discrete mathematics with applications by Susanna notes
PPTX
DisMath-lecture-2-Logic-and-Proofs-08032022-115009am.pptx
PPTX
Discrete Math Chapter 1 :The Foundations: Logic and Proofs
PPTX
PDF
UGC NET Computer Science & Application book.pdf [Sample]
PPTX
Discrete Mathematics Details tree pt.pptx
PPTX
Propositional logic in Discretes tructures.pptx
PPTX
General concepts of digital electronics and
Drinkfromme.pptx
Chapter 01 - p1.pdf
Discrete_Mathematics_Chapter1_Part1.pptx
desmath(1).ppt
Discrete Structures_Logic and Proofs_Saleh.ppt
Propositional Logic Discrete Mathematics
Chapter1p1.pdf
CS202Ch1.ppt
Unit 4 Propositional logic Discrete Mathematics
DMS UNIT-1 ppt.pptx
Lecture 01.ppt
Discrete mathematics with applications by Susanna notes
DisMath-lecture-2-Logic-and-Proofs-08032022-115009am.pptx
Discrete Math Chapter 1 :The Foundations: Logic and Proofs
UGC NET Computer Science & Application book.pdf [Sample]
Discrete Mathematics Details tree pt.pptx
Propositional logic in Discretes tructures.pptx
General concepts of digital electronics and
Ad

More from AssadLeo1 (20)

PPTX
What is SEO in the education usefull for us
PPTX
very useful for every thing in this area
PPT
Chagal chagal with khatch khatch model with detail
PPT
E commerce busin and some important issues
PPTX
What is SEO in pakistan with main components
PPT
business model and some other things that
PPTX
Software Evolution all in Mehmoona.pptx
PPTX
Behavioral Model with Maniha Butt and many More
PPTX
Software Quality Assurance Qurat ul ain.pptx
PPTX
UML Samra Bs it 4th all about aspire college
PPTX
Process Structure and some other important
PPT
Process importance with full detail about
PPTX
IPM Chapter 1 Complete detail and chapeter
PPTX
Hardware Firewall with all the detail of
PPTX
Law and Order in PK in a country is most important
PPTX
Types of Multipule things and other things
PPTX
Model_of_Heterogeneous_System and other things
PPTX
what a knowledge and other things in this slide
PPTX
full with knowledge and other things with
PPT
that is the most important part of this topic
What is SEO in the education usefull for us
very useful for every thing in this area
Chagal chagal with khatch khatch model with detail
E commerce busin and some important issues
What is SEO in pakistan with main components
business model and some other things that
Software Evolution all in Mehmoona.pptx
Behavioral Model with Maniha Butt and many More
Software Quality Assurance Qurat ul ain.pptx
UML Samra Bs it 4th all about aspire college
Process Structure and some other important
Process importance with full detail about
IPM Chapter 1 Complete detail and chapeter
Hardware Firewall with all the detail of
Law and Order in PK in a country is most important
Types of Multipule things and other things
Model_of_Heterogeneous_System and other things
what a knowledge and other things in this slide
full with knowledge and other things with
that is the most important part of this topic
Ad

Recently uploaded (20)

PPTX
Zero Waste Philippines Recycling and Material Sustainability Programs
PPTX
STUDY OF POULTRY FARM MANAGEMENT PRACTICES IN KAMSAGARA, KADUR TQ..pptx
PPTX
Flood management in Bangladesh with respect to the disaster management cycle
PDF
ICAR JRF Agronomy 2021 Paper by IARI Wala.pdf
PPTX
serminar msc 1st in situ conservation .pptx
PPTX
Chapter 12 Promoting Safety and health
PPTX
Human Induced Factors of Flooding in Bangladesh
PPTX
MITIGATION OF HUMAN – WILDLIFE CONFLICT - Copy.pptx
PPTX
Housing principles for different species of poultry.pptx
PDF
Analysing the environmental, economic and social footprint of Traffic Circu...
PPTX
Env107 Presentation Slides done under NLQ
PPTX
ENVIRONMENT SCIENCES & SUSTAINABILITY PPT
PDF
Plant Physiology Study Material For NEET
PDF
Ethiopia's third national communication to UNFCCC.pdf
PPT
vdocument.in_site-planning-by-kevin-lynch.ppt
PPTX
Forest and wildlife Presentation for the students
PPT
Bahan kuliah Pecemar Water pollution.ppt
PPTX
FINANCIAL MARKETS 05Av ghg6ggjgt gygffghuhjggv gvgf. hg
PDF
Basics of Toxicology in environmental health perspective.pdf
DOCX
Aluminum Geodesic Dome Roof for Raw Water Tanks Shields Untreated Water from ...
Zero Waste Philippines Recycling and Material Sustainability Programs
STUDY OF POULTRY FARM MANAGEMENT PRACTICES IN KAMSAGARA, KADUR TQ..pptx
Flood management in Bangladesh with respect to the disaster management cycle
ICAR JRF Agronomy 2021 Paper by IARI Wala.pdf
serminar msc 1st in situ conservation .pptx
Chapter 12 Promoting Safety and health
Human Induced Factors of Flooding in Bangladesh
MITIGATION OF HUMAN – WILDLIFE CONFLICT - Copy.pptx
Housing principles for different species of poultry.pptx
Analysing the environmental, economic and social footprint of Traffic Circu...
Env107 Presentation Slides done under NLQ
ENVIRONMENT SCIENCES & SUSTAINABILITY PPT
Plant Physiology Study Material For NEET
Ethiopia's third national communication to UNFCCC.pdf
vdocument.in_site-planning-by-kevin-lynch.ppt
Forest and wildlife Presentation for the students
Bahan kuliah Pecemar Water pollution.ppt
FINANCIAL MARKETS 05Av ghg6ggjgt gygffghuhjggv gvgf. hg
Basics of Toxicology in environmental health perspective.pdf
Aluminum Geodesic Dome Roof for Raw Water Tanks Shields Untreated Water from ...

Best presentation about discrete structure

  • 1. CS104 : Discrete Structures Chapter I Introduction & Logic Theory
  • 3. 3 What is Discrete Structure?  Discrete Objects  Separated from each other (Opposite of continuous)  e.g., integers, people, house,  Vs. 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
  • 4. 4 Why do we study Discrete Structures?  Information is stored and manipulated by computers in a discrete fashion. 0101101…  As a student in computer science major, you need to know the basic language and conceptual foundation for all of the computer science, i.e., Discrete Structures!  Discrete structure concepts are also widely used throughout math, science, engineering, economics, biology, etc., …  Get training for rational thought!
  • 5. 5 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  ……
  • 6. 6  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. Tentative Syllabus & Text Book
  • 8. 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. 8 Propositions Not Propositions 1. Riyadh is the capital of Saudi Arabia 1. How many students in this class? 2. Every cow has 4 legs. 2. Bring me coffee! 3. 3 + 2 = 32 4. 4 + 3 = 7 3. X + 2 = 3 4. Y + Z = X
  • 9. Propositional Logic - Applications 9  We are using propositional logic as a foundation for formal proofs.  Propositional logic is also the key to writing good code…you can’t do any kind of conditional (if) statement without understanding the condition you’re testing.  All the logical connectives we will discuss are also found in hardware and are called “gates.”
  • 10. Propositional Logic - Negation 10  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 F T T F Notice that p is a proposition!
  • 11. Propositional Logic - Conjunction 11  Conjunction corresponds to English “and.”  Conjunction: Let p and q be two propositions. The conjunction of p and q, denoted by p  q, is the proposition “p and q”. The p  q is true when both p and q are true, otherwise false.  Example: p: “Today is Friday” q: “It is raining today” p  q: “Today is Friday and it is raining today”  Truth table for conjunction: p q p  q F F T T F T F T F F F T
  • 12. Propositional Logic - Disjunction 12  Disjunction corresponds to English “or.”  Disjunction: Let p and q be two propositions. The disjunction of p and q, denoted by p  q, is the proposition “p or q”. The p  q is false when both p and q are false, otherwise true.  Example: p: “Today is Friday” q: “It is raining today” p  q: “Today is Friday or it is raining today”  Truth table for disjunction: p q p  q F F T T F T F T F T T T
  • 13. Propositional Logic – Exclusive Or 13  Exclusive Or: Let p and q be two propositions. The exclusive or of p and q, denoted by p ⊕ q, is the proposition that is true when exactly one of p and q is true, otherwise false.  Truth table for Exclusive Or: p q p ⊕ q F F T T F T F T F T T F
  • 14. Propositional Logic – Conditional Statement 14  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 p  q F F T T F T F T T T F T
  • 15. Propositional Logic - Special Definitions 15  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
  • 16. Propositional Logic - Questions 16  Q1: Give some examples of p  q, then tell what is  q  p  q  p  p  q  Q2: State the converse, contrapositive, and inverse of each of them  If it rains today, then I will stay at home  I come to class whenever there is going to be a examination  A positive integer is prime only if it has no divisors other than 1 and itself.
  • 17. Propositional Logic – Biconditional Statement 17  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 : “You can take the flight if and only if you buy a ticket” p q p q ↔ F F T T F T F T T F F T
  • 18. Propositional Logic – Precedence 18  Precedence of Logical Operators:  A compound proposition that is: (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. Operator Precedence ¬ Λ ν → ↔ 1 2 3 4 5 p p p  p p  p F T T F T F T F
  • 19. Propositional Logic – Compound Propositions p q q p  q p  q (p  q) → (p  q) F T F T F F T T T T F F T T F T F F F T F F T T 19  Construct truth table for (p  q) → (p  q).  Q3: Construct truth table for (p  q) ↔ (p  q).  (p ⊕ q) → (p ⊕ q).
  • 20. Propositional Equivalences – Logical Equivalences p q p  q (p  q) p q p  q F T F T F F T T F T T T T F F F T F T F T T F F T F F F 20  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 :
  • 21. Propositional Equivalences – Logical Equivalences p q p  q p p  q F T F T F F T T T F T T T F T F T F T T 21  Example: p  q  p  q.  Truth tables for p  q and p  q:  Q4: Show that p  (q  r)  (p  q)  (p  r)
  • 22. Propositional Equivalence – Prove the following Logical Equivalences 22 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 ¬( ¬ p)  p Double negation law p ν q  q ν p and p Λ q  q Λ p Commutative laws (p ν q) ν r  p ν (q ν r) and (p Λ q) Λ r  p Λ (q Λ r) Associative laws p  (q  r)  (p  q)  (p  r) p  (q  r)  (p  q)  (p  r) Distributive laws ¬(p ν q)  ¬p Λ ¬q and ¬(p Λ q)  ¬p ν ¬q De Morgan’s laws p  (p  q)  p and p  (p  q)  p Absorption laws p ν ¬p  T and p Λ ¬p  F Negation laws
  • 23. Propositional Equivalence – Prove the following Logical Equivalences 23
  • 24. Propositional Logic – Translating English Sentences 24  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”
  • 25. Propositional Logic – Translating English Sentences 25  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”
  • 26. Propositional Equivalences – Logic and Bit Operations 26  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.
  • 27. Propositional Equivalences – Logic and Bit Operations x y x  y x  y x ⊕ y 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0 1 0 1 1 0 27  Truth table for bitwise OR, AND, and XOR:  Q6: Find bitwise OR, AND, and XOR of the bit strings 01 0011 0100 and 10 1001 0101 00 1011 1010 and 11 1010 0101 11 0101 0110 and 10 1101 0010
  • 28. Predicates and Quantifiers - Predicates 28  The statements “x > 3”, “x = y + 3”, and “computer x is functioning properly” are not propositions  This section discusses how proposition can be produced from such statements  The statement “x > 3” has two parts – the variables x, the subject of the statement is greater than 3, the predicate, the property that the subject of the statement can have  We denote P(x) = “x > 3”, where P denotes the predicate “is greater than 3” and x is the variable  Once we assign a value to x, it becomes proposition
  • 29. Predicates and Quantifiers - Predicates 29  Def: A predicate, or propositional function, is a function that takes some variable(s) as arguments and returns True or False.  Example: Let P(x) = “x > 3”, what are the truth values of P(2) and P(4)?  Sol: P(2) = “2 > 3” is false and P(4) = “4 > 3” is true  Example: Let Q(x, y) = “x = y + 3”, what are the truth values of Q(1, 2) and Q(3, 0)?  Sol: Q(1,2)= “1=2+3” is false, Q(3,0)= “3=0+3” is true  Def: A statement of the form P(x1, x2, …., xn) is the value of the propositional function P at the n-tuple (x1, x2, …., xn), and P is called n-ary predicate
  • 30. Predicates and Quantifiers- Predicates 30  Example: Consider the statement if x > 0 then x := x + 1. Here P(x) = “x > 0”. If P(x) is true for the value of x, then the assignment statement x := x + 1 is executed, x is increased by 1. If P(x) is false for the value of x, then the assignment statement is not executed, x remains same  The statements that describe valid input are known as preconditions, and the conditions that the output should satisfy when it has run are known as postconditions  Q7: Let R(x, y, z) = “x + y = z”, what are the truth values of R(1, 2, 3) and R(0, 0, 1)?
  • 31. Predicates and Quantifiers - Quantifiers 31  Another way of changing a predicate into a proposition is called quantification  In English, the words all, some, many, none, and few are used in quantifications  Two types of quantifications: Universal quantifications – a predicate is true for every element under consideration Existential quantifications – there is one or more element under consideration for which predicate is true  The area of logic that deals with predicates and quantifiers is called predicate calculus
  • 32. Predicates and Quantifiers – Universal Quantifiers Statement When True? When False? x P(x)  x P(x) P(x) is true for every x There is an x for which P(x) is true There is an x for which P(x) is false P(x) is false for every x 32  Def: The universal quantification of P(x) is the statement “P(x) for all values of x in the domain”. The notation x P(x) denotes the universal quantification of P(x). Here  is called universal quantifier. An element for which P(x) is false is called a counterexample of x P(x).  Quantifiers:
  • 33. Predicates and Quantifiers – Universal Quantifiers 33  Example: Let P(x) = “x+1 > x”. What is the truth value of the quantification x P(x), where the domain consists of all real numbers?  Sol: Because P(x) is true for all real numbers x, the quantification x P(x) is true.  Example: Let Q(x) = “x < 2”. What is the truth value of the quantification x Q(x), where the domain consists of all real numbers?  Sol: Because Q(x) is not true for every real number x, because, for instance, Q(3) is false. That is, x=3 is a counterexample for the statement x Q(x).
  • 34. Predicates and Quantifiers – Universal Quantifiers 34  Q8: Let P(x) = “x2 > 0”. What is the truth value of the quantification x P(x), where the domain consists of all real numbers?  Q9: Let Q(x) = “x2 < 10”. What is the truth value of the quantification x Q(x), where the domain consists of positive integers less than 4?  Q10: 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?
  • 35. Predicates and Quantifiers – Existential Quantifiers 35  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.
  • 36. Predicates and Quantifiers – Existential Quantifiers 36  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?
  • 37. Predicates and Quantifiers – Translating English into Logical Expression 37  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.
  • 38. Predicates and Quantifiers – Quantifiers with Restricted Domain 38  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 ⌃z2 = 2).
  • 39. Predicates and Quantifiers – Quantifiers with Restricted Domain 39  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))
  • 40. Predicates and Quantifiers – Negating Quantified Expression 40  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).
  • 41. Predicates and Quantifiers – Negating Quantified Expression Negation Equivalent Statement When is Negation True? When False?  x P(x) x P(x) x P(x)  x P(x) For every x, P(x) is false There is an x for which P(x) is false There is an x for which P(x) is true P(x) is true for every x 41  De Morgan’s laws for quantifiers:
  • 42. Predicates and Quantifiers – Negating Quantified Expression 42  Example: What are the negations of the statements “There is a religious man” and “All Saudi eat Rice”?  Sol: Let P(x) = “x is a religious”, => “There is a religious man”= xP(x), where the domain consists of all men Now, xP(x) = xP(x) =“Every man is nonreligious”. Next, let Q(x) = “x eats Rice” => “All Saudi eat Rice” = xQ(x), where the domain consists of all Saudi Now,  xQ(x) = xQ(x) = “Some Saudi does not eat rice”.  Q14: What are the negations of the statements x (x2 > x) and x (x2 = 2)”?
  • 43. Predicates and Quantifiers – Negating Quantified Expression 43  Example: Let L(x) = “x is a lion”, F(x) = “x is fierce”, and C(x) = “x drinks coffee”. Show the quantifiers for the statements (i) All lions are fierce, (ii) Some lions don’t drink coffee, (iii) Some fierce creatures don’t drink coffee.  Sol: (i) x (L(x)  F(x)), ii) x (L(x)  C(x)), and (iii) x (F(x)  C(x))  Q15: Let B(x) = “x is a hummingbird”, L(x) = “x is a large bird”, H(x) = “x lives on honey”, and R(x) = “x is richly colored”. Show the quantifiers for the statements (i) All hummingbirds are richly colored, (ii) No large birds live on honey, (iii) Birds that do not live on honey are dully colored, and (iv) Not all large birds live on honey.
  • 44. Predicates and Quantifiers – Logical Equivalences 44  Example: Show that x (P(x)  Q(x)) and xP(x)  x Q(x) are logically equivalent.  Sol: Let x (P(x)  Q(x)) is true => if a is in the domain, then P(a)  Q(a) is true => P(a) and Q(a) are true, for all a in the domain => xP(x) and xQ(x) are true => xP(x)  xQ(x) is true So, they are logically equivalent.  Q16: Show that x(P(x)Q(x)) and x(P(x)  Q(x)) are logically equivalent.
  • 45. Nested Quantifiers – Definition 45  Def: Two quantifiers are said to be nested if one is within the scope of the other, such as xy (x + y = 0)  Note that xy (x + y = 0) is same as xQ(x), where Q(x) is yP(x, y), where P(x, y) is x + y = 0.  Example: Assume that the domain for the variables x and y consists of all real numbers. The statement xy (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.
  • 46. Nested Quantifiers – Example 46  Example: Similarly, the statement xy (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 xyz (x + (y + z) = (x + y) + z) is associative law for addition of real numbers.
  • 47. Nested Quantifiers – Order of Quantifiers 47  Example: Let P(x, y) be the statement “x + y = y + x”. What are the truth values of the quantifications xyP(x, y) and yxP(x, y), where the domain for all variables consists of all real numbers?  Sol: xyP(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 xyP(x, y) is also true. Also, yxP(x, y) = “For all real numbers y, for all real numbers x, x + y = y + x” = xyP(x, y).  Note: Order of nested universal quantifiers in a statement without other quantifiers can be changed without changing meaning of quantified statement.
  • 48. Nested Quantifiers – Order of Quantifiers 48  Example: Let Q(x, y) be the statement “x + y = 0”. What are the truth values of the quantifications yxQ(x, y) and xyQ(x, y), where the domain for all variables consists of all real numbers?  Sol: yxQ(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 yxQ(x, y) is false. xyQ(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, xyQ(x, y) is true.
  • 49. Nested Quantifiers – Quantification of Two Variables Statement When True? When False? xyP(x, y) yxP(x, y) P(x, y) is true for every pair x, y. There is a pair x, y for which P(x, y) is false xyP(x, y), For every x there is a y for which P(x, y) is true There is an x such that P(x, y) is false for every y xyP(x, y) There is an x such that P(x, y) is true for every y For every x there is a y for which P(x, y) is false xyP(x, y) yxP(x, y) There is a pair x, y for which P(x, y) is true P(x, y) is false for every pair x, y. 49  Q17: Let Q(x, y) = “x + y = y”. What are the truth values of the quantifications yxQ(x, y) and xyQ(x, y), where the domain for all variables consists of all real numbers?
  • 50. Nested Quantifiers – Order of Quantifiers 50  Example: Let Q(x, y, z) be the statement “x + y = z”. What are the truth values of the quantifications xyzQ(x, y, z) and zxyQ(x, y, z), where the domain for all variables consists of all real numbers?  Sol: xyzQ(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 zxyQ(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
  • 51. Nested Quantifiers – Translating Statements 51  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 xy((x > 0) ⌃ (y > 0) → (x + y > 0)), where the domain for both variables consists of integers. We can also express this as xy(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.
  • 52. Nested Quantifiers – Translating From Nested Quantifiers 52  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 xyz((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.