0% found this document useful (0 votes)
74 views41 pages

FR UB4 EVak AESawh

Hookup Format

Uploaded by

tilsmartbambage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views41 pages

FR UB4 EVak AESawh

Hookup Format

Uploaded by

tilsmartbambage
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Lecture Notes for Discrete Math

Douglas Bauer

1 Symbolic Logic

Definition: A proposition is a sentence that is true or false


but not both.

• 10 is a prime number
•4x2=8
• George Washington was mayor of N.Y.C.
• This class has 35 students
• 10100 can be written as the sum of 2 primes

Note: x > 4 is not a proposition.

Notation: p, q, r, s . . . will be used as propositional variables,


i.e., propositions with unspecified truth value.

Notation: T - true , F - false.

1
In what follows, the propositions p and q are often called
atomic propositions or atoms. We now define a number of
compound propositions.

1. Negation
p ¬p
F T
T F

2. Conjunction(and)
p q p∧q
F F F
F T F
T F F
T T T

3. Disjunction(inclusive or)
p q p∨q
F F F
F T T
T F T
T T T

2
4. Implication
p q p→q
F F T
F T T
T F F
T T T

Note: There is usually a causal relationship between p and q,


but not necessarily.

Example: If I have a million dollars in my pocket, I can jump


over the Empire State Building - this is a true statement.

Example: If you show up Monday, you will get the job.


The only time this is false is when you show up Monday and
still don’t get the job.

Note: Here are some equivalent English expressions.

• if p, then q
• p only if q
• q if p
• q whenever p

Definition: Converse: q → p.
Definition: Inverse: ¬p → ¬q.
Definition: Contrapositive: ¬q → ¬p.

3
5. Logical Equivalence
p q p↔q
F F T
F T F
T F F
T T T

Note: Logical Equivalence is usually expressed as “if and only


if” or “iff”. In these notes, → and ⇒ are used interchangably.
Similarly, ↔ and ⇔ are used interchangably. Also, the text
uses ≡ for ⇔.

Note: To avoid unnecessary parenthesis, ¬(not) has prece-


dence over ∧(and) and ∨(or). Also, → has lower precedence
than ¬, ∧, ∨. Hence ¬p∧q means (¬p)∧q. Also p∨q → ¬p∧q
means (p ∨ q) → ((¬p) ∧ q).

Definition: A tautology is a statement that is always true,


regardless of the truth values of the individual statements sub-
stituted for its statement variables.

Definition: A contradiction is a statement that is always


false, regardless of the truth values of the individual statements
substituted for its statement variables.

4
Examples of Tautologies

• ¬(p ∨ q) ↔ (¬p ∧ ¬q)


• ¬(p ∧ q) ↔ (¬p ∨ ¬q)
• (p → q) ↔ (¬q → ¬p)

Note: The first 2 above are called DeMorgan’s Laws. The last
shows that the truth or falsity of a statement is the same as
that of its contrapositive. This can be proved with a truth
table.

p q p→q ¬q ¬p ¬q → ¬p (p → q) ↔ (¬q → ¬p)


F F T T T T T
F T T F T T T
T F F T F F T
T T T F F T T

Note: Do the truth tables for DeMorgan’s Laws and for some
of the other logical equivalences on page 14 of the text.

In mathematics one often talks about necessary and sufficient


conditions.

Definition: r is a sufficient condition for s means “if r, then


s”. r is a necessary condition for s means “if not r, then not
s”, i.e., “if s, then r.

5
Valid Arguments

First we give an example.

• P1: To be great is to be misunderstood.


• P2: He is great.
• C: He is misunderstood.

Note: Pi: Premises - C: Conclusion

An argument is valid if the conjunction of the premises im-


ply the conclusion, i.e., (P1 ∧P2 ∧. . .∧Pn) → C) is a tautology.

• G: being great
• M: being misunderstood

G M G → M (G → M ) ∧ G [(G → M ) ∧ G] → M
F F T F T
F T T F T
T F F F T
T T T T T

Thus the above argument is valid.

6
Example:

• P1: x is positive or x is negative.


• P2: If x is positive, then x2 > 0.
• P3: If x is negative, then x2 > 0.
• C: x2 > 0.

This argument is also valid. You must check that


(P1 ∧ P2 ∧ P3 → C) is a tautology. First create variables for

1. P: x is positive
2. N: x is negative
3. G: x2 > 0

P N G P ∨ N P → G N → G [(P ∨ N ) ∧ (P → G) ∧ (N → G)] → G
F F F x x x x
F F T x x x x
F T F x x x x
F T T x x x x
T F F x x x x
T F T x x x x
T T F x x x x
T T T x x x x

Note: The conclusion is false for the integers (x = 0).

7
Here are some fallacies:

• P1: If Bob does not do his homework, he will fail the


course.
• P2: Bob failed the course.
• C: Bob did not do his homework.

H: doing homework - F : failing the course.

To see that the argument is invalid, just check that


[(¬H → F ) ∧ F ] → ¬H is not a tautology.

Note: The argument is invalid whether or not the conclusion


is true.

8
Example:

• P1: If Bob does his homework, he will pass the course.


• P2: Bob did not do his homework.
• C: Bob failed the course.

H: doing homework - F : failing the course.

To see that this argument is invalid, just check that


[(H → ¬F ) ∧ ¬H] → F is not a tautology.

H F ¬F H → ¬F ¬H (H → ¬F ) ∧ ¬H [(H → ¬F ) ∧ ¬H] → F
F F T T T T F
F T F T T T T
T F T T F F T
T T F F F F T

9
Sometimes it is not easy to quickly determine if an argument
is valid.

Example: If horses fly or cows eat artichokes, then the mosquito


is the national bird. If the mosquito is the national bird, then
peanut butter tastes good on hot dogs. Peanut butter tastes
terrible on hot dogs. Therefore cows do not eat artichokes.

• F : horses fly
• A: cows eat artichokes
• M : mosquito is the national bird
• P : peanut butter tastes good on hot dogs

Now check to see if [((F ∨A) → M )∧(M → P )∧¬P ] → ¬A


is a tautology.

Note: The truth table will have 16 lines!

10
Proving Theorems

In mathematics and computer science it is important to fol-


low the March Hare’s advise to Alice, namely “Say what you
mean”. It is important to learn how to think and write pro-
grams exactly and precisely. Donald Knuth, one of the pioneers
of computing, has compared constructing a set of programs
from a set of specifications to writing a mathematical proof
from a set of axioms.

We want to study some proof techniques. The subject matter


we will use will consist of elementary number theory and sim-
ple properties of integers.

First some definitions.

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 is composite if, and only if, n = r · s for
some positive integers r and s with r 6= 1 and s 6= 1.
5. A real number r is rational if, and only if, r = a/b for
some integers a and b with b 6= 0.
6. A real number that is not rational is irrational.

11
7. For any real number x, the floor of x, denoted bxc, is
the unique integer n such that n ≤ x < n + 1.
8. For any real number x, the ceiling of x, denoted dxe, is
the unique integer n such that n − 1 < x ≤ n.
9. We say d divides n, denoted d|n if, and only if, there
exists an integer k such that n = d · k.

If a theorem is expressed as a propositional form which is a


tautology, it can be proved via a truth table.

Theorem 1.1 Either 5 is prime or 5 is not prime.

Proof: p: 5 is prime.

p ¬p p ∨ ¬p
F T T
T F T

Most theorems are expressed as implications, i.e., p → q.


Recall

Implication
p q p→q
F F T
F T T
T F F
T T T

12
Methods of Proof

1. Vacuous Proof: Prove that p is false.

Theorem 1.2 If an integer n is both even and odd,


then n is larger than one trillion.

Proof: There is no integer which is both even and odd.


2

2. Trivial Proof: Prove that q is true.

Theorem 1.3 If n! · 10n is divisible by 6 for some n


larger than 1000, then 5 is prime.

Proof: Neither 2, 3, 4 divides evenly into 5. 2

3. Direct Proof: Assume p is true and use logical arguments


to show that q is also true.

Theorem 1.4 If an integer n is divisible by 10, then


it is also divisible by 5.

Proof: If 10|n, then n = 10·y for some integer y. Hence


n = 5 · (2y) for some integer 2y. Thus 5|n. 2

13
4. Indirect Proof: Prove ¬q → ¬p directly.

Theorem 1.5 Given any integer n, if n2 is even, then


n is even.

Proof: Suppose n is odd. Then n = 2k + 1 for some


integer k. Thus n2 = 4k 2 + 4k + 1 = 2(2k 2 + 2k) + 1 and
hence n2 is odd. 2

5. Case Analysis: Sometimes the argument should be done


on a case by case basis.

Theorem 1.6 The square of any odd integer has the


form 8m + 1 for some integer m.

Proof: Any integer can be written as either 4q, 4q + 1,


4q + 2, or 4q + 3 for some integer q. If an integer n is odd,
we can assume either n = 4q + 1 or n = 4q + 3.

Case 1: n = 4q + 1.

Then (leaving out some algebra) we have


n2 = 8(2q 2 + q) + 1. Let m = 2q 2 + q.

Case 2: n = 4q + 3.

Now we get n2 = 8(2q 2 +3q +1)+1. Let m = 2q 2 +3q +1.


2

14
6. Reductio ad Absurdum or Proof by Contradiction: To
prove a proposition p, assume p is false and show this
leads to an absurd conclusion. Thus p must be true.

Theorem 1.7 2 is irrational.

Proof: Suppose 2 = m/n, i.e., it is rational. We may
assume that m/n is reduced to lowest terms. Then
(a) 2 = m2/n2
(b) m2 = 2n2
(c) m2 is even
(d) m is even
(e) m = 2k for some integer k
(f) By (b), 4k 2 = 2n2
(g) n2 = 2k 2
(h) n2 is even
(i) As in (d), n is even
Thus both m and n are even, and hence m/n is √ not
reduced to lowest terms, a contradiction. Thus 2 is
irrational.2

2

Theorem 1.8 If k 6= a for any integer a, then k is
irrational.

Corollary 1.9 2 is irrational.

15
To disprove a theorem it is only necessary to construct one
counterexample.

Statement: For all real numbers a and b, if a2 = b2, then


a = b.
False: a = 1, b = −1.
Note: The statement uses a universal quantifier.

Sometimes a Theorem can be proved by an example.

Statement: There exist 2 even integers whose sum is even.

Proof: 4 + 2 = 6.

Note: The above statement uses an existential quantifier.

We now begin to look at universal and existential quantifiers


more closely.

16
2 Quantifiers

The following are not propositions. They are often called open
sentences or open propositions.

1. y > 5
2. He is tall
3. x is a rational number
4. x1 ∨ x2 ∨ . . . ∨ xn = 4

They are not true or false until values are assigned to the vari-
ables.

The variables are

1. y
2. He
3. x
4. x1, x2, . . . , xn

The following are called predicates.

1. >
2. is tall
3. is a rational number
4. =

17
A (unary) predicate with variable x is a formula or sentence
describing the variable x.

The domain D of a variable is the set of all values that may


be substituted for the variable.

Example: (1) : D = I or Z (integers), (3) D = R (real numbers).

By assigning values (from D) to the variables in an open propo-


sition we obtain a proposition (which is either true or false).

Example: (1) y = 10 - true, (3) x = 2 - false.

Quantification

Definition: Universal quantifier - ∀.

∀xP (x) means for all x ∈ D, P (x) is true.

The symbol ∀ has the following english translations:

• for all
• for every
• for any
• for arbitrary
• for each

18
Definition: Existential quantifier - ∃.

∃xP (x) means that there exists an x ∈ D for which P (x) is


true.

The symbol ∃ has the following english translations:

• there exists
• for some
• for at least one

A less common quantifier is the following:

∃!xP (x) means that there exists a unique x ∈ D for which


P (x) is true.

The symbol ∃! has the following english translations:

• there exists a unique


• there is one and only one

19
Examples:

1. ∀x [2x > x]. If D = P (positive integers) this is true. If


D = I (integers) this is false (x = 0).
2. ∃x [x = x + 10]. If D = R (reals) this is false.
3. ∃x [x = 10x]. If D = R this is true (x = 0). If D = P this
is false.
4. ∃!x [x < 1]. If D = N (natural numbers - 0, 1, 2, . . .) this
is true. (x = 0)
5. ∃!x [x ≥ 2]. If D = N this is false.

Sometimes predicates have more than one variable.

Example: P (x, y) : [x = y + 5].

The variables x, y above are often called “free variables”. To


turn such a predicate into a proposition, the variables must be
“bound”, i.e., they must be given values or quantified.

Example: P (y) : [2 = y + 5] now has one free variable, but it


is still not a proposition. On the other hand, ∀y[2 = y + 5] is
now a proposition, i.e., it has no free variables. If D = R it is
false.

20
Validity in Predicate Logic

The truth value of propositions in propositional logic depends


solely on the truth value of the atoms. If there are n atoms,
the pososition is a tautology if it is true in all 2n possible truth
assignments. The analogue of tautology in predicate logic is
the notion of validity.

Definition: A statement involving predicates and quantifiers


is valid if it is true in every domain D no matter how the
variables are interperted.

The following can be taken as valid.

1. ¬∀xP (x) ↔ ∃x¬P (x).


2. ¬∃xP (x) ↔ ∀x¬P (x).

More than one quantifier

The following can also be taken as valid.

• ∀x ∀yP (x, y) ↔ ∀y ∀xP (x, y)


• ∃x ∃yP (x, y) ↔ ∃y ∃xP (x, y)

However in general, the order of the quantifiers is important.

21
Example:

1. ∀x ∃y [x is married to y]
2. ∃y ∀x [x is married to y]

(1) and (2) above are not saying the same thing.

Example: Let D = I.

1. ∀x ∃y [x + y = 10] is true.
2. ∃y ∀x [x + y = 10] is false.

Example: ∀x ∀y ∃z [x + z = y].

If D = I it is true, but if D = N it is false. One way to see it


is false for D = N is to show its negation is true.

¬(∀x ∀y ∃z [x + z = y]) ↔ ∃x ∃y ∀z [x + z 6= y]. This is


true (x = 10, y = 5).

Recall from calculus that limx→a f (x) = L means


∀  > 0 ∃ δ > 0 such that ∀x [|x − a| < δ → |f (x) − L| < ].

Hence the negation limx→a f (x) 6= L is given by

∃  > 0 ∀ δ > 0 ∃x [|x − a| < δ ∧ |f (x) − L| ≥ ].

Note: We are using the fact that ¬(p → q) ↔ p ∧ ¬q is a


tautology.

22
Question: Since there are infinitely many interpretations of
any quantified proposition, how can we ever decide if a quan-
tified proposition is valid?
Answer: No general algorithm (like using truth tables to de-
cide tautologies) exists to answer this question.
Note: It’s not because we’re too stupid to find the algorithm.
In 1936 Alonzo Church proved that no such algorithm exists.

Translating mathematical statements into logical notation


Let D = I and
• N(x): x is a nonnegative integer.
• E(x): x is an even integer.
• O(x): x is a odd integer.
• P(x): x is a prime.
1. Every integer is either even or odd.
∀x [E(x) ∨ O(x)]
2. The only even prime is 2.
∀x [(E(x) ∧ P (x)) → x = 2]
3. There is one and only one even prime.
∃!x [E(x) ∧ P (x)]
4. Not all primes are odd.
¬∀x [P (x) → O(x)]
5. The sum of an even integer and an odd integer is an odd
integer.
∀x ∀y [E(x) ∧ O(y) → O(x + y)]

23
Proving Theorems (again)

1. To prove ¬∃xP (x) we usually use a proof by contradiction.

Theorem 2.1 There is no largest prime.

Proof (Euclid): Suppose there is a largest prime p.


Then there are only finitely many primes. Let r be the
product of all these primes, i.e., r = 2 · 3 · 5 · · · p. Now
consider r + 1. Since r + 1 > p it is not prime and hence
r + 1 = p1p2 · · · pm, where each pi, 1 ≤ i ≤ m, is prime.
Thus p1|(r+1). However since r+1 = 2·3·5 · · · p1 · · · p+1,
we also have that p1 does not divide r + 1, a contradiction.
2
2. To prove ∃xP (x), we may use either a constructive or
nonconstructive proof. A constructive proof involves
finding a value a ∈ D such that P (a) is true, or an algo-
rithm for finding such an a.

Theorem 2.2 There exists a real number x such that


x2 + 3x + 2 = 0.

Proof: Let x = −1.

A nonconstructive proof is usually a proof by con-


tradiction. The next two theorems illustrate the type of
results that can be established using a proof by contradic-
tion.

Theorem 2.3 (Intermediate Value Theorem) Suppose


f (x) is continuous on [a, b] and f (a) < 0, f (b) > 0.
Then ∃z ∈ (a, b) such that f (z) = 0.
24
Let X be some metric space (think of the points on an
8 1/2 x 11 piece of paper). Let T : X → X be a func-
tion that takes points of X to other points of X. Let
d : XxX → R be a function that measures the distance
between 2 points of X.

Theorem 2.4 (Contraction Mapping Theorem) Let T :


X → X and suppose ∃ a real number r, 0 < r < 1, such
that d(T (x), T (y)) ≤ rd(x, y) ∀x, y ∈ X. Then there
exists a unique point x0 such that T (x0) = x0.

3. To prove ¬∀xP (x) we usually prove ∃x¬P (x) (either con-


tructively or nonconstructively).
4. To prove ∀xP (x) we show P (x) is true for an arbitrary
x ∈ D. If D is finite, this can sometimes be done by the
method of exhaustion.

Theorem 2.5 ∀n ∈ Z, if n is even and 4 ≤ n ≤ 30,


then n can be written as the sum of 2 prime numbers.

Proof: See p. 130 and p. 139 (bottom) of the text.

If D is infinite (e.g. D = Z, the integers), then a more


general argument is needed.

25
Theorem 2.6 If the sum of 2 integers is even, then
so is their difference.

Proof: Let m, n ∈ Z and suppose m + n is even, i.e.,


m + n = 2k for some integer k. Then m = 2k − n and so
m − n = (2k − n) − n
= 2k − 2n
= 2(k − n).

Since k − n is an integer, m − n is even.2

26
3 Elementary Set Theory

A set can be thought of as a collection of objects. More tech-


nically, it is an undefined term, such as point and line in ge-
ometry.

Examples:

• S = {1, 3, 6}
• S = {0, 2, 4, 6, . . .} - the nonnegative even integers
• S = {x | x is a prime and 10 ≤ x ≤ 20}

Note: The element x is not the same as the set {x}.

Sets are completely specified by their elements.

Axiom of Extension: Two sets A and B are equal iff they


have the same elements, i.e.,

A = B ⇔ ∀x [x ∈ A ↔ x ∈ B]

Example: {1, 2, 2} = {1, 2} = {2, 1}.

Definition: A is a subset of B if every element of A is also


an element of B.
Notation: A ⊆ B

Definition: A is a proper subset of B if A is a subset of B


and A 6= B.

27
The following theorem is used to show 2 sets are equal.

Theorem 3.1 A = B iff A ⊆ B and B ⊆ A.

The book talks about “element proofs” and “algebraic proofs”.


We will emphasize the element proofs. Here is a simple exam-
ple.

Theorem 3.2 If A ⊆ B and B ⊆ C, then A ⊆ C.

Proof: Suppose x ∈ A. Since A ⊆ B, x ∈ B. Now since


B ⊆ C, x ∈ C. Hence A ⊆ C. 2

Definition: A set with no elements is called the empty set,


denoted φ.

Theorem 3.3 For any set A, φ ⊆ A.

Proof: We must show x ∈ φ ⇒ x ∈ A. This is vacuously


true.2

28
Operations on Sets

1. The union of two sets A and B is A ∪ B =


{x | x ∈ A ∨ x ∈ B}.
2. The intersection of two sets A and B is A ∩ B =
{x | x ∈ A ∧ x ∈ B}.
3. The set difference of two sets A and B is A − B =
{x | x ∈ A ∧ x ∈
/ B}.
4. The symmetric difference of two sets A and B is
A ⊕ B = (A − B) ∪ (B − A).
5. If B ⊆ A, the relative complement of B in A is
B c = A − B.
6. If A is a set in a universe (or domain) U , then the com-
plement of A is given by Ac = U − A.

Example: A = {0, 1, 2} and B = {1, 2, 3}.

• A ∪ B = {0, 1, 2, 3}
• A ∩ B = {1, 2}
• A − B = {0}
• B − A = {3}
• A ⊕ B = {0, 3}
• Ac in B is not defined.

Note: On p. 233 of the text there is a discussion of “Venn


Diagrams”. These can be useful to get insight, but there is no
such thing as “Proof by Venn Diagram”!

29
The following two theorems are immediate.

Theorem 3.4 A ∪ B = B ∪ A.

Theorem 3.5 A ∩ B = B ∩ A.

We say set union and set intersection are commutative. The


following theorem shows that set union is associative.

Theorem 3.6 (A ∪ B) ∪ C = A ∪ (B ∪ C).

Proof: (⊆) Let x ∈ (A ∪ B) ∪ C. Then either x ∈ A ∪ B


or x ∈ C.

Case 1: x ∈ C.
Then x ∈ B ∪ C. Thus x ∈ A ∪ (B ∪ C).

Case 2: x ∈ A ∪ B
Then x ∈ A ∨ x ∈ B. If x ∈ A, then x ∈ A ∪ (B ∪ C). If
x ∈ B, then x ∈ B ∪ C. Hence x ∈ A ∪ (B ∪ C).

(⊇) - Done similarly. 2

30
The next theorem says that set intersection is also associative.

Theorem 3.7 (A ∩ B) ∩ C = A ∩ (B ∩ C).

Note: As a result, A ∪ B ∪ C and A ∩ B ∩ C are well-defined.

Note: Subtraction is an operation that is not associative.


What is 10 − 5 − 2?

(10 − 5) − 2 = 5 − 2 = 3 and 10 − (5 − 2) = 10 − 3 = 7.

The next theorem says that union and intersection distribute


over each other.

Theorem 3.8 1. A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C).


2. A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).

Theorem 3.9 A − (B ∪ C) = (A − B) ∩ (A − C).

Proof: (⊆) Suppose x ∈ A − (B ∪ C) Then x ∈ A and


x∈/ B ∪ C. Hence x ∈
/ B and x ∈
/ C. Since x ∈ A and x ∈
/B
we have x ∈ A − B. Also since x ∈ A and x ∈ / C we have
x ∈ A − C. Thus x ∈ (A − B) ∩ (A − C).

(⊇) Try it.

31
There is a version of De Morgan’s Laws that is exactly anal-
ogous to the version we’ve seen concerning the connectives ∨
and ∧. We’ll state them without proof for now.

Theorem 3.10 (De Morgan’s Laws)

1. (A ∪ B)c = Ac ∩ B c.
2. (A ∩ B)c = Ac ∪ B c.

Actually, De Morgans’s Laws hold even if we have more than


2 sets.

Definition: The power set of a set A, denoted P (A), is the


set of all subsets of A.

Example: A = {1, 2}.

P (A) = {φ, {1}, {2}, {1, 2}}.

Question: If |A| = n, what is |P (A)|?

32
Answer: |P (A)| = 2n. Every subset of A can be thought of
as assigning a 0 or 1 to each element in A. There are 2n ways
to do this.

Example: A = {1, 2, 3}.

0 0 0 φ
0 0 1 {3}
0 1 0 {2}
0 1 1 {2, 3}
1 0 0 {1}
1 0 1 {1, 3}
1 1 0 {1, 2}
1 1 1 {1, 2, 3}.

Definition: If A ∩ B = φ, then A and B are called disjoint.


If C is a collection of sets such that any two sets are disjoint,
they are called pairwise disjoint.

Example: A1 = {1, 2}, A2 = {2, 3}, A3 = {3, 4}.

Even though A1 ∩ A2 ∩ A3 = φ, they are not pairwise disjoint


since, e.g., A1 ∩ A2 = {2}.

Example: A1 = {1, 2}, A2 = {3, 4}, A3 = {5, 6} are pairwise


disjoint.

33
Definition: A collection of nonempty sets {A1, A2, . . . , An} is
a partition of a set A if, and only if

1. A = A1 ∪ A2 ∪ . . . ∪ An;
2. A1, A2, . . . , An are pairwise disjoint.

Example: Consider the set of integers Z. Then the following


3 sets form a partition of Z.

• T0 = {n ∈ Z | n = 3k for some integer k},


• T1 = {n ∈ Z | n = 3k + 1 for some integer k},
• T2 = {n ∈ Z | n = 3k + 2 for some integer k}.

Recall that the definition of a set is unaffected by the order in


which its elements are listed or if elements are listed more than
once. However sometimes we want the order to be important.

Definition: An n-tuple is an ordered collection of n items.

Example: (1, 3, 2) 6= (3, 1, 2).

Two n-tuples (u1, u2, . . . , un) and (v1, v2, . . . , vn) are equal iff
ui = vi, 1 ≤ i ≤ n.

34
Definition: The Cartesian Product of sets S and T , de-
noted SxT , is the set of all ordered pairs (s, t), where s ∈ S
and t ∈ T , i.e., SxT = {(s, t) | s ∈ S ∧ t ∈ T }. If S = T we
denote SxT as S 2.

Some Examples:

1. A = {1, 2}, B = {3, 4}. AxB = {(1, 3), (1, 4), (2, 3), (2, 4)}.
2. φxA = Axφ = φ.
3. If R is the real numbers, then R2 = RxR represents the
points in the plane. In general, Rn = RxRx . . . xR are
the points in n dimentional space. If C is the complex
numbers, then C = RxR, e.g., 3 + 5i is identified with
(3, 5).
4. Let A1 = A2 = · · · = An = {0, 1}. Then A1xA2x . . . xAn =
{0, 1}n. What is |{0, 1}n|?
5. A = {x, y}, B = {1, 2, 3}, C = {a, b}.
Then (AxB)xC = {((x, 1), a), ((x, 2), a), ((x, 3), a), ((y, 1), a),
((y, 2), a), ((y, 3), a), ((x, 1), b), ((x, 2), b), ((x, 3), b),
((y, 1), b), ((y, 2), b), ((y, 3), b)}.

35
Formal Languages

Computer languages are similar to English in many respects.


Certain “words” or “strings” are legitimate and others are not.
Certain “syntax” is legitimate, just as correct grammatical con-
structions are legitimate. Languages in Computer Science are
studied formally in Automata Theory, however we will intro-
duce some of the basic ideas here.

Let Σ be a nonempty finite set of symbols. We call Σ an al-


phabet.

Example: Σ = {0, 1}, Σ = {a, b} Σ = {a, b, c}.

Definition: A string or word of an alphabet Σ is either

1. an n-tuple of elements of Σ written without parenthesis or


commas, or
2. the empty word (or null string), denoted e.

Example: Σ = {a, b}. Then aba, bb, aab are strings over Σ.

Definition: The length of a string of an alphabet is the num-


ber of characters that make up the string.

Notation: Σn denotes the strings over Σ with n letters.

36
Definition: The set of nonempty strings over an alphabet Σ
is given by Σ+. If we wish to include the empty string, we use
Σ∗, i.e., Σ∗ = Σ+ ∪ {e} is the set of all finite strings over Σ.

Example: Let Σ = {a, b}. Then aab, abba, a, bbb, e ∈ Σ∗.

Definition: A formal language over an alphabet is any


set of words of the alphabet.

Example: Let Σ = {a, b}.

1. L1 = the set of all strings of length 4 that begin with b.


2. L2 = the set of all palindromes, i.e., all strings that read
the same forward as backward, e.g., abba.

Note: L1 ∩ L2 = {bbbb, baab}

The most common operation one does on the words of a lan-


guage is the operation of concatenation.

Definition: If x = a1a2 . . . an and y = b1b2 . . . bm are words


of a language Σ∗, then x concatenated with y is given by
a1a2 . . . anb1b2 . . . bm . If x = e, then, xy = b1b2 . . . bm. If
y = e, then, xy = a1a2 . . . an.
Very often the symbol ∗ is used to denote the operation of
concatenation - but not in our text.
Example: Let Σ = {a, b}. Then (Σ∗, ∗) denotes the operation
of concatenation on words of Σ∗, e.g., aab ∗ bbab = aabbbab.

37
Before leaving “elementary” set theory, we discuss Russell’s
Paradox. This will indicate that set theory is more compli-
cated than it first appears.

Russell’s Paradox

First realize that sets can be elements of other sets.

• {A, B, {A, B}} is a set with 3 elements, namely A, B, {A, B}.


• {{a, b, c}, {b, c}, a, b} has 4 elements.
• {φ} has one element, namely the empty set.
• {{φ}, {{φ}}} has 2 elements, namely {φ}, {{φ}}.

Example: Let S1 = {John, M ary}, S2 = {{John, M ary}}


and S3 = {{{John, M ary}}}. Then

• John ∈ S1
• John ∈
/ S2
• John ∈
/ S3
• S1 ∈ S2
• S1 ∈
/ S3
• S2 ∈ S3

38
Note: It is also possible for a set to be an element of itself.

• Consider the set of all “concepts”.


• Consider the set of all things that are not chairs.
• Consider the set of all sets.
These examples may not be satisfying, but there is nothing
wrong with them.

Given that some sets are elements of themselves and some


are not, let S be the set of all sets which are not elements of
themselves, i.e.,
S = {x | x ∈
/ x}
Question: Is S ∈ S?

• If S ∈ S, then S ∈
/ S.
• If S ∈
/ S, then S ∈ S.
Russell, together with A. N. Whitehead, spent 10 years writ-
ing Principia Mathematica to correct this problem and put set
theory back on a firm foundation. A simple solution, given in
our book, is to require that whenever a set is defined using a
predicate as a defining property, it must be stipulated that the
set is a subset of a known set. Thus we can not talk about
“the set of all sets that are not elements of themselves”. We
can only talk about “the set of all sets that are elements of a
“collection” of sets and are not elements of themselves”.

39
Let U be a collection of sets.

S = {A ∈ U | A ∈
/ A}.

Question: Is S ∈ S?

Now the answer is clearly no! If we suppose S ∈ S, then S


satisfies the defining property of being in S, and so S ∈/ S.
If we suppose S ∈ / S, then it does not follow that S ∈ S. It
simply means S ∈ / U.

Halting Problem

Anyone who has written a computer program knows the frus-


tration of having the program, together with a set of data, go
into an infinite loop. It would be nice to have a program (call
it CheckHalt) that can be used to test any program with its
data and print out one of two things:

1. “halts” - if program X terminates in a finite number of


steps when run with data set D.
2. “loops forever” - otherwise.

Question: Is it possible to write such a program?

Answer: In the 1930’s Alan Turing proved that the answer is


No.

40
The argument is similar to the one used in Russell’s Paradox.

Note: To simplify things, let’s consider letting D be the string


of characters of the program X. Hence we will run CheckHalt
(X,X).

Create a new program called “Test”. Doctor up the program


as follows: For any input algorithm X, Test (X)

• loops forever if CheckHalt (X,X) prints “halts”


• stops if CheckHalt (X,X) prints “loops forever”

It sounds crazy to do this, but it’s only being done to make a


point. The important fact is that if CheckHalt exists, there’s
no reason why this can’t be done.

Now run algorithm Test with input Test, i.e., run Test(Test).

• If Test(Test) terminates, then the value of CheckHalt (Test,Test)


is “halts”, and Test(Test) loops forever.
• If Test(Test) does not terminate, then CheckHalt (Test,Test)
prints “loops forever” and so Test(Test) terminates.

This is a contradiction, and so the program CheckHalt can not


exist.

41

You might also like