Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
147 views146 pages

Ch01 1

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 146

Discrete Structures

•  Logic, Induction and Reasoning [12 hours] [24


marks]
•  Finite State Automata [10 hours] [16 marks]
•  Recurrence Relations [8 hours] [8 marks]
•  Graph Theory [15 hours] [32 marks]

May 2012 Discrete Structures 1


Discrete Structures
•  Kenneth Rosen, “Discrete Mathematical
Structures with Applications for Computer
Science”.
•  G. Birkhoff, T.C. Bartee, “ Modern Applied
Algebra”
•  R. Johnsonbaugh, “Discrete Mathematics”
•  G. Chartand, B.R. Oller Mann, “Applied and
Algorithmic Graph Theory”
•  Joe L Mott, Abrahan Kandel and Theodore P.
Bakere, “ Discrete Mathematics for
Computer Scientists and Mathematicians”
May 2012 Discrete Structures 2
Let’s get started with...

Logic!

May 2012 Discrete Structures 3


Logic
•  Crucial for mathematical reasoning
•  Important for program design
•  Used for designing electronic circuitry

•  (Propositional )Logic is a system based on


propositions.
•  A proposition is a (declarative) statement
that is either true or false (not both).
•  We say that the truth value of a proposition
is either true (T) or false (F).
•  Corresponds to 1 and 0 in digital circuits
May 2012 Discrete Structures 4
The Statement/Proposition Game

“Elephants are bigger than mice.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value


of the proposition? true

May 2012 Discrete Structures 5


The Statement/Proposition Game

“520 < 111”

Is this a statement? yes

Is this a proposition? yes

What is the truth value


of the proposition? false

May 2012 Discrete Structures 6


The Statement/Proposition Game

“y > 5”

Is this a statement? yes


Is this a proposition? no

Its truth value depends on the value of y,


but this value is not specified.
We call this type of statement a
propositional function or open sentence.
May 2012 Discrete Structures 7
The Statement/Proposition Game

“Today is January 27 and 99 < 5.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value


of the proposition? false

May 2012 Discrete Structures 8


The Statement/Proposition Game

“Please do not fall asleep.”

Is this a statement? no
It’s a request.

Is this a proposition? no

Only statements can be propositions.

May 2012 Discrete Structures 9


The Statement/Proposition Game
“If the moon is made of cheese,
then I will be rich.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value


of the proposition? probably true

May 2012 Discrete Structures 10


The Statement/Proposition Game
“x < y if and only if y > x.”
Is this a statement? yes
Is this a proposition? yes
… because its truth value
does not depend on
specific values of x and y.
What is the truth value
of the proposition? true
May 2012 Discrete Structures 11
Combining Propositions

As we have seen in the previous examples,


one or more propositions can be combined
to form a single compound proposition.

We formalize this by denoting propositions


with letters such as p, q, r, s, and
introducing several logical operators or
logical connectives.

May 2012 Discrete Structures 12


Logical Operators (Connectives)
We will examine the following logical operators:

•  Negation (NOT, ¬)
•  Conjunction (AND, ∧)
•  Disjunction (OR, ∨)
•  Exclusive-or (XOR, ⊕ )
•  Implication (if – then, → )
•  Biconditional (if and only if, ↔ )
• Truth tables can be used to show how these operators can
combine propositions to compound propositions.
May 2012 Discrete Structures 13
Negation (NOT)

Unary Operator, Symbol: ¬

P ¬ P
true (T) false (F)
false (F) true (T)

May 2012 Discrete Structures 14


Conjunction (AND)
Binary Operator, Symbol: ∧

P Q P∧Q
T T T
T F F
F T F
F F F

May 2012 Discrete Structures 15


Disjunction (OR)
Binary Operator, Symbol: ∨

P Q P∨ Q
T T T
T F T
F T T
F F F

May 2012 Discrete Structures 16


Exclusive Or (XOR)
Binary Operator, Symbol: ⊕

P Q P⊕Q
T T F
T F T
F T T
F F F

May 2012 Discrete Structures 17


Implication (if - then)
Binary Operator, Symbol: →
p is hypothesis (antecedent or premise and q is
conclusion or consequence)

P Q P→Q
T T T
T F F
F T T
F F T
May 2012 Discrete Structures 18
Implication (if - then)
v if p, then q.
v if p, q.
v p is sufficient for q.
v q if p.
v q when p.
v a necessary condition for p is q.
v p implies/causes q.
May 2012 Discrete Structures 19
Implication (if - then)
v p only if q.
v a sufficient condition for q is p.
v q whenever p.
v q is necessary for p.
v q follows from p.
v q unless ¬p
v q when p.
May 2012 Discrete Structures 20
Implication (if - then)
Example: Implication in various forms
v If today is rainy, then the flowers will grow well.
v If the gas pedal is pressed deeper, the car moves fast.
v Ice melted in north and south pole causes the increase
of sea level.
v He is willing to go if he is given travel allowance.
v Ahmad can take Factory Layout only if he already
passed Discrete Mathematics.
v The sufficient condition for a gas station to explode is
small cigarette sparks.

May 2012 Discrete Structures 21


Implication (if - then)
Example: Implication in various forms
v The necessary condition for Indonesia to win the
WorldCupTM is by hiring a famous foreign trainer.
v It is necessary to have a valid password to log in to
the server.
Solution:
Ø A valid password is necessary to log in to the server.
Ø If you have logged in to the server then you must have a
valid password.
v You will reach the summit unless you bring your climb
too late.

May 2012 Discrete Structures 22


Implication (if - then)
Example: Implication in various forms
v To get tenure as a professor, it is sufficient to be
world-famous.
Solution:
Ø If you are world-famous then you will get tenure as a
professor.
v It is necessary to walk 8 miles to get to the top of
Long's Peak.
Solution:
Ø 8 miles walk is necessary to get to the top of Long's
Peak.
Ø If you get to the top of Long's Peak then you must have
walked 8 miles.
May 2012 Discrete Structures 23
Implication (if - then)
Example: Implication in various forms
v What is the value of the variable x after the
statement
Ø if 2 + 2 = 4 then x := x + 1
v if x = 0 before this statement is encountered?

May 2012 Discrete Structures 24


Implication (if - then)
Converse, Contrapositive, and Inverse
v The proposition q → p is called the converse of p → q.
v The contrapositive of p → q is the proposition ¬q → ¬p.
v The proposition ¬p → ¬q is called the inverse of p → q.
Example
v What are the contrapositive, the converse, and the
inverse of the implication
Ø “The home team wins whenever it is raining.”?

May 2012 Discrete Structures 25


Implication (if - then)
Solution
v The implication p → q is written as
Ø “If it is raining, then the home team wins.”
Consequently, the contrapositive, the converse, and the
inverse of this implication are
v “If the home team does not win, then it is not raining.”,
v “If the home team wins, then it is raining.”,
v “If it is not raining, then the home team does not win.”,
respectively.
Only the contrapositive is equivalent to the original
implication.

May 2012 Discrete Structures 26


Biconditional (if and only if)
Binary Operator, Symbol: ↔

P Q P↔Q
T T T
T F F
F T F
F F T

May 2012 Discrete Structures 27


Biconditional (if and only if)
Example
You can take the flight if and only if you buy a ticket.

v p is necessary and sufficient for q


v q is necessary and sufficient for p
v p iff q
v q iff p
v if p then q and conversely.

May 2012 Discrete Structures 28


Exercises
•  To take discrete mathematics, you must have
taken calculus or a course in computer science.
•  When you buy a new car from Acme Motor
Company, you get $2000 back in cash or a 2%
car loan.
•  School is closed if more than 2 feet of snow
falls or if the wind chill is below -100.

May 2012 Discrete Structures 29


Exercises
•  To take discrete mathematics, you must have
taken calculus or a course in computer science.
–  P: take discrete mathematics
–  Q: take calculus
–  R: take a course in computer science
•  P → Q ∨ R

May 2012 Discrete Structures 30


Exercises
•  When you buy a new car from Acme Motor
Company, you get $2000 back in cash or a 2%
car loan.
–  P: buy a car from Acme Motor Company
–  Q: get $2000 cash back
–  R: get a 2% car loan

•  P → Q ⊕R
•  Why use XOR here? – example of ambiguity of
natural languages
May 2012 Discrete Structures 31
Exercises
•  School is closed if more than 2 feet of snow
falls or if the wind chill is below -100.
–  P: School is closed
–  Q: 2 feet of snow falls
–  R: wind chill is below -100

•  Q ∨ R → P
•  Precedence among operators:
¬, ∧, ∨, →, ↔

May 2012 Discrete Structures 32


Exercises
•  You can access the internet from campus only
if you are a computer science major or you are
not a freshman.
•  The automated replay cannot be sent when
the file system is full.
•  You cannot ride the roller coaster if you are
under 4 feet tall unless you are older than 16
years old.

May 2012 Discrete Structures 33


Exercises
•  Example
•  You can access the internet from campus only if you
are a computer science major or you are not a
freshman.
•  Solution
•  a → (c ∨ ¬f ).
•  where a = “You can access the Internet from campus”
•  c = “You are a computer science major”
•  f = “You are a freshman”

May 2012 Discrete Structures 34


Exercises
•  Example
•  The automated replay cannot be sent when the file
system is full.
•  Solution
•  p → ¬q
where
•  q = “The automated reply can be sent”
•  p = “The file system is full”

May 2012 Discrete Structures 35


Exercises
•  You cannot ride the roller coaster if you are under 4
feet tall unless you are older than 16 years old.
Solution
•  (r∧¬s) → ¬q
where q: You can ride the roller coaster.
r: You are under 4 feet tall.
s: You are older than 16 years old.

May 2012 Discrete Structures 36


Exercises
•  Example
•  Determine whether these system specifications are
consistent
•  The diagnostic message is stored in the buffer or it is
retransmitted.
•  The diagnostic message is not stored in the buffer.
•  If the diagnostic message is stored in the buffer,
then it is retransmitted.
•  Solution
•  The specifications can then be written as p ∨ q, ¬p,
and p → q, where
May 2012 Discrete Structures 37
Exercises
•  p = “The diagnostic message is stored in the buffer”
•  q = “The diagnostic message is retransmitted”
•  These specifications are consistent since they are all
true when p is false and q is true.

•  Example
•  Do the system specifications in the above example
remain consistent if the specification “The diagnostic
message is not retransmitted” is added?
•  NO

May 2012 Discrete Structures 38


Statements and Operations
Statements and operators can be combined in any
way to form new statements.

P Q P∧Q ¬(P∧Q) (¬P)∨(¬Q)

T T T F F
T F F T T
F T F T T
F F F T T
May 2012 Discrete Structures 39
Equivalent Statements
P Q ¬(P∧Q) (¬P)∨(¬Q) ¬(P∧Q)↔(¬P)∨(¬Q)

T T F F T
T F T T T
F T T T T
F F T T T
The statements ¬(P∧Q) and (¬P) ∨ (¬Q) are logically
equivalent, since they have the same truth table, or put
it in another way, ¬(P∧Q) ↔(¬P) ∨ (¬Q) is always true.
May 2012 Discrete Structures 40
Tautologies and Contradictions
•  A tautology is a statement that is always true.
Examples:
–  R∨(¬R)
  ¬(P∧Q) ↔ (¬P)∨(¬ Q)
•  A contradiction is a statement that is always false.
Examples:
–  R∧(¬R)
  ¬(¬(P ∧ Q) ↔ (¬P) ∨ (¬Q))
•  The negation of any tautology is a contradiction, and
the negation of any contradiction is a tautology.
•  A compound proposition that is neither a tautology
nor a contradiction is called a contingency.
May 2012 Discrete Structures 41
Equivalence
Definition: two propositional statements
S1 and S2 are said to be (logically)
equivalent, denoted S1 ≡ S2 if
–  They have the same truth table, or
–  S1 ⇔ S2 is a tautology
Equivalence can be established by
–  Constructing truth tables
–  Using equivalence laws

May 2012 Discrete Structures 42


Equivalence
Equivalence laws
–  Identity laws, P ∧ T ≡ P,
–  Domination laws, P ∧ F ≡ F,
–  Idempotent laws, P ∧ P ≡ P,
–  Double negation law, ¬ (¬ P) ≡ P
–  Commutative laws, P ∧ Q ≡ Q ∧ P,
–  Associative laws, P ∧ (Q ∧ R)≡ (P ∧ Q) ∧ R,
–  Distributive laws, P ∧ (Q ∨ R)≡ (P ∧ Q) ∨ (P ∧ R),
–  De Morgan’s laws, ¬ (P∧Q) ≡ (¬ P) ∨ (¬ Q)
–  Law with implication P → Q ≡ ¬ P ∨ Q

May 2012 Discrete Structures 43


Equivalence

May 2012 Discrete Structures 44


Equivalence

May 2012 Discrete Structures 45


Exercises
•  Show that P → Q ≡ ¬ P ∨ Q: by truth table
•  Show that (P → Q) ∧ (P → R) ≡ P → (Q ∧ R):
by equivalence laws :
–  Law with implication on both sides
–  Distribution law on LHS

May 2012 Discrete Structures 46


Exercises
Show that
v ¬(p∨q) and ¬p∧¬q
v p→q and ¬p∨q
v p∨ (q∧r) and (p∨q)∧(p∨r)
v ¬(p∨ (¬p∧q)) and ¬p∧¬q
are logically equivalent.
 
Show that (p∧q)→(p∨q) is a tautology.

May 2012 Discrete Structures 47


Predicates
A Predicate is a declarative sentence whose true/false
value depends on one or more variables.
The statement “x is greater than 3” has two parts:
v the subject: x is the subject of the statement
v the predicate: “is greater than 3” (a property that the
subject can have).
We denote the statement “x is greater than 3” by P (x),
where P is the predicate “is greater than 3” and x is the
variable.
The statement P(x) is also called the value of
propositional function P at x.

May 2012 Discrete Structures 48


Predicates
Assign a value to x, so P(x) becomes a proposition and has a truth
value:
v  P (5) is the statement “5 is greater than 3”, so P (5) is true.
v  P (2) is the statement “2 is greater than 3”, so P (2) is false.
Prime(x) = “x is a prime number.”
v  Prime(2) is true, since the only numbers that divide 2 are 1 and
itself.
v  Prime(9) is false, since 3 divides 9.
C(x, y)=“x is the capital of y”.
v  C(Ottawa,Canada) is true.
v  C(Buenos Aires,Brazil) is false.
E(x, y, z) = “x + y = z”.
v  E(2, 3, 5) is ...
v  E(4, 4, 17) is ...

May 2012 Discrete Structures 49


Propositional Functions & Predicates
Propositional function (open sentence):
statement involving one or more variables,
e.g.: x-3 > 5.
Let us call this propositional function P(x), where
P is the predicate and x is the variable.
What is the truth value of P(2) ? false
What is the truth value of P(8) ? false
What is the truth value of P(9) ? true
When a variable is given a value, it is said to be
instantiated
Truth value depends on value of variable
May 2012 Discrete Structures 50
Propositional Functions
Let us consider the propositional function
Q(x, y, z) defined as:
x + y = z.
Here, Q is the predicate and x, y, and z are the
variables.
What is the truth value of Q(2, 3, 5) ? true
What is the truth value of Q(0, 1, 2) ? false
What is the truth value of Q(9, -9, 0) ? true
A propositional function (predicate) becomes a
proposition when all its variables are instantiated.
May 2012 Discrete Structures 51
Propositional Functions
Other examples of propositional functions

Person(x), which is true


Person(Socrates) = Tif x is a person
Person(dolly-the-sheep) = F
CSCourse(x), which is true if x is a
computer science course
CSCourse(CMSC201) = T
CSCourse(MATH155) = F
How do we say
All humans are mortal
One CS course
May 2012 Discrete Structures 52
Universal Quantification
The universal quantification of P (x) is the statement:
“P(x) for all values of x in the domain” denoted ∀xP(x).
u ∀xP (x) is true when P (x) is true for every x in the domain.
u ∀xP (x) is false when there is an x for which P (x) is false.
Ø An element for which P (x) is false is called a
counterexample of ∀xP (x).
Ø If the domain is empty, ∀xP(x) is true for any propositional
function P (x), since there are no counterexamples in the
domain.
Ø If the domain is finite {x1,x2,...,xn}, ∀xP(x) is the same as
P(x1)∧P(x2)∧···∧P(xn).

May 2012 Discrete Structures 53


Universal Quantification
Let P(x) be “x2 > 10′′. What is the truth value of ∀xP (x) for
each of the following domains:
v the set of real numbers: R
² False. 3 is a counterexample.
v the set of positive integers not exceeding 4: {1, 2, 3, 4}
² False. 3 is a counterexample.
Also note that here ∀P(x) is P(1) ∧ P(2) ∧ P(3) ∧ P(4), so its
enough to observe that P(3) is false.
v the set of real numbers in the interval [10, 39.5]
² True. It takes a bit longer to verify than in false statements.
Let x ∈ [10,39.5]. Then x ≥ 10 which implies x2 = 102 = 100 >
10, and so x2 > 10.

May 2012 Discrete Structures 54


Universal Quantification
Let P(x) be a predicate (propositional function).

Universally quantified sentence:


For all x in the universe of discourse P(x) is true.

Using the universal quantifier ∀:


∀x P(x) “for all x P(x)” or “for every x P(x)”

(Note: ∀x P(x) is either true or false, so it is a


proposition, not a propositional function.)

May 2012 Discrete Structures 55


Universal Quantification
Example: Let the universe of discourse be all
people
S(x): x is a UMBC student.
G(x): x is a genius.
What does ∀x (S(x) → G(x)) mean ?
“If x is a UMBC student, then x is a genius.” or
“All UMBC students are geniuses.”
If the universe of discourse is all UMBC students,
then the same statement can be written as
∀x G(x)
May 2012 Discrete Structures 56
Existential Quantification
The existential quantification of P (x) is the statement:
“There exists an element x in the domain such that P (x)”
denoted ∃xP (x).
u ∃xP (x) is true when P (x) is true for one or more x in the
domain.
u An element for which P (x) is true is called a witness of ∃xP
(x).
Ø ∃xP (x) is false when P (x) is false for every x in the domain
(if domain nonempty).
Ø If the domain is empty, ∃xP(x) is false for any propositional
function P (x), since there are no witnesses in the domain.
Ø If the domain is finite {x1,x2,...,xn}, ∃xP(x) is the same as
P(x1)∨P(x2)∨···∨P(xn).

May 2012 Discrete Structures 57


Existential Quantification
Let P(x) be “x2 > 10′′. What is the truth value of ∃xP (x) for
each of the following domains:
v the set of real numbers: R
² True. 10 is a witness.
v the set of positive integers not exceeding 4: {1, 2, 3, 4}
² True. 4 is a witness.
v Also note that here ∃P(x) is P(1) ∨ P(2) ∨ P(3) ∨ P(4), so
its enough to observe that P(4) is true.
v the set of real numbers in the interval [0,√9.8]
² False. It takes a bit longer to conclude than in true
statements.
Let x ∈ [0, 9.8]. Then 0 ≤ x ≤(√9.8) which implies x2 ≤ (√9.8)2=9.8 <
10, and so x2 <10. What we have shown is that ∀x¬P (x), which (we
will see) is equivalent to ¬∃xP(x)
May 2012 Discrete Structures 58
Existential Quantification
Existentially quantified sentence:
There exists an x in the universe of discourse
for which P(x) is true.

Using the existential quantifier ∃:


∃x P(x) “There is an x such that P(x).”
“There is at least one x such that P(x).”

(Note: ∃x P(x) is either true or false, so it is a


proposition, but no propositional function.)

May 2012 Discrete Structures 59


Existential Quantification
Example:
P(x): x is a UMBC professor.
G(x): x is a genius.

What does ∃x (P(x) ∧ G(x)) mean ?

“There is an x such that x is a UMBC professor


and x is a genius.”
or
“At least one UMBC professor is a genius.”

May 2012 Discrete Structures 60


Quantification

May 2012 Discrete Structures 61


Quantification
Another example:
Let the universe of discourse be the real numbers.

What does ∀x∃y (x + y = 320) mean ?

“For every x there exists a y so that x + y = 320.”

Is it true? yes

Is it true for the natural numbers? no

May 2012 Discrete Structures 62


Disproof by Counterexample
A counterexample to ∀x P(x) is an object c so
that P(c) is false.

Statements such as ∀x (P(x) → Q(x)) can be


disproved by simply providing a counterexample.

Statement: “All birds can fly.”


Disproved by counterexample: Penguin.

May 2012 Discrete Structures 63


Restricting the domain of a quantifier
Abbreviated notation is allowed, in order to restrict the
domain of certain quantifiers.
∀x>0(x2 >0)is the same as ∀x(x>0→x2 >0).
∀y≠0(y3≠ 0)is the same as ∀y(y≠0→y3≠ 0).
∃z>0(z2 =2)is the same as ∃z(z>0∧ z2 =2)

May 2012 Discrete Structures 64


Logical Equivalences Involving Quantifiers

Definition
Two statements S and T involving predicates and
quantifiers are logically equivalent if and only if they
have the same truth value regardless of the
interpretation, i.e. regardless of
the meaning that is attributed to each propositional
function,
the domain of discourse. We denote S ≡ T.
Is ∀x(P (x) ∧ Q(x)) logically equivalent to ∀xP (x) ∧
∀xQ(x) ?
Is ∀x(P (x) ∨ Q(x)) logically equivalent to ∀xP (x) ∨
∀xQ(x) ?
May 2012 Discrete Structures 65
Logical Equivalences Involving Quantifiers

Prove that ∀x(P (x) ∧ Q(x)) is logically equivalent to


∀xP (x) ∧ ∀xQ(x) (where the same domain is used
throughout). Use two steps:
If ∀x(P (x) ∧ Q(x)) is true, then ∀xP (x) ∧ ∀xQ(x) is
true.
Proof: Suppose ∀x(P (x) ∧ Q(x)) is true.
Then if a is in the domain, P(a) ∧ Q(a) is true, and so P(a)
is true and Q(a) is true. So, if a in in the domain P(a) is
true, which is the same as ∀xP(x) is true; and similarly,
we get that ∀xQ(x) is true.
This means that ∀xP (x) ∧ ∀xQ(x) is true.

May 2012 Discrete Structures 66


Logical Equivalences Involving Quantifiers

If ∀xP (x) ∧ ∀xQ(x) is true, then ∀x(P (x) ∧ Q(x)) is


true.
Proof: Suppose that ∀xP (x) ∧ ∀xQ(x) is true.
It follows that ∀xP (x) is true and ∀xQ(x) is true. So, if
a is in the domain, then P (a) is true and Q(a) is true. It
follows that if a is in the domain P (a) ∧ Q(a) is true.
This means that ∀x(P (x) ∧ Q(x)) is true.

May 2012 Discrete Structures 67


Logical Equivalences Involving Quantifiers

Prove that ∀x(P (x) ∨ Q(x)) is not logically equivalent to


∀xP (x) ∨ ∀xQ(x).
It is enough to give a counterexample to the assertion
that they have the same truth value for all possible
interpretations.
Under the following interpretation: domain: set of people
in the world P (x) =“x is male”. Q(x) =“x is female”.
We have: ∀x(P (x) ∨ Q(x)) (every person is a male or a
female) is true; while ∀xP (x) ∨ ∀xQ(x) (every person
is a male or every person is a female) is false.

May 2012 Discrete Structures 68


Translating sentences into logical expressions
Express the statements “Every student in the class has
studied calculus.” using quantifiers.

“For every student in this class, that student has studied


calculus.”

Introducing variable 'x'


“For every student x in this class, x has studied calculus.”

Let C(x) is the statement “x has studied calculus”.


If the domain of x consists of the students in the class then
∀xC(x).

May 2012 Discrete Structures 69


Translating sentences into logical expressions

However, if the domain consist of all the people


“For every person x, if person x is a student in this class then
x has studied calculus.”
If S(x) represents the statement that “Person x is in this
class” then
∀x(S(x)→C(x))
Our statement cannot be expressed as
∀x(S(x) ∧ C(x)) because this statement says that all people
are student in this class and have studied calculus.
If Q(x,y) is the statement that “student x has studied the
subject y” then
∀xQ(x, calculus)
∀x(S(x)→Q(x, calculus))
May 2012 Discrete Structures 70
Translating sentences into logical expressions

Express the statements


“Some student in this class has visited Mexico” using
quantifiers.
“Some student in this class has visited Mexico” means
“There is a student in this class with the property that the
student has visited Mexico”
Introducing variable 'x'
“There is a student x in this class with the property that x
has visited Mexico”
Let M(x) be the statement “x has visited Mexico” and if the
domain of x consists of student in this class then
∃xM(x)

May 2012 Discrete Structures 71


Translating sentences into logical expressions

But if we are interested in other people then


“There is a person x having the properties that x is a student
in this class and x has visited Mexico”
Let S(x) represents the statement “x is a student in this
class” and the solution will be
∃x(S(x) ∧ M(x))
Our statement cannot be expressed as
∃x(S(x)→M(x)), which is true when there is someone not in the
class because, in that case, for such a person x, S(x)→M(x) becomes
either F→T or F→F, both of which are true.
If V(x, y) represents the statement that “x has visited
country y” then
∃xV(x, Mexico)
∃x(S(x) ∧ V(x, Mexico))
May 2012 Discrete Structures 72
Translating sentences into logical expressions

Express the statements


“Every student in this class has visited either Canada or
Mexico”. using quantifiers.
By introducing the variable 'x' , this can be written as
For every x in this class, x has the property that x has visited
Canada or x has visited Mexico.
C(x) be the statement “x has visited Canada”
∀x(C(x) ∨ M(x)) if the domain of x is the students in the
class
But if the domain of x is other people then
“For every person x, if x is a student in this class then x has
visited Canada or x has visited Mexico.”
∀x(S(x)→(C(x) ∨ M(x)))
May 2012 Discrete Structures 73
Translating sentences into logical expressions

If V(x, y) represents the statement that “x has visited


country y” then
∀x(V(x, Canada) ∨ V(x, Mexico))
∀x(S(x)→(V(x, Canada) ∨ V(x, Mexico)))

May 2012 Discrete Structures 74


Translating sentences

Translate the statement


∀x(C(x)∨∃y(C(y) ∧ F(x,y)) into English, where C(x) is
“x has a computer,” F(x,y) is “x and y are friends,” and
the universe of discourse for both x and y is the set of
all students in your school.

For every student x in your school x has a computer or


there is a student y such that y has a computer and x and
y are friends. In other words, every student in your
school has a computer or has a friend who has a
computer.

May 2012 Discrete Structures 75


Translating sentences

Translate the statement


∃x∀y∀z(((F(x,y) ∧ F(x,z) ∧ (y≠z))→¬F(y,z))) or
∃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
universe of discourse for x, y and z is the set of all
students in your school.

There is a student x such that for all students y and all


students z other than y, if x and y are friends and x and
z are friends, then y and z are not friends. In other
words, there is a student none of whose friends are also
friends with each other.

May 2012 Discrete Structures 76


Translating sentences

Assuming that the universe of discourse for the


variables x and y is the set of al real numbers.
The statements
v ∀x∀y(x+y = y+x)
says that x+y = y+x for all real numbers x and y. This is
the commutative law for addition for real numbers.
v ∀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.
v ∀x∀y∀z(x+(y+z)=(x+y)+z)
is the associative law for addition of real numbers.
May 2012 Discrete Structures 77
Translating sentences

Translate the following statements:

“The sum of two positive integers is always positive.”


∀x∀y(x+y>0)

“Every real number except zero has a multiplicative


inverse.”
(a multiplicative inverse of x is y such that xy = 1).
∀x((x≠0)→∃y(xy=1))

May 2012 Discrete Structures 78


Translating sentences

Express the statement “Everyone has exactly one best


friend” as a logical expression

Let B(x,y) be a statement “y is the best friend of x.”


For every person x there is another person y such that y
is the best friend of x and that if z is a person other
than y, then z is not the best friend of x.

∀x∃y∀z(B(x,y) ∧ ((z≠y)→¬B(x,z))).

May 2012 Discrete Structures 79


Translating sentences

Express the statement “If somebody is female and is a


parent, then this person is someone's mother” as a logical
expression

Let F(x) be the statement “x is female,” let P(x) be the


statement “x is a parent,” and let M(x,y) be the
statement “x is the mother of y.” Since the statement in
the example pertains to all people,

∀x((F(x) ∧ P(x))→ ∃yM(x,y))

May 2012 Discrete Structures 80


Precedence of quantifiers
∀ and ∃ have higher precedence than logical operators.
Example: ∀xP (x) ∨ Q(x) means (∀xP (x)) ∨ Q(x), it
doesn’t mean ∀x(P (x) ∨ Q(x)).
(Note: This statement is not a proposition since there is
a free variable!)

May 2012 Discrete Structures 81


Binding variables and scope
v  When a quantifier is used on the variable x we say that this
occurrence of x is bound.
v  When the occurrence of a variable is not bound by a
quantifier or set to a particular value, the variable is said to
be free.
v  The part of a logical expression to which a quantifier is
applied is the scope of the quantifier.
v  A variable is free if it is outside the scope of all
quantifiers. In the example above,
§  (∀x P(x)) ∨ Q(x), the x in P (x) is bound by the universal
quantifier, while the x in Q(x) is free. The scope of the
universal quantifier is underlined.
§  ∃x(x+y=1) where x is bounded variable and y is a free
variable.
May 2012 Discrete Structures 82
The order of quantifiers
v  Let P (x, y) be the statement “x + y = y + x”.
v  Consider the following: ∀x∀yP (x, y) and ∀y∀xP (x, y).
v  What is the meaning of each of these statements? What is
the truth value of each of these statements? Are they
equivalent?

v  Let Q(x, y) be the statement “x + y = 0”. Consider the


following: ∃y∀xQ(x, y) and ∀x∃yQ(x, y).
v  What is the meaning of each of these statements? What is
the truth value of each of these statements? Are they
equivalent?

May 2012 Discrete Structures 83


Summary of quantification of two variables

v  ∀x∀yP (x, y) and ∀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
v  ∀x∃yP (x, y)
² For every x there is y for which P (x, y) is true
² There is an x such that P (x, y) is false for every y
v  ∃x∀yP (x, y)
² There is an x for which P(x,y) is true for every y
² For every x there is a y for which P (x, y) is false.
v  ∃x∃yP (x, y) and ∃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.

May 2012 Discrete Structures 84


Summary of quantification of two variables

May 2012 Discrete Structures 85


Summary of quantification of two variables

v  Example:
v  Let Q(x,y,z) be the statement “x+y=z.” What are the truth
values of the statements ∀x∀y∃z Q(x,y,z) and ∃z
∀x∀y Q(x,y,z)?

v  ∀x∀y∃z Q(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
v  ∃z∀x∀y Q(x,y,z)
² “There is a real number z such that for all real numbers x and
for all real numbers y it is true that x+y=z.” is False, since
there is no value of z that satisfies the equation x+y=z for all
values of x and y.

May 2012 Discrete Structures 86


Negating Quantified Expressions: De Morgan Laws

v  ¬∀xP (x) ≡ ∃x¬P (x)


v  Proof: ¬∀xP(x) is true if and only if ∀xP(x) is false. Note
that ∀xP (x) is false if and only if there exists an element
in the domain for which P(x) is false. But this holds if and
only if there exists an element in the domain for which
¬P(x) is true. The latter holds if and only if ∃x¬P (x) is
true.
v  “Every student in the class has taken a course in calculus.” This
can be represented as ∀xP (x) where P(x) is the statement “x has
taken a course in calculus.”
v  Negation
v  “It is not the case that every student in the class has taken a
course in calculus.” This is equivalent to “There is a student in the
class who has not taken a course in calculus.” This can be
represented as ∃x¬P (x)
May 2012 Discrete Structures 87
Negating Quantified Expressions: De Morgan Laws

v  ¬∃xP (x) ≡ ∀x¬P (x)


v  Proof: ¬∃xP(x) is true if and only if ∃xP(x) is false. Note
that ∃xP (x) is false if and only there exists no element in
the domain for which P(x) is true. But this holds if and only
if for all elements in the domain we have P (x) is false;
which is the same as for all elements in the domain we have
¬P (x) is true. The latter holds if and only if ∀x¬P (x) is
true.
²  ¬∃xQ (x) ≡ ∀x¬Q (x)
²  “There is a student in this class who has taken a course in
calculus.” This can be represented as
²  ∃xQ(x) where Q(x) is the statement “x has taken a course
in calculus.”

May 2012 Discrete Structures 88


Negating Quantified Expressions: De Morgan Laws

v  Negation
v  “It is not the case that there is a student in this class who
has taken a course in calculus.” This is equivalent to “Every
student in this class has not taken calculus.” This can be
represented as
v  ∀x¬ Q(x)
v  When the domain has n elements x1, x2, . . . . . . . , xn , it
follows that ¬∀x P(x) is the same as ¬ ( P(x1) ∧ P(x2)
∧. . .∧P(xn )), which is equivalent to ¬P(x1) v ¬P(x2) . . .v
¬P(xn) by De Morgan's laws, and this is the same as
∃x¬P(x).
v  Similarly, ¬∃xP(x)is the same as ¬(P(x1) v P(x2) v . . . v
P(xn)), which by De Morgan's laws is equivalent to ¬P(x1) ∧
¬P(x2) ∧ . . . ∧ ¬P(xn )), and this is the same as ∀x¬P(x)
May 2012 Discrete Structures 89
Negating Quantified Expressions: De Morgan Laws

v  Practice Exercises
v  What are the negations of the following statements:
v  “There is an honest politician.”
v  “All americans eat cheeseburgers.”
v  What are the negations of ∀x(x2 > x) and ∃x(x2 = 2)? Ans:
(∃x( x2 <= x)) and ∀x( x2≠2)
v  Show that ¬∀x(P (x) → Q(x)) and ∃x(P (x) ∧ ¬Q(x)) are
logically equivalent.

May 2012 Discrete Structures 90


Negating Quantified Expressions: De Morgan Laws

Let H (x) denote "x is honest." Then the statement "There is


an honest politician" is represented by ∃x H(x), where the
domain consists of all politicians. The negation of this
statement is ¬ ∃x H(x), which is equivalent to ∀x ¬H(x).
This negation can be expressed, as "Every politician is
dishonest."
v  (Note: In English, the statement "All politicians are not
honest" is ambiguous. In common usage, this statement
often means, "Not all politicians are honest." Consequently,
we do not use this statement to express this negation.)

May 2012 Discrete Structures 91


Negating Quantified Expressions: De Morgan Laws

v  Let C(x) denote "x eats cheeseburgers." Then the


statement "All Americans eat cheese-burgers" is
represented by ∀x C(x), where the domain consists of all
Americans. The negation of this statement is ¬∀x C(x),
which is equivalent to ∃x ¬C(x).
v  This negation can be expressed in several different ways,
including "Some American does not eat cheeseburgers" and
"There is an American who does not eat cheeseburgers."

May 2012 Discrete Structures 92


Negation

¬(∀x P(x)) is logically equivalent to ∃x (¬P(x)).

¬(∃x P(x)) is logically equivalent to ∀x (¬P(x)).

This is de Morgan’s law for quantifiers

May 2012 Discrete Structures 93


Negation
Examples
Not all roses are red
¬∀x (Rose(x) → Red(x))
∃x (Rose(x) ∧ ¬Red(x))

Nobody is perfect
¬∃x (Person(x) ∧ Perfect(x))
∀x (Person(x) → ¬Perfect(x))

May 2012 Discrete Structures 94


Predicate calculus in Mathematical Reasoning

v Using predicates to express definitions.


² D(x) =“x is a prime number”
(defined term)
² P (x) =“x ≥ 2 and the only divisors of x are 1 and x”
(defining property about x)
² Definition of prime number: ∀x(D(x) ↔ P (x))

v Note that definitions in English form use if instead of


if and only if, but we really mean if and only if.

May 2012 Discrete Structures 95


Use predicates and quantifiers to express system
specifications:

v “Every mail message larger than one megabyte will be


compressed.”
² S(m,y):“mail message m is larger than y megabytes”
² C(m): “mail message m will be compressed”
² ∀m(S (m,1)→C (m))

v “If a user is active, at least one network link will be


available.”
² A(u): “User u is active.”
² S(n, x): “Network n is in state x”.
² ∃uA(u) → ∃nS(n, available)

May 2012 Discrete Structures 96


Predicate calculus in Logic Programming

Prolog is a declarative language based in predicate logic. The


program is expressed as Prolog facts and Prolog rules. Execution is
triggered by running queries over these relations.
mother_child(trude, sally).
father_child(tom, sally).
father_child(tom, erica).
father_child(mike, tom).

sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y).


parent_child(X, Y) :- father_child(X, Y).
parent_child(X, Y) :- mother_child(X, Y).
The result of the following query is given:
?- sibling(sally, erica).
Yes
May 2012 Discrete Structures 97
Rules of Inference and Formal Proofs

v Proofs in mathematics are valid arguments that


establish the truth of mathematical statements.
v An argument is a sequence of statements that end
with a conclusion.
v The argument is valid if the conclusion (final
statement) follows from the truth of the preceding
statements (premises).
v Rules of inference are templates for building valid
arguments.

May 2012 Discrete Structures 98


Valid Arguments using Propositional Logic

v Consider the following argument (sequence of


propositions):
² If the prof offers chocolate for an answer, you answer the
prof’s question.
² The prof offers chocolate for an answer.
² Therefore, you answer the prof’s question.
v Let p be “the prof offers chocolate for an answer” and
q be “you answer the prof’s question”.

May 2012 Discrete Structures 99


Valid Arguments using Propositional Logic

v The form of the above argument is:


p→q
p
----------
∴q
v The argument is valid since ((p → q) ∧ p) → q is a
tautology.

May 2012 Discrete Structures 100


Arguments, argument forms and their validity

Definition
v An argument in propositional logic is sequence of propositions. All
but the final proposition are called premises and the final
proposition is called the conclusion. An argument is valid if the truth
of all its premises implies that the conclusion is true.

v An argument form in propositional logic is a sequence of compound


propositions involving propositional variables. An argument form is
valid if no matter which propositions are substituted for the
propositional variables in its premises, if the premises are all true,
then the conclusion is true.

v In other words, an argument form with premises p1, p2, . . . , pn


and conclusion q is valid if and only if (p1 ∧ p2 ∧ · · · ∧ pn) → q is a
tautology.
May 2012 Discrete Structures 101
Rules of Inference

May 2012 Discrete Structures 102


Rules of Inference

May 2012 Discrete Structures 103


Rules of inference

Which rule of inference is used in each argument below?


Alice is a Math major. Therefore, Alice is either a Math major or a
CSI major.
Jerry is a Math major and a CSI major. Therefore, Jerry is a Math
major.
If it is rainy, then the pool will be closed. It is rainy. Therefore, the
pool is closed.
If it snows today, the university will close. The university is not
closed today. Therefore, it did not snow today.
If I go swimming, then I will stay in the sun too long. If I stay in the
sun too long, then I will sunburn. Therefore, if I go swimming, then I
will sunburn.
I go swimming or eat an ice cream. I did not go swimming. Therefore,
I eat an ice cream.

May 2012 Discrete Structures 104


Rules of inference

Determine whether the argument is valid and whether the conclusion


must be true
v If √2 > (3/2) then (√2)2 > (3/2)2 .
v We know that √2 > (3/2) . Therefore, (√2)2 = ( 2) > (3/2)2 =
(9/4) .
v Is the argument valid?
v Does the conclusion must be true?
v What is wrong?
v The argument is valid: modus ponens inference rule.
v We cannot conclude that the conclusion is true, since one of its
premises, √2 > (3/2) , is false.
v Indeed, in this case the conclusion is false, since 2 is not greater
than (9/4) = 2.25.

May 2012 Discrete Structures 105


Formal Proofs
v  A formal proof of a conclusion q given hypotheses p1,
p2, . . . , pn is a sequence of steps, each of which applies
some inference rule to hypotheses or previously proven
statements (antecedents) to yield a new true statement
(the consequent).
v  A formal proof demonstrates that if the premises are true,
then the conclusion is true.
v  A formal proof is based simply on symbol manipulation (no
need of thinking, just apply rules).
v  A formal proof is rigorous but so can be a proof that does
not rely on symbols!

May 2012 Discrete Structures 106


Formal Proofs
Show that the hypotheses:
v It is not sunny this afternoon and it is colder than
yesterday.
v We will go swimming only if it is sunny.
v If we do not go swimming, then we will take a canoe trip.
v If we take a canoe trip, then we will be home by sunset.
lead to the conclusion:
v We will be home by the sunset.
Main steps:
v Translate the statements into proposional logic.
v Write a formal proof, a sequence of steps that state
hypotheses or apply inference rules to previous steps.

May 2012 Discrete Structures 107


Formal Proofs
v It is not sunny this afternoon and it is colder than
yesterday. ¬s ∧ c
v We will go swimming only if it is sunny. w → s
v If we do not go swimming, then we will take a canoe
trip. ¬w → t
v If we take a canoe trip, then we will be home by
sunset. t → h
lead to the conclusion:
v We will be home by the sunset. h
v Where: s: “it is sunny this afternoon” c: “it is colder
than yesterday” w: “we will go swimming” t: “we will
take a canoe trip. h: “we will be home by the sunset.”
May 2012 Discrete Structures 108
6

    
   
   

Formal Proofs
+KL+
31  & 
    



 
   
  &     
< 7
   
$
 
+KL+
34+
+K+L+

#    
 

83
 
&

May 2012 Discrete Structures 109


Resolution and Automated Theorem Proving

v  We can build programs that automate the task of reasoning and


proving theorems.
v  Recall that the rule of inference called resolution is based on the
tautology:
v  ((p ∨ q) ∧ (¬p ∨ r)) → (q ∨ r)
v  If we express the hypotheses and the conclusion as clauses
(possible by CNF, a conjunction of clauses), we can use resolution
as the only inference rule to build proofs!
v  Assume r is False, then above statement becomes
v  ((p ∨ q) ∧ (¬p )) → (q )
v  If r = q
v  ((p ∨ q) ∧ (¬p ∨ q)) → (q)
v  This is used in programming languages like Prolog. It can be used
in automated theorem proving systems.

May 2012 Discrete Structures 110


7

&4     
  
L++L
Resolution and Automated Theorem Proving
  D#<#<C#E5I
7

&
    
G1"3$ 
   & 
 +  I 
 +  
>
 
 
$ 


L++L

  D#<#<C#E5I

G1"3$ 
   & 
 +  I 

 
$ 


May 2012 Discrete Structures 111


Resolution and Automated Theorem Proving

Show that the hypotheses:


v ¬s ∧ c translates to clauses: ¬s, c
v w → s translates to clause: (¬w ∨ s)
v ¬w → t translates to clause: (w ∨ t)
v t → h translates to clause: (¬t ∨ h)
lead to the conclusion:
v h (it is already a trivial clause)
v Note that the fact that p and ¬p ∨ q implies q (called
disjunctive syllogism) is a special case of resolution, since
p∨F and ¬p∨q give us F∨q which is equivalent to q.

May 2012 Discrete Structures 112


7

&
    
Resolution and Automated Theorem Proving
>
 

L++L

  D#<#<C#E5I

G1"3$ 
   & 
 +  I
 
$ 


May 2012 Discrete Structures 113


Fallacies
v  Fallacy = misconception resulting from incorrect argument.
v  Fallacy of affirming the conclusion based on
v  ((p → q) ∧ q) → p
v  which is NOT A TAUTOLOGY.
v  Example
v  If prof gives chocolate, then you answer the question.
v  You answer the question.
v  We conclude the prof gave chocolate.
v  If you do every problem in this book, then you will learn
discrete mathematics.
v  You learned discrete mathematics.
v  Therefore, you did every problem in this book.

May 2012 Discrete Structures 114


Fallacies
v  Fallacy of denying the hypothesis based on
v  ((p → q) ∧ ¬p) → ¬q
v  which is NOT A TAUTOLOGY.
v  Example
v  If prof gives chocolate, then you answer the question.
v  Prof doesn’t give chocolate.
v  Therefore, you don’t answer the question.
v  If you do every problem in this book, then you will learn
discrete mathematics.
v  You did not do every problem in this book
v  Therefore, you didn't learn discrete mathematics.

May 2012 Discrete Structures 115


 
 "
<    <  
 
 
Rules of Inference for Quantified Statements
G$&   <  
  1

&    
  
  1

 
 
<1"@1  <  A
>1"@1
 A
81"@1
  1
A
/& "1<1K>1
1<1L81
!   "181K>1

/& "1<1K>1
1<1L81!  

May 2012 Discrete Structures 116


Rules of Inference for Quantified Statements

Show that the premises:


v A student in Section A of the course has not read the book.
v Everyone in Section A of the course passed the first exam.
imply the conclusion
v Someone who passed the first exam has not read the book.
v A(x): “x is in Section A of the course”
v B(x): “x read the book”
v P(x): “x passed the first exam.”
v Hypotheses: ∃x(A(x) ∧ ¬B(x)) and ∀x(A(x) → P (x)).
v Conclusion: ∃x(P(x)∧¬B(x)).

May 2012 Discrete Structures 117


$
 
   $   

    
&  

   
& 

Rules of Inference for Quantified Statements


     
 1&
 

   $)

%  

 

    

 
 
  
<


    


1
& $

 

May 2012 Discrete Structures 118


Combining Rules of Inference for Propositions
$
 and Quantified

   $ 
Statements
    
&  

   
     
 1&
 

   $)

%  

 

   

 
 
  
<


    


1
 

May 2012 Discrete Structures 119


Proof Methods
v A proof is a valid argument that establishes the truth
of a mathematical statement, using the hypotheses of
the theorem, if any, axioms assumed to be true, and
previously proven theorems.
v Using these ingredients and rules of inference, the
proof establishes the truth of the statement being
proved.
v We move from formal proofs, as seen in the previous
section, to informal proofs, where more than one
inference rule may be used at each step, where steps
may be skipped, and where axioms and rules of
inference used are not explicitly stated.

May 2012 Discrete Structures 120


Proof Methods
Some terminology
v Theorem: a statement that can be shown to be true
(sometimes referred to as facts or results). Less
important theorems are often called propositions.
v A lemma is a less important theorem, used as an
auxiliary result to prove a more important theorem.
v Let a=bq+r where a, b, q and r are integers. Then gcd
(a, b) = gcd (b, r) [Example: - Lemma]
v A corollary is a theorem proven as an easy consequence
of a theorem.
v A conjecture is a statement that is being proposed as a
true statement. If later proven, it becomes a theorem,
but it may be false.
May 2012 Discrete Structures 121
Proof Methods
Some terminology
v Axiom (or postulates) are statements that we assume
to be true (algebraic axioms specify rules for arithmetic
like commutative laws).
v A proof is a valid argument that establishes the truth
of a theorem. The statements used in a proof include
axioms, hypotheses (or premises), and previously proven
theorems. Rules of inference, together with definition of
terms, are used to draw conclusions from other
assertions, tying together the steps of a proof.

May 2012 Discrete Structures 122


Proof Methods
Understanding how theorems are stated
Many theorems assert that a property holds for all
elements in a domain. However, the universal quantifier is
often not explicitly stated.
The statement:
“If x > y, where x and y are positive real numbers, then
x2 > y2.”
really means
“For all positive real numbers x and y, if x > y then x2 >
y2.”
That is, in formal logic under the domain of positive real
numbers this is the same as ∀x∀y((x > y) → (x2 > y2)).
May 2012 Discrete Structures 123
Proof Methods
v  Methods of proving theorems
v  To prove a theorem of the form ∀x(P (x) → Q(x)), we use
the steps:
v  Take an arbitrary element c of the domain and show that (P
(c) → Q(c)) is true.
v  Apply universal generalization to conclude ∀x(P (x) →
Q(x)). (Normally we not even bother with this final step.)

May 2012 Discrete Structures 124


Proof Methods
v  3 methods of showing statements of the type p → q are
true:
v  (1) Direct proofs: Assume p is true; the last step
establishes q is true.
v  (2) Proof by Contraposition: Uses a direct proof of the
contrapositive of p → q, which is ¬q → ¬p. That is, assume
¬q is true; the last step established ¬p is true.
v  (3) Proof by Contradiction: To prove that P is true, we
assume ¬P is true and reach a contradiction, that is that (r
∧ ¬r) is true for some proposition r. In particular, to prove
(p → q), we assume (p → q) is false, and get as a
consequence a contradiction. Assuming that (p → q) is false
= (¬p ∨ q) is false = (p ∧ ¬q) is true.

May 2012 Discrete Structures 125


Direct Proof
v  A formal direct proof of a conditional statement p → q
works as follows:
v  Assume p is true, build steps using inference rules, with the
final step showing that q is true.
v  In a (informal) direct proof, we assume that p is true, and
use axioms, definitions and previous theorems, together
with rules of inference to show that q must be true.

v  Definition
v  The integer n is even if there exists an integer k such that
n = 2k, and n is odd if there exists an integer k such that n
= 2k + 1.

May 2012 Discrete Structures 126


Direct Proof
v  Give a direct proof of the following theorem.
v  Theorem
v  If n is an odd integer, then n2 is odd.
v  Observations: We want to show that ∀n(P (n) → Q(n)),
where P (n) is “n is an odd integer” and Q(n) is “n2 is odd”.
We show this by proving that for an arbitrary n, P (n)
implies Q(n), without invoking the universal generalization.
v  Proof:
v  Let n be an odd integer. By definition of odd, we know that
there exists an integer k such that n = 2k + 1. Squaring both
sides of the equation, we get n2 =(2k+1)2=4k2 +4k+1
v  =2(2k2+2k)+1. Since n2=2k′+1,where k′ =2k2+2k, by the
definition of odd we conclude n2 is odd.

May 2012 Discrete Structures 127


Direct Proof
v  Definition
v  An integer a is a perfect square if there is an integer b
such that a = b2.
v  Prove the following theorem using a direct proof.
v  Theorem
v  If m and n are both perfect squares, then mn is also a
perfect square.
v  Let hypothesis be true, i.e., m and n be both perfect
squares. Then, we can represent m and n as follows
v  m=s2 and n=t2
v  mn = s2 t2 = (st)2
v  Hence mn is also a perfect square.

May 2012 Discrete Structures 128


Proof by Contraposition
v  This method of proof makes use of the equivalence (p → q) ≡ (¬q
→ ¬p).
v  In a proof by contraposition that p → q, we assume ¬q is true, and
using axioms, definitions and previously proven theorems,
together with inference rules, we show that ¬p must be true.
v  (It is a direct proof of the contrapositive statement!)
v  Theorem
v  If n is an integer and 3n+2 is odd, then n is odd.
v  Proof: We prove the statement by contraposition.
v  Assume n is even (assuming ¬q). Then, by definition, n = 2k for
some integer k. Thus, 3n+2=3(2k)+2=6k+2=2(3k+1). So, we have
that 3n+2=2k′ where k′ =3k+1,which means 3n+2 is an even number.
This is the negation of the hypothesis of the theorem (¬p), which
concludes our proof by contraposition.

May 2012 Discrete Structures 129


Proof by Contraposition
v Prove that if n = ab, where a and b are positive
integers, then a ≤ √n or b ≤ √n.

v Let q be a ≤ √n or b ≤ √n and assume that q is false .


This gives us that a ≤ √n is false and b ≤ √n is false.
Then ¬q which is a > √n and b > √n is true.
v ab > √n*√n=n, i.e., ab > n. Thus, n ≠ ab. This mean ¬p is
true.
v This completes the proof.
v Because the negation of the conclusion of the
conditional statement implies that hypothesis is false,
the original conditional statement is true.
May 2012 Discrete Structures 130
Vacuous Proofs
v We can quickly prove that a conditional statement p →
q is true when we know that p is false, because p → q
must be true when p is false. Consequently, if we can
show that p is false, then we have a proof, called a
vacuous proof, of the conditional statement p → q.
v Show that the proposition P(0) is true where the
domain consists of the integer numbers and P(n) is “If
n ≥ 1 then n2 > n.” Note: vacuous proof: when p is false p
→ q is true, regardless of the value of q.
v Solution:
v Note that P(0) is “If 0 > 1, then 02 > 0.” We can show
P(0) using a vacuous proof, because the hypothesis 0 >
1 is false. Hence P(0) is automatically true.
May 2012 Discrete Structures 131
Trivial Proof:
v A proof of p → q that uses the fact that q is true is
called trivial proof.
v Let P(n) be “if a and b are positive integers with a ≥ b,
then an ≥ bn, where the domain consists of all integers.
Show that P(0) is true.
v The proposition P(0) is “If a ≥ b, then a0 ≥ b0 ” Because
a0 = b0 =1, the conclusion of the given conditional
statement is true.
v When to use each type of proof?
v Usually try a direct proof. If it doesn’t work, try a
proof by contraposition.

May 2012 Discrete Structures 132


Proofs
v  Definition
v  A real number r is rational if there exists integers p and q
with q ≠ 0 such that r = p/q. A real number that is not
rational is called irrational
v  Prove that the sum of two rational numbers is rational.
v  (For all r, s ∈ R , if r and s are rational numbers, then r + s
is rational.)
v  Let r and s be rational numbers. Then, there exist integers
p, q, t, u with q ≠ 0 and u ≠ 0 such that r =p/q and s=t/u. So,
v  r + s = p/q + t/u = (pu + qt) / qu
v  Since q≠0 and u≠0, we have qu≠0. Therefore,we expressed r
+s as the ratio of two integers pu + qt and qu, where qu ≠ 0.
This means that r + s is rational.
v  (The direct proof succeeded!)
May 2012 Discrete Structures 133
Proofs
v  Prove that for any integer number n, if n2 is odd, then n is
odd.
v  Trying a direct proof…
v  Let n be an integer number. Assume that n2 is odd. We get
next that there exists an integer k such that n2 = 2k + 1.
Solving for n produces the equation n = ±√(2k + 1), which is
not very useful to show that n is odd.
v  Try a prove by contraposition...
v  Let n be an integer number. Assume n is not odd. This means
that n is even, and so there exists an integer k such that
n=2k. Thus, n2=(2k)2=4k2 = 2(2k2). So, taking k′ = 2k2 ,we see
that n2 = 2k′ and so n2 is even. This concludes our proof by
contraposition.

May 2012 Discrete Structures 134


Proof by Contradiction
v In a proof by contradiction, we prove that a
proposition p is true, by showing that there exists a
contradiction q such that ¬p → q.
v We can prove that p is true by showing for instance
that ¬p → (r ∧ ¬r), for some proposition r.
v Prove that
v √2 is irrational.
v A direct proof is difficult, as it means to show that
there exists no two integer a and b with b ≠ 0 such
that √ 2= a/b usually hard. Let’s try a proof by
contradiction...

May 2012 Discrete Structures 135


Proof by Contradiction
v Theorem √ 2 is irrational.
v Proof: We prove by means of contradiction. Assume √2
is a rational number. So, there exists a and b integers
with b ≠ 0 with √2 = a/b.
v We select such integers a and b with the additional
property that a and b have no common factors, i.e. the
fraction a/b is in lowest terms (this is always possible
to obtain, for we can keep dividing by common factors).
So, √2 = a/b so 2 = a2/b2. This implies
v 2b2 = a2………………………………………………………………………………(1)
v By the definition of even, we know that a2 is even.
v Next we use a theorem that states that if a2 is even
then a is even (prove it as an exercise).
May 2012 Discrete Structures 136
Proof by Contradiction
v Now, since a is even, we know that there exists c such
that a = 2c.
v Substituting in the formula (1) above, we get that
v 2b2 = (2c)2 = 4c2.
v Dividing both sides by 2 we get
v b2 = 2c2.
v By the definition of even, we see that b is even.
Therefore, we got that a is even and b is even, and so
2 is a common factor of a and b.
v But we also had that a and b had no common factors.
We just reached a contradiction!

May 2012 Discrete Structures 137


Proof by Contradiction
v Give a proof by contradiction of the theorem
v “ If 3n+2 is odd, then n is odd.”
v Let p be “ 3n+2 is odd” and q be “ n is odd”. Assume
both p and ¬q are true. That is assume that 3n+2 is odd
and n is not odd. So, n is even.
v If n is even, then we can show that 3n+2 is also even as
follows.
v n=2k where k is an integer
v 3n+2=3(2k)+2=2(3k+1)
v Hence 3n+2 is even which is a contradiction.

May 2012 Discrete Structures 138


Other types of proof statements
v  Proof of equivalences:
v  To prove a statement p ↔ q, we show that both p → q and
q → p are true.
v  Example: Prove that if n is a positive integer, then n is odd
if and only if n2 is odd.
v  Sometimes, a theorem states that several propositions are
equivalent. Such a theorem states that propositions p1, p2,
p3........pn are equivalent. This can be written as p1↔
p2↔........↔ pn
v  which states that all propositions have the same truth
values and consequently for all i and j with 1 ≤ i ≤ n and 1 ≤ j ≤
n, pi and pj are equivalent.
v  This can be proved as following
v  (p1↔ p2↔........↔ pn)↔(p1→p2)∧(p2→p3)∧.............∧(pn→p1)
May 2012 Discrete Structures 139
Other types of proof statements
v  Show that these statements about the integer n are
equivalent
v  p1: n is even
v  p2: n-1 is odd
v  p3: n2 is even

v  Showing that a statement of the form ∀xP (x) is false: In


this case, we need to find a counterexample.
v  Example: Show that the statement “Every positive integer
is the sum of the squares of two integers.” is false. We
argue that 3 is a counterexample. The only perfect squares
smaller than 3 are 0 and 1, and clearly, 3 cannot be written
as a sum of two terms each being 0 or 1.

May 2012 Discrete Structures 140


Mistakes in Proofs
v  What is the problem with the following proof that 1 = 2?
v  Use the following steps, where a and b are two equal
positive integers.
1. a=b Given
2. a2 = ab Multiply both sides of (1) by a
3. a2 −b2 =ab−b2 Substract b2 from both sides of (2)
4. (a−b)(a+b)=b(a−b) Factoring both sides of (3)
5. a+b=b Divide both sides of (4) by a−b
6. 2b=b Replace a by b in (5) , since a=b
7. 2=1 Divide both sides of (6) by b
Therefore 2 = 1.
v  Solution: Step 5 where we divided both sides by a-b is
invalid. The error is that a - b equals zero; (Divide by Zero)
May 2012 Discrete Structures 141
Proof by Cases
v  Sometimes it is difficult to use a single argument that holds
for all cases.
v  Proof by cases uses the following equivalence:
v  [(p1 ∨p2 ∨···∨pn)→q]≡[(p1 →q)∧(p2 →q)∧···∧(pn →q)]
v  Example: Prove that if n is integer then n2 ≥ n. We split the
proof into three cases.
v  Case (i) n = 0.
v  In this case,n2 =02 =0=n.
v  Case (ii) n ≥ 1
v  In this case, when we multiply both sides of n ≥ 1 by n we
obtain n·n ≥ n·1. This simplies n2 ≥ n.
v  Case (iii) n ≤ −1. In this case, n ≤ −1, but n2 ≥ 0. Therefore, n2
≥ 0 ≥ −1 ≥ n, and so n2 ≥ n.
May 2012 Discrete Structures 142
Exhaustive proof
v This is a special form of a proof by cases, when there
is a finite and small number of examples for which we
need to prove a fact.

v Prove that (n+1)2 ≥ 3n if n is a positive integer with n ≤


2.

v We use a proof by exhaustion, by examining the cases


n = 1, 2.
v For n=1,(n+1)2 =22 =4 ≥ 3=3n.
v For n=2,(n+1)2 =32 =9 ≥ 32 =3n.

May 2012 Discrete Structures 143


Existence Proofs
v Existence proofs prove statements of the form
∃x P(x).
v Constructive existence proof: find a such that P(a) is
true.
v Example: Show that there is a positive integer that
can be written as a sum of cubes of positive integers in
two different ways.
v Proof: 1729=103+93 and 1729=123+13.

May 2012 Discrete Structures 144


Existence Proofs
v Non-constructive existence proof: show that ∃x P(x)
without explicitly giving a for which P(a) is true.
v Example: Show that there exist irrational numbers x
and y such that xy is rational.
v From a previous theorem we know that
v √2 is irrational.
v Consider the √2√2 number.
v There are two possible cases:
v √2√2 is rational: In this case, take x =√2 and y = √2.
v √2√2 is irrational: In this case, take x = √2√2 and y = √2.
Then
v xy = (√2√2)√2 = (√2)2 = ( 2) =2.
May 2012 Discrete Structures 145
Existence Proofs
v This proof is an example of a non-constructive
existence proof because we have not found irrational
numbers x and y such that xy is rational.
v Rather, we have shown that either the pair x=√2,
y=√2 or the pair x = √2√2, y = √2 have the desired
property, but we do not know which of these two pairs
works!

May 2012 Discrete Structures 146

You might also like