Discrete Chapter 1 Logics and Proofs
Discrete Chapter 1 Logics and Proofs
Discrete Mathematics
Chapter No. 1: Logic and Proofs
Discrete Mathematics:
Discrete Mathematics concerns processes that consist of a sequence of individual steps. Discrete mathematics
is the study of mathematical structures that are fundamentally discrete rather than continuous.
Logic:
Logic is the study of the principles and methods that distinguish between a valid and an invalid argument.
Examples:
Propositions Not Propositions
1) Grass is green. 1) Close the door.
2) 4 + 2 = 6 2) x is greater than 2.
3) 4 + 2 = 7 3) He is very rich
4) There are four fingers in a hand.
Understanding Statements:
1) x + 2 is positive. Not a statement 2) May I come in? Not a statement
3) Logic is interesting. A statement 4) It is hot today. A statement
5) -1 > 0 A statement 6) x + y = 12 Not a statement
Negation(~)
If p is a statement variable, then negation of p, “not p”, is denoted as “~p” It has opposite truth value from p
i.e., if p is true, then ~ p is false; if p is false, then ~ p is true.
Example: “Michael’s PC runs Linux”
Solution: The negation is “It is not the case that Michael’s PC runs Linux.”
This negation can be more simply expressed as “Michael’s PC does not run Linux.”
Conjunction (∧)
If p and q are statements, then the conjunction of p and q is “p and q”, denoted as “p ∧ q”.
1|Page
Remarks:
p ∧ q is true only when both p and q are true.
If either p or q is false, or both are false, then p ∧ q is false.
Exclusive OR:
When OR is used in its exclusive sense, the statement “p or q” means “p or q but not both” or “p or q and not p
and q” which translates into symbols as (p ∨ q) ∧ ~ (p ∧ q) It is abbreviated as p ⊕ q or p XOR q.
Truth Table for Exclusive OR:
p q p⊕q
F F F
F T T
T F T
T T F
Conditional Statements
If p and q are statement variables, the conditional of q by p is “If p then q” or “p implies q” and is denoted p
→ q. p → q is false when p is true and q is false; otherwise it is true.
The arrow "→” is the conditional operator. In p → q, the statement p is called the hypothesis (or antecedent)
and q is called the conclusion (or consequent).
Examples:
Determine the truth value of each of the following conditional statements:
1. “If 1 = 1, then 3 = 3.” TRUE. 2. “If 1 = 1, then 2 = 3.” FALSE
3. “If 1 = 0, then 3 = 3.” TRUE. 4. “If 1 = 2, then 2 = 3.” TRUE
Truth Table
p q p→q
F F T
F T T
T F F
T T T
BiConditional
If p and q are statement variables, the biconditional of p and q is “p if and only if q”. It is denoted p↔q. “if
and only if” is abbreviated as iff. The double headed arrow “↔" is the biconditional operator.
2|Page
Remarks: 1- p ↔ q is true only when p and q both are true or both are false.
2- p ↔ q is false when either p or q is false.
Example: Truth Table
p q p ↔q
F F T
F T F
T F F
T T T
Logically Equivalence
If two logical expressions have the same logical values in the truth table, then we say that the two logical
expressions are logically equivalent. In the following example, ~ (~ p) is logically equivalent p. So it is
written as ~ (~p) ≡ p.
Example:
Double Negative Property ~ (~p) ≡ p
p ~p ~(~p)
T F T
F T F
Tautology
A tautology is a statement form that is always true regardless of the truth values of the statement variables. A
tautology is represented by the symbol “t”.
Example:
The statement form p ∨ ~ p is tautology
p ~p p∨~p
T F T
F T T
p∨~p≡t
Contradiction
A contradiction is a statement form that is always false regardless of the truth values of the statement
variables. A contradiction is represented by the symbol “c”.
So if we have to prove that a given statement form is CONTRADICTION, we will make the truth table for the
statement form and if in the column of the given statement from all the entries are F, then we say that statement
form is contradiction.
Example: The statement form p ∧ ~ p is a contradiction.
p ~p p∧~p
T F F
F T F
Remarks:
– Most statements are neither tautologies nor contradictions.
– The negation of a tautology is a contradiction and vice versa.
– In common usage we sometimes say that two statements are contradictory.
3|Page
Contingency
A compound proposition that is neither a tautology nor a contradiction is called a contingency.
Inverse:
The inverse of proposition p → q is ¬p → ¬q. A conditional and its inverse are not equivalent as could be seen
from the truth table.
Truth Table of Inverse
p q p→q ~p ~q ~p → ~q
F F T T T T
F T T T F F
T F F F T T
T T T F F T
Writing Inverse:
1. If today is Friday, then 2 + 3 = 5.
If today is not Friday, then 2 + 3 ≠ 5.
2. If it snows today, I will ski tomorrow.
If it does not snow today I will not ski tomorrow.
3. If P is a square, then P is a rectangle.
If P is not a square then P is not a rectangle.
4. If my car is in the repair shop, then I cannot get to class.
If my car is not in the repair shop, then I shall get to the class.
Converse
The converse of the conditional statement p → q is q →p.
Example:
p q p→q q →p
F F T T
F T T F
T F F T
T T T T
Writing Converse:
1. If today is Friday, then 2 + 3 = 5.
If 2 + 3 = 5, then today is Friday.
2. If it snows today, I will ski tomorrow.
I will ski tomorrow only if it snows today.
3. If P is a square, then P is a rectangle.
If P is a rectangle then P is a square.
4. If my car is in the repair shop, then I cannot get to class.
If I cannot get to the class, then my car is in the repair shop.
Contrapositive
The contra-positive of the conditional statement p → q is ~ q → ~ p. A conditional and its contra-positive are
equivalent.
Symbolically p→q ≡ ~q → ~p
Writing Contrapositive:
1. If today is Friday, then 2 + 3 = 5.
If 2 + 3 ≠ 5, then today is not Friday.
2. If it snows today, I will ski tomorrow.
I will not ski tomorrow only if it does not snow today.
3. If P is a square, then P is a rectangle.
If P is not a rectangle then P is not a square.
4. If my car is in the repair shop, then I cannot get to class.
If I can get to the class, then my car is not in the repair shop.
4|Page
Bit, Boolean Variable, Bit String
A bit is a symbol with two possible values, namely, 0 (zero) and 1 (one). This meaning of the word bit comes
from binary digit, because zeros and ones are the digits used in binary representations of numbers. .A variable
is called a Boolean variable if its value is either true or false. A bit string is a sequence of zero or more bits. The
length of this string is the number of bits in the string.
DE MORGAN’S LAWS
1) The negation of an AND statement is logically equivalent to the OR statement in which each component
is negated.
Symbolically ~ (p ∧ q) ≡ ~ p ∨ ~ q
2) The negation of an OR statement is logically equivalent to the AND statement in which each component
is negated.
Symbolically ~ (p ∨ q) ≡ ~ p ∧ ~ q
Laws Of Logic
1) Commutative Laws p∧q≡q∧p p∨q≡q∨p
2) Associative Laws (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) (p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
3) Distributive Laws p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
4) Identity Laws p∧t≡p p∨c≡p
5) Negation Laws p ∨ ∼p ≡ t p ∧ ∼p ≡ c
6) Double Negation Law ∼ (∼p) ≡ p
7) Idempotent Laws p∧p≡p p∨p≡p
8) DE Morgan’s Laws ~ (p ∧ q) ≡ ~p ∨ ∼q ~ (p ∨ q) ≡ ~p ∧ ∼q
9) Universal Bound Laws p∨t≡t p∧c≡c
10) Absorption Laws p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
11) Negation of t and c ~t≡c ~c≡t
Predicate
Consider the sentence “Aslam is a student at the Virtual University.” let P stand for the words “is a student at
the Virtual University” and let Q stand for the words “is a student at.” Then both P and Q are predicate symbols.
The sentences “x is a student at the Virtual University” and “x is a student at y” are symbolized as P(x) and Q(x,
y), where x and y are predicate variables and take values in appropriate sets. When concrete values are
substituted in place of predicate variables, a statement results.
Definition
A predicate is a sentence that contains a finite number of variables and becomes a statement when
specific values are substituted for the variables. The domain of a predicate variable is the set of all
values that may be substituted in place of the variable.
5|Page
Example:
1. Algorithm to compute a product of two nonnegative integers:
Precondition: The input variables m and n are nonnegative integers.
Postcondition: The output variable p equals m · n.
Quantifiers
An expression that indicates the scope of a term to which it is attached, is called quantifier. There are two types
of quantifiers:
i- Universal Quantifiers ii- Existential Quantifiers
Nested Quantifiers
Quantifier within a quantifier is called nested quantifier.
Statement Where True? Where False?
∀x ∀y P(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.
∀y ∀x P(x, y)
∀x ∃y P(x, y) For every x there is a y for which P(x, y) is There is an x such that P(x, y)is false for
true. every y.
∃x ∀y P(x, y) There is an x for which P(x, y) is true for For every x there is a y for which P(x, y) is
every y. false.
∃x ∃y P(x, y) There is a pair x, y for which P(x, y) is P(x, y)is false for every pair x, y.
∃y ∃x P(x, y) true.
Binding Variables
When a quantifier is used on the variable x, we say that this occurrence of the variable is bound. An occurrence
of a variable that is not bound by a quantifier or set equal to a particular value is said to be free. .All the variables
that occur in a propositional function must be bound or set equal to a particular value to turn it into a proposition.
This can be done using a combination of universal quantifiers, existential quantifiers, and value assignments.
The part of a logical expression to which a quantifier is applied is called the scope of this quantifier.
Consequently, a variable is free if it is outside the scope of all quantifiers in the formula that specify this variable.
6|Page
Valid And Invalid Argument
An argument is valid if the conclusion is true when all the premises are true. Alternatively, an argument is valid
if conjunction of its premises imply conclusion.
That is (P1∧ P2 ∧ P3 ∧ . . . ∧ Pn) → C is a tautology. An argument is invalid if the conclusion is false when all
the premises are true. Alternatively, an argument is invalid if conjunction of its premises does not imply
conclusion.
Proofs
A proof is a valid argument that establishes the truth of a mathematical statement.
Direct Proofs
The implication p →q can be proved by showing that if p is true, the q must also be true. This shows that the
combination p true and q false never occurs. A proof of this kind is called a direct proof.
“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. (Note that every integer is either even or odd, and no integer is both even and odd.) Two integers
have the same parity when both are even or both are odd; they have opposite parity when one is even and the
other is odd”
SOME BASICS
1. An integer n is even if, and only if, n = 2k for some integer k.
2. An integer n is odd if, and only if, n = 2k + 1 for some integer k.
3. An integer n is prime if, and only if, n > 1 and for all positive integers r and s, if n = r·s, then
r = 1 or s = 1.
4. An integer n > 1 is composite if, and only if, n = r·s for some positive integers r and s with r ≠ 1
and s ≠ 1.
5. A real number r is rational if, and only if, a/ b for some integers a and b with b≠0.
6. If n and d are integers and d ≠0, then d divides n, written d | n if, and only if, n = d.k for
some integers k.
7. An integer n is called a perfect square if, and only if, n = k2 for some integer k
7|Page
Example 1
Prove that the sum of two odd integers is even.
Solution
Let m and n be two odd integers. Then by definition of odd numbers
m = 2k + 1 for some k ∈ Z
n = 2l + 1 for some l ∈ Z
Now m + n = (2k + 1) + (2l + 1)
= 2k + 2l + 2
= 2 (k + l + 1)
= 2r where r = (k + l + 1) ∈ Z
Hence m + n is even.
Example 2
Give a direct proof that if m and n are both perfect squares, then nm is also a perfect square. (An
integer a is a perfect square if there is an integer b such that a = b2.)
Solution
To produce a direct proof of this theorem, we assume that the hypothesis of this conditional statement
is true, namely, we assume that m and n are both perfect squares. By the definition of a perfect square, it follows
that there are integers s and t such that m = s2 and n = t2. The goal of the proof is to show that mn must also be
a perfect square when m and n are; looking ahead we see how we can show this by substituting s2 for m and t2
for n into mn. This tells us that mn = s2t2. Hence, mn = s2 t2 = (ss)(tt) = (st)(st) = (st)2, using commutativity and
associativity of multiplication. By the definition of perfect square, it follows that mn is also a perfect square,
because it is the square of st, which is an integer. We have proved that if m
and n are both perfect squares, then mn is also a perfect square.
Example 3
Prove that the product of an even integer and an odd integer is even.
Solution
Suppose m is an even integer and n is an odd integer. Then m = 2k for some integer k
and n = 2l + 1 for some integer l
Now
m·n = 2k · (2l + 1)
= 2·k (2l + 1)
= 2·r where r = k(2l + 1) is an integer
Hence m·n is even. (Proved)
Example 4
Prove that the square of an even integer is even.
Solution
Suppose n is an even integer. Then n = 2k
Now
8|Page
Example 5
Prove that if n is any even integer, then (-1)n = 1
Solution
Suppose n is an even integer. Then n = 2k for some integer k.
Now
Proved
Example 6
Prove that if n is an odd integer, then n3 + n is even.
Solution
Let n be an odd integer, then n = 2k + 1for some k ∈ Z
Now
Example 7
Prove that, if the sum of any two integers is even, then so is their difference.
Solution
Suppose m and n are integers so that m + n is even. Then by definition of even numbers m + n = 2k
for some integer k
⇒ m = 2k - n ……………….(1)
Now m - n = (2k - n) - n using (1)
= 2k - 2n
= 2 (k - n) = 2r where r = k - n is an integer
Hence m - n is even.
Example 8
Prove that the sum of any two rational numbers is rational.
Solution
Suppose r and s are rational numbers. Then by definition of rational
9|Page
Example 9
Prove that the sum of any three consecutive integers is divisible by 3.
Solution
Let n, n + 1 and n + 2 be three consecutive integers.
Now
n + (n + 1) + (n + 2)= 3n + 3
= 3(n + 1)
= 3·k where k=(n+1)∈Z
Hence, the sum of three consecutive integers is divisible by 3
Example 10
Disprove the statement by giving a counter example. For all real numbers a and b, if a < b then a2 < b2.
Solution
Suppose a = -5 and b = -2
then clearly - 5 < - 2
But a2 = (-5)2 = 25 and b2 = (-2)2 = 4
But 25 > 4
This disproves the given statement.
Example 11
Prove or give counter example to disprove the statement.
For all integers n, n2 - n + 11 is a prime number.
Solution
The statement is not true
For n = 11
we have , n2 - n + 11= (11) 2 - 11 + 11
= (11) 2
= (11) (11)
=121
which is obviously not a prime number.
Example 12
Prove or disprove that the product of any two irrational numbers is an irrational number.
Solution
We know that √2 is an irrational number. Now
Proof By Contraposition
A proof by contraposition is based on the logical equivalence between a statement and its contrapositive.
Therefore, the implication p→ q can be proved by showing that its contrapositive ~ q → ~ p is true. The
contrapositive is usually proved directly. The method of proof by contrapositive may be summarized as:
1. Express the statement in the form if p then q.
2. Rewrite this statement in the contrapositive form if not q then not p.
3. Prove the contrapositive by a direct proof.
Example 1
Prove that for all integers n, if n2 is even then n is even.
Solution
The contrapositive of the given statement is:
“if n is not even (odd) then n2 is not even (odd)”
We prove this contrapositive statement directly.
Suppose n is odd. Then n = 2k + 1 for some k € Z
10 | P a g e
Now n2 = (2k+1) 2= 4k2 + 4k + 1
= 2·(2k2 + 2k) + 1
= 2·r + 1 where r = 2k2 + 2k €Z
2
Hence n is odd. Thus the contrapositive statement is true and so the given statement is
true.
Example 2
Prove that if 3n + 2 is odd, then n is odd.
Solution
The contrapositive of the given conditional statement is
“ if n is even then 3n + 2 is even”
Suppose n is even, then
n = 2k for some k €Z
Now 3n + 2 = 3 (2k) + 2
= 2. (3k + 1)
= 2.r where r = (3k + 1) € Z
Hence 3n + 2 is even. We conclude that the given statement is true since its contrapositive
is true.
Example 3
Prove that if n is an integer and n3 + 5 is odd, then n is even.
Solution
Suppose n is an odd integer. Since, a product of two odd integers is odd, therefore n2 = n.n is odd; and
n3 = n2.n is odd. Since a sum of two odd integers is even therefore n2 + 5 is even.Thus we have proved
that if n is odd then n3 + 5 is even.
Since this is the contrapositive of the given conditional statement, so the given statement
is true.
Example 4
Prove that if n2 is not divisible by 25, then n is not divisible by 5.
Solution
The contra positive statement is: “if n is divisible by 5, then n2 is divisible by 25”
Suppose n is divisible by 5. Then by definition of divisibility
n = 5·k for some integer k
Squaring both sides
n2 = 25·k2 where k2 € Z
2
n is divisible by 25
Example 5
Prove the statement by contraposition:
“For all integers m and n, if m + n is even then m and n are both even or m and n are both
odd.”
Solution
The contrapositive statement is:
“For all integers m and n, if m and n are not both even and m and n are not both odd, then m + n is not
even.” Or more simply,
“For all integers m and n, if one of m and n is even and the other is odd, then m + n is odd”
Suppose m is even and n is odd. Then m = 2p for some integer p and n = 2q + 1 for some integer q
Now
m + n = (2p) + (2q + 1)
= 2·(p+q) + 1
= 2·r + 1 where r = p+q is an integer
Hence m + n is odd.
Similarly, taking m as odd and n even, we again arrive at the result that m + n is odd. Thus, the
contrapositive statement is true. Since an implication is logically equivalent to its contrapositive so the
given implication is true.
11 | P a g e
PROOF BY CONTRADICTION
A proof by contradiction is based on the fact that either a statement is true or it is false but not both. Hence the
supposition, that the statement to be proved is false, leads logically to a contradiction, impossibility or
absurdity, then the supposition must be false. Accordingly, the given statement must be true. This method of
proof is also known as reductio ad absurdum because it relies on reducing a given assumption to an absurdity.
Many theorems in mathematics are conditional statements (p→q). Now the negation of he implication p→q is
~ (p→q) ≡ ~ (~p∨q)
≡ ~ (~p) ∧(~q) DeMorgan’s Law
≡ p ∧ ~q
Clearly if the implication is true, then its negation must be false, i.e., leads to a contradiction.
Hence ~(p→q) ≡ (p ∧ ~q) → c, where c is a contradiction. Thus to prove an implication p → q by
contradiction method, we suppose that the condition p and the negation of the conclusion q, i.e., (p ∧ ~q) is
true and ultimately arrive at a contradiction.
The method of proof by contradiction, may be summarized as follows:
1. Suppose the statement to be proved is false.
2. Show that this supposition leads logically to a contradiction.
3. Conclude that the statement to be proved is true.
Example 1
Give a proof by contradiction for the statement: “If n2 is an even integer then n is an even integer.”
Solution
Suppose n2 is an even integer and n is not even, so that n is odd.
Hence n = 2k + 1 for some integer k.
Now n2 = (2k + 1) 2
= 4k2 + 4k + 1
= 2·(2k2 + 2k) + 1
= 2r + 1 where r = (2k2 + 2k) ∈Z
This shows that n2 is odd, which is a contradiction to our supposition that n2 is even. Hence the given
statement is true.
Example 2
Prove that if n is an integer and n3 + 5 is odd, then n is even using contradiction method.
Solution
Suppose that n3 + 5 is odd and n is not even (odd). Since n is odd and the product of two odd numbers
is odd, it follows that n2 is odd and n3 = n2. n is odd. Further, since the difference of two odd number is
even, it follows that
5 = (n3 + 5) - n3
is even. But this is a contradiction. Therefore, the supposition that n3 + 5 and n are both odd is wrong
and so the given statement is true.
Example 3
Prove by contradiction method, the statement: If n and m are odd integers, then n + m is an even
integer.
Solution
Suppose n and m are odd and n + m is not even (odd i.e by taking contradiction).
Now n = 2p + 1 for some integer p
and m = 2q + 1 for some integer q
Hence n + m = (2p + 1) + (2q + 1)
= 2p + 2q + 2 = 2· (p + q + 1)
which is even, contradicting the assumption that n + m is odd.
Example 4
Prove that √2 is irrational.
Solution
Suppose √2 is rational. Then there are integers m and n with no common factors so that
12 | P a g e
Squaring both sides gives
Or m2 = 2n2 ………………………(1)
This implies that m2 is even (by definition of even). It follows that m is even. Hence
m = 2 k for some integer k ………(2)
Substituting (2) in (1), we get
(2k)2 = 2n2
⇒ 4k2 = 2n2
⇒ n2 = 2k2
This implies that n2 is even, and so n is even. But we also know that m is even. Hence both m and n
have a common factor 2. But this contradicts the supposition that m and n have no common factors.
Hence our supposition is false and so the theorem is true. Substituting (2) in (1), we get
(2k)2 = 2n2
⇒ 4k2 = 2n2
⇒ n2 = 2k2
This implies that n2 is even, and so n is even. But we also know that m is even. Hence both m and n
have a common factor 2. But this contradicts the supposition that m and n have no common factors.
Hence our supposition is false and so the theorem is true.
13 | P a g e