Lecture No 1: Topics Covered Logic and Truth Tables
Lecture No 1: Topics Covered Logic and Truth Tables
Topics covered
Logic and Truth tables
TEXT BOOK:
DISCRETE MATHEMATICS AND ITS
APPLICATIONS
BY
KENNETH H ROSEN
6TH OR 7TH EDITION
REFERENCE BOOK:
DISCRETE MATHEMATICS WITH APPLICATIONS
BY
SUSANNA S. EPP
4TH EDITION
MARKS DIVISION
Total absolute score 100%
Discrete function
A B
1 a
3 b
10 c
How can I encrypt a message so that no unintended recipient can read it?
EXAMPLE 1
All the following declarative sentences are propositions.
1. Washington, D.C., is the capital of the United States of America.
2. Toronto is the capital of Canada.
3. 1 + 1 = 2.
4. 2 + 2 = 3.
Negation of p:
negation of p, denoted by ¬ p (also denoted by p), is the
statement
“It is not the case that p.”
The truth value of the negation of p, ¬ p, is the opposite of the
truth value of p.
EXAMPLE 3
Find the negation of the proposition
“Michael’s PC runs Linux” and express this in simple English.
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.”
EXAMPLE 4
Find the negation of the proposition
“Vandana’s smartphone has at least 32GB of memory”
and express this in simple English.
Solution: The negation is
“It is not the case that Vandana’s smartphone has at least 32GB of memory.”
This negation can also be expressed as
“Vandana’s smartphone does not have at least 32GB of memory”
or even more simply as
“Vandana’s smartphone has less than 32GB of memory.”
Conjunction of propositions:
The conjunction of p and q, denoted by p ∧ q, is the proposition “p
and q.”
The conjunction p ∧ q is true when both p and q are true and is
false otherwise.
EXAMPLE 5
Find the conjunction of the propositions p and q?
where p is the proposition “Rebecca’s PC has more than 16 GB
free hard disk space”
and q is the proposition “The processor in Rebecca’s
PC runs faster than 1 GHz.”
Conditional statement:
Let p and q be propositions. The conditional statement p → q is the
proposition “if p, then q.” The conditional statement
p → q is false when p is true and q is false, and true otherwise.
In the conditional statement p → q, p is called the hypothesis (or antecedent
or premise) and q is called the conclusion (or consequence).
Ways to express this conditional statement:
“if p, then q” “p implies q”
“if p, q” “p only if q”
“p is sufficient for q” “a sufficient condition for q is p”
“q if p” “q whenever p”
“q when p” “q is necessary for p”
“q follows from p” “q unless ¬ p”
“a necessary condition for p is q”
“If you get 100% on the final, then you will get an A.”
If you manage to get a 100% on the final, then you would expect to
receive an A. If you do not get 100% you may or may not receive an A
depending on other factors. However, if you do get
100%, but the professor does not give you an A, you will feel cheated.
EXAMPLE 7
Let p be the statement “Maria learns discrete mathematics” and q the
statement “Maria will find a good job.” Express the statement
p → q as a statement in English.
Solution:
p → q represents the statement
“If Maria learns discrete mathematics, then she will find a good job.”
There are many other ways to express this conditional statement in
English. Among the most natural of these are:
“Maria will find a good job when she learns discrete mathematics.”
“For Maria to get a good job, it is sufficient for her to learn discrete
mathematics.”
and
“Maria will find a good job unless she does not learn discrete
mathematics.”
EXAMPLE 8
What is the value of the variable x after the statement
if 2 + 2 = 4 then x := x + 1
if x = 0 before this statement is encountered? (The symbol :=
stands for assignment. The
statement x := x + 1 means the assignment of the value of x + 1 to
x.)
Solution:
Because 2 + 2 = 4 is true, the assignment statement
x := x + 1 is executed. Hence,
x has the value 0 + 1 = 1 after this statement is encountered.
Converse:
The converse of p → q is q → p.
Contrapositive:
The contrapositive of p → q is the proposition ¬ q → ¬ p.
Inverse:
The inverse of p → q is ¬ p → ¬ q.
Equivalent:
When two compound propositions always have the same truth
value we call them equivalent, so that a conditional statement and
its contrapositive are equivalent. The converse and the inverse of
a conditional statement are also equivalent
EXAMPLE 9
What are the contrapositive, the converse, and the inverse of the
conditional statement
“The home team wins whenever it is raining?”
Solution:
p → q, the original statement can be rewritten as
“If it is raining, then the home team wins.”
Consequently, the contrapositive of this conditional statement is
“If the home team does not win, then it is not raining.”
The converse is
“If the home team wins, then it is raining.”
The inverse is
“If it is not raining, then the home team does not win.”
Only the contrapositive is equivalent to the original statement.
Biconditional :
Let p and q be propositions. The biconditional statement 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, and is false
otherwise. Biconditional statements are also called bi-
implications.
EXAMPLE 10
Let p be the statement “You can take the flight,” and let q be the
statement “You buy a ticket.”
Then p ↔ q is the statement
“You can take the flight if and only if you buy a ticket.”
This statement is true if p and q are either both true or both false,
that is, if you buy a ticket and can take the flight or if you do not
buy a ticket and you cannot take the flight.
It is false when
p and q have opposite truth values, that is, when you do not buy a
ticket, but you can take the flight (such as when you get a free
trip) and when you buy a ticket but you cannot take the flight
(such as when the airline bumps you).
EXAMPLE 11
Construct the truth table of the compound proposition
(p ∨ ¬ q) → (p ∧ q).
PRECEDENCE OF LOGICAL
OPERATORS
LOGIC AND BIT OPERATIONS
A bit is a symbol with two possible values namely 0 and 1
corresponding to True and False in Logics.
Variable is called a Boolean variable if its value is either true
or false.
Computer bit operations correspond to the logical
connectives.
Bit operators are OR, AND and XOR.
Solution:
We obtain the statement A(CS1) by setting x = CS1 in the
statement “Computer x is under attack by an intruder.” Because
CS1 is not on the list of computers currently under attack, we
conclude that A(CS1) is false. Similarly, because CS2 and
MATH1 are on the list of
computers under attack, we know that A(CS2) and A(MATH1)
are true.
EXAMPLE 3
Let Q(x, y) denote the statement “x = y + 3.” What are the truth
values of the propositions Q(1, 2) and Q(3, 0)?
Solution:
To obtain Q(1, 2), set x = 1 and y = 2 in the statement Q(x, y).
Hence,
Q(1, 2) is the statement “1 = 2 + 3,” which is false.
The statement Q(3, 0) is the proposition “3 = 0 + 3,”
which is true.
QUANTIFIERS
Quantification expresses the extent to which a predicate is true
over a range of elements. In English, the words all, some, many,
none, and few are used in quantifications.
The universal quantification of P(x) is the statement
“P(x) for all values of x in the domain.”
The notation ∀xP(x) denotes the universal quantification of P(x).
Here ∀ is called the universal quantifier.
We read ∀xP(x) as “for all xP(x)” or “for every xP(x).” An
element for which P(x) is false is called a counterexample of
∀xP(x).
EXAMPLE 8
Let P(x) be the statement “x + 1 > x.” What is the truth value of
the quantification ∀xP(x), where the domain consists of all real
numbers?
Solution:
Because P(x) is true for all real numbers x, the quantification
∀xP(x) is true.
Solution:
First, we rewrite the statement so that we can clearly identify the
appropriate quantifiers
to use. Doing so, we obtain:
“For every student in this class, that student has studied calculus.”
Next, we introduce a variable x so that our statement becomes
“For every student x in this class, x has studied calculus.”
EXAMPLE 24
Express the statements “Some student in this class has visited
Mexico” and “Every student in this class has visited either
Canada or Mexico” using predicates and quantifiers.
Solution:
The statement “Some student in this class has visited Mexico”
means that
“There is a student in this class with the property that the student
has visited Mexico.”
We can introduce a variable x, so that our statement becomes
“There is a student x in this class having the property that x has
visited Mexico.”
INTRODUCTION TO PROOFS
Theorem is a statement that can be shown to be true. In
mathematical writing, the term theorem is usually reserved for a
statement that is considered at least somewhat important. Less
important theorems sometimes are called propositions.
O = {1, 3, 5, 7, 9}.
V = {a, e, i, o, u}.
L = {1, 2, 3, . . . , 99}.
P = {x | x is an odd positive integer less than 10},
O = {x ∈ Z+ | x is odd and x < 10}.
R, the set of real numbers
R+, the set of positive real numbers
C, the set of complex numbers.
[a, b] = {x | a ≤ x ≤ b}
[a, b) = {x | a ≤ x < b}
(a, b] = {x |a < x ≤ b}
(a, b) = {x |a < x < b}
Note that [a, b] is called the closed interval from a to b and (a,
b) is called the open interval from a to b.
Two sets are equal if and only if they have the same elements.
Therefore, if A and B are sets, then A and B are equal if and only
if ∀x(x ∈ A ↔ x ∈ B).We write A = B if A and B are equal sets.
The sets {1, 3, 5} and {3, 5, 1} are equal, because they have the
same elements
The set A is a subset of B if and only if every element of A is also an
element of B. We use the notation A ⊆ B to indicate that A is a subset of the
set B.
The quantification of A ⊆ B is ∀x(x ∈ A → x ∈ B).
EXAMPLE 10
Let A be the set of odd positive integers less than 10. Then |A| = 5.
EXAMPLE 11
Let S be the set of letters in the English alphabet. Then |S| = 26.
EXAMPLE 12
Because the null set has no elements, it follows that | ∅| = 0.
Given
a set S, the power set of S is the set of all subsets of the set
S. The power set of S is denoted by P(S).
EXAMPLE 14
What is the power set of the set {0, 1, 2}?
Solution:
The power set P({0, 1, 2}) is the set of all subsets of {0, 1, 2}.
Hence,
P({0, 1, 2}) = {∅, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2}, {0, 1, 2}}.
The ordered n-tuple is the ordered collection that has as its first
element, as its second element, . . . , and as its nth element.
= if and only if ,
for i = 1, 2, . . . , n.
Let A and B be sets. The Cartesian product of A and B, denoted
by A × B, is the set of all ordered pairs (a, b), where a ∈ A and b
∈ B. Hence,
A × B = {(a, b) | a ∈ A ∧ b ∈ B}.
EXAMPLE 17
What is the Cartesian product of A = {1, 2} and
B = {a, b, c}?
Solution:
The Cartesian product A × B is
A × B = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.
EXAMPLE 19
What is the Cartesian product A × B × C, where
A = {0, 1}, B = {1, 2}, and C = {0, 1, 2} ?
Solution:
The Cartesian product A × B × C consists of all ordered triples (a,
b, c), where a ∈ A, b ∈ B, and c ∈ C. Hence,
A × B × C = {(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1),
(0, 2, 2),(1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 2, 0), (1, 2, 1),
(1, 2, 2)}.
a) ∅ b) {∅}
c) {∅, {∅}} d) {∅, {∅}, {∅, {∅}}}
a) ∀x∈R () b) ∃x∈Z ( = 2)
c) ∀x∈Z (> 0) d) ∃x∈R ( = x)
OPERATIONS ON SETS
EXAMPLE 5
The domain and codomain of functions are often specified in
programming languages. For instance, the Java statement
int floor(float real){. . .}
and
the C++ function statement
int function (float x){. . .}
both tell us that the domain of the floor function is the set of real
numbers (represented by floating point numbers) and its
codomain is the set of integers.?
A function f is said to be one-to-one, or an injunction, if and only if f
(a) = f (b) implies that a = b for all a and b in the domain of f. A
function is said to be injective if it is one-to-one. f(a) is the image of a
in the range.
Or If every element of domain has unique image in Range.