You are on page 1of 21

Chapter 1: The Foundations: Logic and Proofs

Propositional Logic: Page 1

Propositions
A proposition is a declarative sentence (that is, a sentence that declares a fact) that is
either true or false, but not both.
Example:
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

Example: 13 (Page 12)

Applications of Propositional Logic: Page 16


Example: 1 and 2 (Page 17)
EXAMPLE 1

How can this English sentence be translated into a logical expression?


“You can access the Internet from campus only if you are a computer science major
or you are not a freshman.”

Solution:
Solution: Let a, c, and f represent “You can access the Internet from campus,” “You
are a computer science major,” and “You are a freshman.” The sentence can be
translated into:
a → (c ν ¬ f ).
EXAMPLE 2

How can this English sentence be translated into a logical expression?


“You cannot ride the roller coaster if you are under 4 feet tall unless you are older
than 16 years old.”

Solution: Let q, r, and s represent “You can ride the roller coaster,” “You are under 4
feet tall,” and “You are older than 16 years old,” respectively. Then the sentence can
be translated to
(r ∧ ¬ s) → ¬ q.

Propositional Equivalences: Page 25


Table: 6 Logic Equivalences (Page 27)
Example: 6, 7 and 8 (Page 29 and 30)
EXAMPLE 6 Show that ¬(p → q) and p ∧ ¬q are logically equivalent
Predicates and Quantifiers: Page 36
Example: 1, 2, 3, 4, 6, 23 and 24(Page 37, 38, 39, 48 and 49)
Rules of Inference: Page 69 Example: 10, 11, 12, 13 and 14 (Page 75, 76 and 77)
Functions: Page 138
Example: 1, 2, 4 and 6(Page 140 and 141)
EXAMPLE 1
What are the domain, co-domain, and range of the function that assigns grades to students
described in the fifth paragraph of the introduction of this section?

Let G be the function that assigns a grade to a student in our discrete mathematics class.

Note that G(Adams) = A, for instance.


The domain of G is the set {Adams, Chou, Goodfriend, Rodriguez, Stevens}, and the
codomain is the set {A, B, C, D, F}. The range of G is the set {A, B, C, F}, because
each grade except D is assigned to some student.

EXAMPLE 2
Let R be the relation with ordered pairs (Abdul, 22), (Brenda, 24), (Carla, 21), (Desire, 22),
(Eddie, 24), and (Felicia, 22). Here each pair consists of a graduate student and this
student’s age. Specify a function determined by this relation.

 If f is a function specified by R, then f(Abdul ) = 22, f(Brenda) = 24, f(Carla) =


21, f(Desire) = 22, f(Eddie) = 24, and f(Felicia) = 22.
 For the domain, we take the set {Abdul, Brenda, Carla, Desire, Eddie, Felicia}.
 A co-domain needs to contain all possible ages of students. Because it is highly
likely that all students are less than 100 years old, we can take the set of positive
integers less than 100 as the codomain
 The range of the function we have specified is the set of different ages of these
students, which is the set {21, 22, 24}.
EXAMPLE 4
Let f : Z → Z assign the square of an integer to this integer. Then, f (x) = x2, where
the domain of f is the set of all integers, the codomain of f is the set of all integers, and
the range of f is the set of all integers that are perfect squares, namely, {0, 1, 4, 9,...}.

EXAMPLE 6
Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) = x − x2. What are
the functions f1 + f2 and f1f2?
Solution:
From the definition of the sum and product of functions, it follows that
(f1 + f2)(x) = f1(x) + f2(x) = x2 + (x − x2) = x
and
(f1f2)(x) = x2(x − x2) = x3 − x4.
When f is a function from A to B, the image of a subset of A can also be defined.

Matrices: Page 177


Example: 1 and 2 (Page 178)

3.1 Algorithms: Page 191


Algorithms:
An algorithm is a finite sequence of precise instructions for performing a computation
or for solving a problem.

Example: 1, 4 and 5 (Page 192, 196 and 198)


EXAMPLE 1
Describe an algorithm for finding the maximum (largest) value in a finite sequence of
integers.
Solution:
We perform the following steps.
1. Set the temporary maximum equal to the first integer in the sequence. (The
temporary maximum will be the largest integer examined at any stage of the
procedure.)
2. Compare the next integer in the sequence to the temporary maximum, and if it is
larger than the temporary maximum, set the temporary maximum equal to this
integer.
3. Repeat the previous step if there are more integers in the sequence.
4. Stop when there are no integers left in the sequence. The temporary maximum at
this point is the largest integer in the sequence.

EXAMPLE 4 Use the bubble sort to put 3, 2, 4, 1, 5 into increasing order

Start with the second element, for each item in the input list:
“Insert” it into the correct place in the sorted output list generated so far. Like so:Find
the location where the new item should be inserted using linear or binary search.Then,
shift the items from that position onwards up by one position. Put the new item in the
remaining hole.
 Use the insertion sort to put 3, 2, 4, 1, 5 into increasing order
 Insert the 2nd element 2 in the right position:
 3 > 2 ⇒ put 2 in front of 3. ⇒ 2, 3, 4, 1, 5
 Insert the 3rd element 4 in the right position:
 4 > 2 ⇒ do nothing. Move to the next comparison.
 4 > 3 ⇒ do nothing. Done. ⇒ 2, 3, 4, 1, 5
 Insert the 4th element 1 in the right position:
 2 > 1 ⇒ put 1 in front of 2. ⇒ 1, 2, 3, 4, 5
 Insert the 5th element 5 in the right position:
 5 > 1 ⇒ do nothing. Move to the next comparison.
 5 > 2 ⇒ do nothing. Move to the next comparison.
 5 > 3 ⇒ do nothing. Move to the next comparison.
 5 > 4 ⇒ do nothing. Done. ⇒ 1, 2, 3, 4, 5

3.2 The Growth of Functions:P#204 Example:1(Page 206

EXAMPLE 1 Show that f (x) = x2 + 2x + 1 is O(x2)


Solution:
We observe that we can readily estimate the size of f (x) when x > 1 because x<x2
and 1 < x2 when x > 1. It follows that
0 ≤ x2 + 2x + 1 ≤ x2 + 2x2 + x2 = 4x2

Alternatively, we can estimate the size of f (x) when x > 2. When x > 2, we have
2x ≤ x2 and 1 ≤ x2. Consequently, if x > 2, we have
0 ≤ x2 + 2x + 1 ≤ x2 + x2 + x2 = 3x2
It follows that C = 3 and k = 2 are also witnesses to the relation f (x) is O(x2).

Observe that O(x2) can be replaced by any function with larger values than x2,
e.g., f(x)= x2+2x+1 is O(x3), f(x) is O(x2+x+7), O(x2+2x+1)
In this example, f(x)=x2+2x+1, g(x)=x2, we say both of these big-O relationships are
of the same order Sometimes written as f(x) = O(g(x))
It is acceptable to write f(x) ∈ O(g(x)) as O(g(x)) represents the set of functions that
are O(g(x))
Example: 1 Caesar Cipher (Page 295)
Cryptography:
Cryptography is a method of protecting information and communications through the
use of codes, so that only those for whom the information is intended can read and
process it. The prefix "crypt-" means "hidden" or "vault" -- and the suffix "-graphy"
stands for "writing."
EXAMPLE 1
What is the secret message produced from the message “MEET YOU IN THE
PARK” using the Caesar cipher?
Solution. First replace the letters in the message with numbers. This produces
12 4 4 19 24 14 20 8 13 19 7 4 15 0 17 10.
Now replace each of these numbers p by f(p) = (p + 3) mod 26. This gives
15 7 7 22 1 17 23 11 16 22 10 7 18 3 20 13.
Translating this back to letters produces the encrypted message “PHHW BRX LQ WKH SDUN.”

Example: 2 and 3 Shift Cipher (Page 296)


EXAMPLE 2
Encrypt the plain text message “STOP GLOBAL WARMING” using the shift cipher
with shift k = 11.
Solution: To encrypt the message “STOP GLOBAL WARMING” we first translate
each letter to the corresponding element of Z26. This produces the string
18 19 14 15 6 11 14 1 0 11 22 0 17 12 8 13 6.
We now apply the shift f (p) = (p + 11) mod 26 to each number in this string. We
obtain
3 4 25 0 17 22 25 12 11 22 7 11 2 23 19 24 17.
Translating this last string back to letters, we obtain the cipher text
“DEZA RWZMLW HLCXTYR.”
EXAMPLE 3
Decrypt the cipher text message “LEWLYPLUJL PZ H NYLHA ALHJOLY”
that was encrypted with the shift cipher with shift k = 7.
Solution:
To decrypt the cipher text “LEWLYPLUJL PZ H NYLHA ALHJOLY” we first
translate the letters back to elements of Z26. We obtain
11 4 22 11 24 15 11 20 9 11 15 25 7 13 24 11 7 0 0 11 7 9 14 11 24.
Next, we shift each of these numbers by −k = −7 modulo 26 to obtain
4 23 15 4 17 8 4 13 2 4 8 18 0 6 17 4 0 19 19 4 0 2 7 4 17.
Finally, we translate these numbers back to letters to obtain the plaintext. We obtain
“EXPERIENCE IS A GREAT TEACHER.”

We can generalize shift ciphers further to slightly enhance security by using a


function of the form f (p) = (ap + b) mod 26,

where a and b are integers, chosen so that f is a bijection. (The function f (p) = (ap +b) mod
26 is a bijection if and only if gcd(a, 26) = 1.) Such a mapping is called an affifine
transformation, and the resulting cipher is called an affine cipher.
Graphs and Graph Models: Page 641
Graphs:
A graph G = (V , E) consists of V , a nonempty set of vertices (or nodes) and E, a set
of edges. Each edge has either one or two vertices associated with it, called its
endpoints. An edge is said to connect its endpoints.

Finite Graph:
A graph with a finite vertex set and a finite edge set is called a finite graph. In this
book we will usually consider only finite graphs.

Infinite Graph:
The set of vertices V of a graph G may be infinite. A graph with an infinite vertex
set or an infinite number of edges is called an infinite graph

Figure: 1, 2, 3, 6 and 7 (Page 642 and 645)


Figure: 1 A Computer Network.

Now suppose that a network is made up of data centers and communication links
between computers. We can represent the location of each data center by a point and
each communications link by a line segment, as shown in Figure 1.

This computer network can be modeled using a graph in which the vertices of the
graph represent the data centers and the edges represent communication links. In
general, we visualize
FIGURE 2 A Computer Network with Multiple Links between Data Centers.

A computer network may contain multiple links between data centers, as shown in
Figure 2. To model such networks we need graphs that have more than one edge
connecting the same pair of vertices.

Graphs that may have multiple edges connecting the same vertices are called multi
graphs. When there are m different edges associated to the same unordered pair of
vertices {u, v}, we also say that {u, v} is an edge of multiplicity m. That is, we can
think of this set of edges as m different copies of an edge {u, v}.

FIGURE 3 A Computer Network with Diagnostic Links.


Sometimes a communications link connects a data center with itself, perhaps a
feedback loop for diagnostic purposes. Such a network is illustrated in Figure 3. To
model this network we
Figure 6 and 7:

Example: 5 and 6 (Page 655)


Example# 5
Complete Graphs A complete graph on n vertices, denoted by Kn, is a simple graph
that contains exactly one edge between each pair of distinct vertices. The graphs Kn,
for n = 1, 2, 3, 4, 5, 6, are displayed in Figure 3. A simple graph for which there is at
least one pair of distinct vertex not connected by an edge is called non complete.

FIGURE 3 The Graphs Kn for 1 ≤ n ≤ 6.

Example# 6
Cycles A cycle Cn, n ≥ 3, consists of n vertices v1, v2,..., vn and edges {v1, v2}, {v2,
v3},...,{vn−1, vn}, and {vn ,v1}. The cycles C3, C4, C5, and C6 are displayed in Figure 4.
Table: 1 (Page 644)
Figure: 1 and 2 (Page 745 and 746)
FIGURE 1 The Bernoulli Family of Mathematicians.

FIGURE 2 Examples of Trees and Graphs That Are Not Trees.

Example: 2 and 3 (Page 748)


EXAMPLE 2
In the rooted tree T (with root a) shown in Figure 5, find the parent of c, the children
of g, the siblings of h, all ancestors of e, all descendants of b, all internal vertices, and
all leaves. What is the sub tree rooted at g?
Solution:
The parent of c is b. The children of g are h, i, and j . The siblings of h are i and j .
The ancestors of e are c, b, and a. The descendants of b are c, d, and e. The internal
vertices are a, b, c, g, h, and j . The leaves are d, e, f , i, k, l, and m. The sub tree
rooted at g is shown in Figure 6

(Not included in Answers)


Rooted trees with the property that all of their internal vertices have the same number
of children are used in many different applications.

A rooted tree is called an m-ary tree if every internal vertex has no more than m
children. The tree is called a full m-ary tree if every internal vertex has exactly m
children. An m-ary tree with m = 2 is called a binary tree.

EXAMPLE 3
Are the rooted trees in Figure 7 full m-ary trees for some positive integer m?

Solution:
T1 is a full binary tree because each of its internal vertices has two children. T2 is a
full 3-ary tree because each of its internal vertices has three children. In T3 each
internal vertex has five children, so T3 is a full 5-ary tree. T4 is not a full m-ary tree for
any m because some of its internal vertices have two children and others have three
children.
Example: 1,2 and 3 (Page 811 and 812)
Ways to Solve Problems:
In Boolean Algebra The complement of an element, denoted with a bar, is defined by
0 = 1 and 1 = 0. The Boolean sum, denoted by + or by OR, has the following values:

1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0 + 0 = 0.

The Boolean product, denoted by · or by AND, has the following values:

1 · 1 = 1, 1 · 0 = 0, 0 · 1 = 0, 0·0=0

You might also like