CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160...
Transcript of CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160...
![Page 1: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/1.jpg)
CIS160Mathematical Foundations of
Computer ScienceSome Notes
Jean GallierDepartment of Computer and Information Science
University of PennsylvaniaPhiladelphia, PA 19104, USAe-mail: [email protected]
c� Jean GallierPlease, do not reproduce without permission of the author
December 15, 2009
![Page 2: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/2.jpg)
2
![Page 3: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/3.jpg)
Contents
1 Mathematical Reasoning, Proof Princi-ples and Logic 71.1 Problems, Motivations . . . . . . . . . . . 71.2 Inference Rules, Deductions, The Proof
Systems N⇒m and NG⇒m . . . . . . . . . . 19
1.3 Adding ∧, ∨, ⊥; The Proof SystemsN⇒,∧,∨,⊥
c and NG⇒,∧,∨,⊥c . . . . . . . . . 46
1.4 Clearing Up Differences Between Rules In-volving ⊥ . . . . . . . . . . . . . . . . . . 71
1.5 De Morgan Laws and Other Rules of Clas-sical Logic . . . . . . . . . . . . . . . . . 80
1.6 Formal Versus Informal Proofs; Some Ex-amples . . . . . . . . . . . . . . . . . . . 85
1.7 Truth Values Semantics for Classical Logic 1031.8 Adding Quantifiers; The Proof Systems
N⇒,∧,∨,∀,∃,⊥c , NG⇒,∧,∨,∀,∃,⊥
c . . . . . . . . 1131.9 First-Order Theories . . . . . . . . . . . . 1481.10 Basics Concepts of Set Theory . . . . . . 166
3
![Page 4: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/4.jpg)
4 CONTENTS
2 Relations, Functions, Partial Functions 1932.1 What is a Function? . . . . . . . . . . . . 1932.2 Ordered Pairs, Cartesian Products, Rela-
tions, etc. . . . . . . . . . . . . . . . . . . 2032.3 Induction Principles on N . . . . . . . . . 2192.4 Composition of Relations and Functions . 2412.5 Recursion on N . . . . . . . . . . . . . . . 2452.6 Inverses of Functions and Relations . . . . 2502.7 Injections, Surjections, Bijections, Permu-
tations . . . . . . . . . . . . . . . . . . . 2582.8 Direct Image and Inverse Image . . . . . . 2682.9 Equinumerosity; Pigeonhole Principle;
Schroder–Bernstein . . . . . . . . . . . . . 2742.10 An Amazing Surjection: Hilbert’s Space
Filling Curve . . . . . . . . . . . . . . . . 2982.11 Strings, Multisets, Indexed Families . . . . 302
3 Graphs, Part I: Basic Notions 3193.1 Why Graphs? Some Motivations . . . . . 3193.2 Directed Graphs . . . . . . . . . . . . . . 3243.3 Path in Digraphs; Strongly Connected Com-
ponents . . . . . . . . . . . . . . . . . . . 3363.4 Undirected Graphs, Chains, Cycles, Con-
nectivity . . . . . . . . . . . . . . . . . . 3623.5 Trees and Arborescences . . . . . . . . . . 380
![Page 5: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/5.jpg)
CONTENTS 5
3.6 Minimum (or Maximum) Weight SpanningTrees . . . . . . . . . . . . . . . . . . . . 389
4 Some Counting Problems; MultinomialCoefficients 4014.1 Counting Permutations and Functions . . 4014.2 Counting Subsets of Size k; Multinomial
Coefficients . . . . . . . . . . . . . . . . . 4074.3 Some Properties of the Binomial Coefficients4234.4 The Inclusion-Exclusion Principle . . . . . 446
5 Partial Orders, Equivalence Relations, Lat-tices 4595.1 Partial Orders . . . . . . . . . . . . . . . 4595.2 Lattices and Tarski’s Fixed Point Theorem 4785.3 Well-Founded Orderings and Complete In-
duction . . . . . . . . . . . . . . . . . . . 4875.4 Unique Prime Factorization in Z and GCD’s5025.5 Equivalence Relations and Partitions . . . 5215.6 Transitive Closure, Reflexive and Transi-
tive Closure . . . . . . . . . . . . . . . . 5335.7 Fibonacci and Lucas Numbers; Mersenne
Primes . . . . . . . . . . . . . . . . . . . 5365.8 Distributive Lattices, Boolean Algebras, Heyt-
ing Algebras . . . . . . . . . . . . . . . . 570
![Page 6: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/6.jpg)
6 CONTENTS
![Page 7: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/7.jpg)
Chapter 1
Mathematical Reasoning, ProofPrinciples and Logic
1.1 Problems, Motivations
Problem 1. Find formulae for the sums
1 + 2 + 3 + · · · + n = ?
12 + 22 + 32 + · · · + n2 = ?
13 + 23 + 33 + · · · + n3 = ?
· · · · · · · · · · · ·1k + 2k + 3k + · · · + nk = ?
Jacob Bernoulli (1654-1705) discovered the formulae listedbelow:
7
![Page 8: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/8.jpg)
8 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
IfSk(n) = 1k + 2k + 3k + · · · + nk
then
S0(n) = 1n
S1(n) =1
2n2 +
1
2n
S2(n) =1
3n3 +
1
2n2 +
1
6n
S3(n) =1
4n4 +
1
2n3 +
1
4n2
S4(n) =1
5n5 +
1
2n4 +
1
3n3 − 1
30n
S5(n) =1
6n6 +
1
2n5 +
5
12n4 − 1
12n2
S6(n) =1
7n7 +
1
2n6 +
1
2n5 − 1
6n3 +
1
42n
S7(n) =1
8n8 +
1
2n7 +
7
12n6 − 7
24n4 +
1
12n2
S8(n) =1
9n9 +
1
2n8 +
2
3n7 − 7
15n5 +
2
9n3 − 1
30n
S9(n) =1
10n10 +
1
2n9 +
3
4n8 − 7
10n6 +
1
2n4 − 3
20n2
S10(n) =1
11n11 +
1
2n10 +
5
6n9 − n7 + n5 − 1
2n3 +
5
66n
Is there a pattern?
What are the mysterious numbers
11
2
1
60 − 1
300
1
420 − 1
300
5
66?
![Page 9: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/9.jpg)
1.1. PROBLEMS, MOTIVATIONS 9
The next two are
0 − 691
2730Why?
It turns out that the answer has to do with the Bernoullipolynomials , Bk(x), with
Bk(x) =k�
i=0
�k
i
�xk−iBi,
where the Bi are the Bernoulli numbers .
There are various ways of computing the Bernoulli num-bers, including some recurrence formulae.
Amazingly, the Bernoulli numbers show up in very differ-ent areas of mathematics, in particular, algebraic topol-ogy!
![Page 10: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/10.jpg)
10 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
Figure 1.1: Funny spheres (in 3D)
Figure 1.2: A plane (granite slab!)
Problem 2. Prove that a sphere and a plane in 3D havethe same number of points .
More precisely, find a one-to-one and onto mapping of thesphere onto the plane (a bijection)
Actually, there are also bijections between the sphere anda (finite) rectangle, with or without its boundary!
![Page 11: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/11.jpg)
1.1. PROBLEMS, MOTIVATIONS 11
Problem 3. Counting the number of derangements ofn elements.
A permutation of the set {1, 2, . . . , n} is any one-to-onefunction, f , of {1, 2, . . . , n} into itself. A permutation ischaracterized by its image: {f (1), f(2), . . . , f (n)}.
For example, {3, 1, 4, 2} is a permutation of {1, 2, 3, 4}.
It is easy to show that there are n! = n · (n− 1) · · · 3 · 2distinct permutations of n elements.
A derangements is a permutation that leaves no elementfixed, that is, f (i) �= i for all i.
{3, 1, 4, 2} is a derangement of {1, 2, 3, 4} but{3, 2, 4, 1} is not a derangement since 2 is left fixed.
What is the number of derangements , pn, of n elements?
![Page 12: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/12.jpg)
12 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
The number pn/n! can be interpreted as a probability .
Say n people go to a restaurant and they all check theircoat. Unfortunately, the cleck loses all the coat tags.Then, pn/n! is the probability that nobody gets her orhis coat back!
Interestingly, pn/n! has limit 1e ≈
13 as n goes to infinity,
a surprisingly large number.
![Page 13: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/13.jpg)
1.1. PROBLEMS, MOTIVATIONS 13
1
16 17 18 19
10 11 12 13 14 15
5 6 7 8 9
1 2 3 4
Figure 1.3: An undirected graph modeling a city map
Problem 4. Finding strongly connected componentsin a directed graph.
The undirected graph of Figure 1.3 represents a map ofsome busy streets in a city.
The city decides to improve the traffic by making thesestreets one-way streets.
However, a good choice of orientation should allow oneto travel between any two locations. We say that theresulting directed graph is strongly connected .
![Page 14: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/14.jpg)
14 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
1
16 17 18 19
10 11 12 13 14 15
5 6 7 8 9
1 2 3 4
Figure 1.4: A choice of one-way streets
A possibility of orienting the streets is shown in Figure1.4.
Is the above graph strongly connected?
If not, how do we find its strongly connected compo-nents?
How do we use the strongly connected components to findan orientation that solves our problem?
![Page 15: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/15.jpg)
1.1. PROBLEMS, MOTIVATIONS 15
1
d2
d3
dn+1
card 1card 2
card n
Figure 1.5: Stack of overhanging cards
Problem 5. The maximum overhang problem.
How do we stack n cards on the edge of a table, respectingthe law of gravity, and achieving a maximum overhang.
We assume each card is 2 units long.
Is it possible to achieve any desired amount of overhangor is there a fixed bound?
How many cards are needed to achieve an overhang of dunits?
![Page 16: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/16.jpg)
16 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
Problem 6. Ramsey Numbers
A version of Ramsey’s Theorem says that for every pair,(r, s), of positive natural numbers, there is a least positivenatural number, R(r, s), such that for every coloring ofthe edges of the complete (undirected) graph on R(r, s)vertices using the colors blue and red , either there is acomplete subgraph with r vertices whose edges are allblue or there is a complete subgraph with s vertices whoseedges are all red .
So, R(r, r), is the smallest number of vertices of a com-plete graph whose edges are colored either blue or redthat must contain a complete subgraph with r verticeswhose edges are all of the same color.
![Page 17: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/17.jpg)
1.1. PROBLEMS, MOTIVATIONS 17
1
Figure 1.6: Left: A 2-coloring of K5 with no monochromatic K3; Right: A 2-coloring of K6
with several monochromatic K3’s
The graph shown in Figure 1.6 (left) is a complete graphon 5 vertices with a coloring of its edges so that there isno complete subgraph on 3 vertices whose edges are allof the same color.
Thus, R(3, 3) > 5.
There are215 = 32768
2-colored complete graphs on 6 vertices. One of thesegraphs is shown in Figure 1.6 (right).
It can be shown that all of them contain a triangle whoseedges have the same color, so R(3, 3) = 6.
![Page 18: CIS160 Mathematical Foundations of Computer Science …jean/cis160/cis260probs-motiv.pdf · CIS160 Mathematical Foundations of Computer Science Some Notes Jean Gallier Department](https://reader034.fdocuments.in/reader034/viewer/2022051801/5ae1ef7c7f8b9a495c8b75e8/html5/thumbnails/18.jpg)
18 CHAPTER 1. MATHEMATICAL REASONING, PROOF PRINCIPLES AND LOGIC
The numbers, R(r, s), are called Ramsey numbers .
It turns out that there are very few numbers r, s forwhich R(r, s) is known because the number of coloringsof a graph grows very fast! For example, there are
243×21 = 2903 > 102490 > 10270
2-colored complete graphs with 43 vertices, a huge num-ber!
In comparison, the universe is only approximately 14 bil-lions years old, namely 14× 109 years old.
For example, R(4, 4) = 18, R(4, 5) = 25, but R(5, 5) isunknown, although it can be shown that43 ≤ R(5, 5) ≤ 49.
Finding the R(r, s), or, at least some sharp bounds forthem, is an open problem.