Docsity

Mathematical Background for Theoretical Computer Science Course, Lecture notes of Mathematics

Toggle sidebar
bg1
0
Mathematical Background
This is a brief review of some mathematical tools, and especially
probability theory, that we will use in this course. See also the math-
ematical background and probability lectures in my Notes on Intro-
duction to Theoretical Computer Science, which share much of the
following text.
At Harvard, much of this material (and more) is taught in Stat
110 โ€œIntroduction to Probabilityโ€, CS20 โ€œDiscrete Mathematicsโ€, and
AM107 โ€œGraph Theory and Combinatoricsโ€. Some good sources for
this material are the lecture notes by Papadimitriou and Vazirani (see
home page of Umesh Vaziarani), Lehman, Leighton and Meyer from
MIT Course 6.042 โ€œMathematics For Computer Scienceโ€ (Chapters
1-2 and 14 to 19 are particularly relevant), and the Berkeley course CS
70. The mathematical tool we use most often is discrete probability.
The โ€œProbabilistic Methodโ€ book by Alon and Spencer is a great re-
source in this area. Also, the books of Mitzenmacher and Upfal and
Prabhakar and Raghavan cover probability from a more algorithmic
perspective. For an excellent popular discussion of some of the math-
ematical concepts weโ€™ll talk about see the book โ€œHow Not to Be Wrongโ€
by Jordan Ellenberg.
Although knowledge of algorithms is not strictly necessary, it
would be quite useful. Students who did not take an algorithms class
such as CS 124 might want to look at (1) Corman, Leiserson, Rivest
and Smith, (2) Dasgupte, Papadimitriou and Vaziarni, or (3) Klein-
berg and Tardos. We do not require prior knowledge of complexity
or computability but some basic familiarity could be useful. Students
who did not take a theory of computation class such as CS 121 might
want to look at my lecture notes or the first 2 chapters of my book with
Arora.
0.1 A QUICK OVERVIEW OF MATHEMATICAL PREREQUISITES
The main notions we will use in this course are the following:
Compiled on 11.17.2021 22:35
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Mathematical Background for Theoretical Computer Science Course and more Lecture notes Mathematics in PDF only on Docsity!

Mathematical Background

This is a brief review of some mathematical tools, and especially probability theory, that we will use in this course. See also the math- ematical background and probability lectures in my Notes on Intro- duction to Theoretical Computer Science, which share much of the following text. At Harvard, much of this material (and more) is taught in Stat 110 โ€œIntroduction to Probabilityโ€, CS20 โ€œDiscrete Mathematicsโ€, and AM107 โ€œGraph Theory and Combinatoricsโ€. Some good sources for this material are the lecture notes by Papadimitriou and Vazirani (see home page of Umesh Vaziarani), Lehman, Leighton and Meyer from MIT Course 6.042 โ€œMathematics For Computer Scienceโ€ (Chapters 1-2 and 14 to 19 are particularly relevant), and the Berkeley course CS

  1. The mathematical tool we use most often is discrete probability. The โ€œProbabilistic Methodโ€ book by Alon and Spencer is a great re- source in this area. Also, the books of Mitzenmacher and Upfal and Prabhakar and Raghavan cover probability from a more algorithmic perspective. For an excellent popular discussion of some of the math- ematical concepts weโ€™ll talk about see the book โ€œHow Not to Be Wrongโ€ by Jordan Ellenberg. Although knowledge of algorithms is not strictly necessary, it would be quite useful. Students who did not take an algorithms class such as CS 124 might want to look at (1) Corman, Leiserson, Rivest and Smith, (2) Dasgupte, Papadimitriou and Vaziarni, or (3) Klein- berg and Tardos. We do not require prior knowledge of complexity or computability but some basic familiarity could be useful. Students who did not take a theory of computation class such as CS 121 might want to look at my lecture notes or the first 2 chapters of my book with Arora.

0.1 A QUICK OVERVIEW OF MATHEMATICAL PREREQUISITES The main notions we will use in this course are the following:

Compiled on 11.17.2021 22:

24 an intensive introduction to cryptography

  • Proofs: First and foremost, this course will involve a heavy dose of formal mathematical reasoning, which includes mathematical definitions , statements , and proofs.
  • Sets and functions: We will assume familiarity with basic notions of sets and operations on sets such as union (denoted โˆช), intersec- tion (denoted โˆฉ), and set subtraction (denoted โงต). We denote by |๐ด| the size of the set ๐ด. We also assume familiarity with functions, and notions such as one-to-one (injective) functions and onto (surjec- tive) functions. If ๐‘“ is a function from a set ๐ด to a set ๐ต, we denote this by ๐‘“ โˆถ ๐ด โ†’ ๐ต. If ๐‘“ is one-to-one then this implies that |๐ด| โ‰ค |๐ต|. If ๐‘“ is onto then |๐ด| โ‰ฅ |๐ต|. If ๐‘“ is a permutation/bijection (e.g., one-to-one and onto) then this implies that |๐ด| = |๐ต|.
  • Big Oh notation: If ๐‘“, ๐‘” are two functions from โ„• to โ„•, then (1) ๐‘“ = ๐‘‚(๐‘”) if there exists a constant ๐‘ such that ๐‘“(๐‘›) โ‰ค ๐‘ โ‹… ๐‘”(๐‘›) for every sufficiently large ๐‘›, (2) ๐‘“ = ฮฉ(๐‘”) if ๐‘” = ๐‘‚(๐‘“), (3) ๐‘“ = ฮ˜(๐‘”) is ๐‘“ = ๐‘‚(๐‘”) and ๐‘” = ๐‘‚(๐‘“), (4) ๐‘“ = ๐‘œ(๐‘”) if for every ๐œ– > 0, ๐‘“(๐‘›) โ‰ค ๐œ–โ‹…๐‘”(๐‘›) for every sufficiently large ๐‘›, and (5) ๐‘“ = ๐œ”(๐‘”) if ๐‘” = ๐‘œ(๐‘“). To emphasize the input parameter, we often write ๐‘“(๐‘›) = ๐‘‚(๐‘”(๐‘›)) instead of ๐‘“ = ๐‘‚(๐‘”), and use similar notation for ๐‘œ, ฮฉ, ๐œ”, ฮ˜. While this is only an imprecise heuristic, when you see a statement of the form ๐‘“(๐‘›) = ๐‘‚(๐‘”(๐‘›)) you can often replace it in your mind by the statement ๐‘“(๐‘›) โ‰ค 1000๐‘”(๐‘›) while the statement ๐‘“(๐‘›) = ฮฉ(๐‘”(๐‘›)) can often be thought of as ๐‘“(๐‘›) โ‰ฅ 0.001๐‘”(๐‘›).
  • Logical operations: The operations AND, OR, and NOT (โˆง, โˆจ, ยฌ) and the quantifiers โ€œexistsโ€ and โ€œforallโ€ (โˆƒ,โˆ€).
  • Tuples and strings: The notation ฮฃ๐‘˜^ and ฮฃโˆ—^ where ฮฃ is some finite set which is called the alphabet (quite often ฮฃ = {0, 1}).
  • Graphs: Undirected and directed graphs, connectivity, paths, and cycles.
  • Basic combinatorics: Notions such as (๐‘›๐‘˜) (the number of ๐‘˜-sized subset of a set of size ๐‘›).
  • Discrete probability: We will extensively use probability theory , and specifically probability over finite samples spaces such as tossing ๐‘› coins, including notions such as random variables , expectation , and concentration.
  • Modular arithmetic: We will use modular arithmetic (i.e., addition and multiplication modulo some number ๐‘š), and in particular talk about operations on vectors and matrices whose elements are taken modulo ๐‘š. If ๐‘› is an integer, then we denote by ๐‘Ž (mod ๐‘›) the remainder of ๐‘Ž when divided by ๐‘›. ๐‘Ž (mod ๐‘›) is the number

26 an intensive introduction to cryptography

Like any good piece of writing, a proof should be concise and not be overly formal or cumbersome. In fact, overuse of formalism can of- ten be detrimental to the argument since it can mask weaknesses in the argument from both the writer and the reader. Sometimes students try to โ€œthrow the kitchen sinkโ€ at an answer trying to list all possi- bly relevant facts in the hope of getting partial credit. But a proof is a piece of writing, and a badly written proof will not get credit even if it contains some correct elements. It is better to write a clear proof of a partial statement. In particular, if you havenโ€™t been able to convince yourself that the statement is true, you should be honest about it and explain which parts of the statement you have been able to verify and which parts you havenโ€™t.

0.2.1 Example: The existence of infinitely many primes. In the spirit of โ€œdo what I say and not what I doโ€, I will now demon- strate the importance of conciseness by belaboring the point and spending several paragraphs on a simple proof, written by Euclid around 300 BC. Recall that a prime number is an integer ๐‘ > 1 whose only divisors are ๐‘ and 1. Euclidโ€™s Theorem is the following:

Theorem 0.1 โ€” Infinitude of primes. There exist infinitely many primes.

Instead of simply writing down the proof, let us try to understand how we might figure this proof out. (If you havenโ€™t seen this proof before, or you donโ€™t remember it, you might want to stop reading at this point and try to come up with it on your own before continuing.) The first (and often most important) step is to understand what the statement means. Saying that the number of primes is infinite means that it is not finite. More precisely, this means that for every natural number ๐‘˜, there are more than ๐‘˜ primes. Now that we understand what we need to prove, let us try to con- vince ourselves of this fact. At first, it might seem obviousโ€” since there are infinitely many natural numbers, and every one of them can be factored into primes, there must be infinitely many primes, right? Wrong. Since we can multiply a prime many times with itself, a finite number of primes can generate infinitely many numbers. In- deed the single prime 3 generates the infinite set of all numbers of the form 3 ๐‘›. So, what we really need to show is that for every finite set of primes {๐‘ 1 , โ€ฆ , ๐‘๐‘˜}, there exists a number ๐‘› that has a prime factor outside this set. Now we need to start playing around. Suppose that we had just two primes ๐‘ and ๐‘ž. How would we find a number ๐‘› that is not gen- erated by ๐‘ and ๐‘ž? If you try to draw things on the number line, you will see that there is always some gap between multiples of ๐‘ and ๐‘ž in

mathematical background 27

the sense that they are never consecutive. It is possible to prove that (in fact, itโ€™s not a bad exercise) but this observation already suggests a guess for what would be a number that is divisible by neither ๐‘ nor ๐‘ž, namely ๐‘๐‘ž + 1. Indeed, the remainder of ๐‘› = ๐‘๐‘ž + 1 when dividing by either ๐‘ or ๐‘ž would be 1 (which in particular is not zero). This obser- vation generalizes and we can set ๐‘› = ๐‘๐‘ž๐‘Ÿ + 1 to be a number that is divisible neither by ๐‘, ๐‘ž nor ๐‘Ÿ, and more generally ๐‘› = ๐‘ 1 โ‹ฏ , ๐‘๐‘˜ + 1 is not divisible by ๐‘ 1 , โ€ฆ , ๐‘๐‘˜. Now we have convinced ourselves of the statement and it is time to think of how to write this down in the clearest way. One issue that arises is that we want to prove things truly from the definition of primes and first principles, and so not assume properties of division and remainders or even the existence of a prime factorization, without proving it. Here is what a proof could look like. We will prove the following two lemmas:

Lemma 0.2 โ€” Existence of prime divisor. For every integer ๐‘› > 1, there exists a prime ๐‘ > 1 that divides ๐‘›.

Lemma 0.3 โ€” Existence of co-prime. For every set of integers ๐‘ 1 , โ€ฆ , ๐‘๐‘˜ > 1, there exists a number ๐‘› such that none of ๐‘ 1 , โ€ฆ , ๐‘๐‘˜ divide ๐‘›.

From these two lemmas it follows that there exist infinitely many primes, since otherwise if we let ๐‘ 1 , โ€ฆ , ๐‘๐‘˜ be the set of all primes, then we would get a contradiction as by combining Lemma 0.2 and Lemma 0.3 we would get a number ๐‘› with a prime factor outside this set. We now prove the lemmas:

Proof of Lemma 0.2. Let ๐‘› > 1 be a number, and let ๐‘ be the smallest divisor of ๐‘› that is larger than 1 (there exists such a number ๐‘ since ๐‘› divides itself). We claim that ๐‘ is a prime. Indeed suppose otherwise there was some 1 < ๐‘ž < ๐‘ that divides ๐‘. Then since ๐‘› = ๐‘๐‘ for some integer ๐‘ and ๐‘ = ๐‘ž๐‘โ€ฒ^ for some integer ๐‘โ€ฒ^ weโ€™ll get that ๐‘› = ๐‘ž๐‘๐‘โ€ฒ^ and hence ๐‘ž divides ๐‘› in contradiction to the choice of ๐‘ as the smallest divisor of ๐‘›. โ– 

Proof of Lemma 0.3. Let ๐‘› = ๐‘ 1 โ‹ฏ ๐‘๐‘˜ + 1 and suppose for the sake of contradiction that there exists some ๐‘– such that ๐‘› = ๐‘๐‘– โ‹… ๐‘ for some integer ๐‘. Then if we divide the equation ๐‘› โˆ’ ๐‘ 1 โ‹ฏ ๐‘๐‘˜ = 1 by ๐‘๐‘– then we get ๐‘ minus an integer on the lefthand side, and the fraction 1/๐‘๐‘– on the righthand side. โ– 

This completes the proof of Theorem 0.

mathematical background 29

Figure 2 : The event that if we toss three coins ๐‘ฅ 0 , ๐‘ฅ 1 , ๐‘ฅ 2 โˆˆ {0, 1} then the sum of the ๐‘ฅ๐‘–โ€™s is even has probability 1/2 since it corresponds to exactly 4 out of the 8 possible strings of length 3.

๐ด = {000, 011, 101, 110}, and hence Pr[๐ด] = 48 = 12 (see Fig. 2). It turns out this is true for every ๐‘›:

Lemma 0.4 For every ๐‘› > 0,

Pr ๐‘ฅโˆผ{0,1}๐‘›

[

๐‘›โˆ’ โˆ‘ ๐‘–=

๐‘ฅ๐‘– is even ] = 1/

P To test your intuition on probability, try to stop here and prove the lemma on your own.

Proof of Lemma 0.4. We prove the lemma by induction on ๐‘›. For the case ๐‘› = 1 it is clear since ๐‘ฅ = 0 is even and ๐‘ฅ = 1 is odd, and hence the probability that ๐‘ฅ โˆˆ {0, 1} is even is 1/2. Let ๐‘› > 1. We assume by induction that the lemma is true for ๐‘› โˆ’ 1 and we will prove it for ๐‘›. We split the set {0, 1}๐‘›^ into four disjoint sets ๐ธ 0 , ๐ธ 1 , ๐‘‚ 0 , ๐‘‚ 1 , where for ๐‘ โˆˆ {0, 1}, ๐ธ๐‘ is defined as the set of ๐‘ฅ โˆˆ {0, 1}๐‘›^ such that ๐‘ฅ 0 โ‹ฏ ๐‘ฅ๐‘›โˆ’2 has even number of ones and ๐‘ฅ๐‘›โˆ’1 = ๐‘ and similarly ๐‘‚๐‘ is the set of ๐‘ฅ โˆˆ {0, 1}๐‘›^ such that ๐‘ฅ 0 โ‹ฏ ๐‘ฅ๐‘›โˆ’2 has odd number of ones and ๐‘ฅ๐‘›โˆ’1 = ๐‘. Since ๐ธ 0 is obtained by simply extending ๐‘› โˆ’ 1-length string with even number of ones by the digit 0 , the size of ๐ธ 0 is simply the number of such ๐‘› โˆ’ 1-length strings which by the induction hypothesis is 2 ๐‘›โˆ’1/2 = 2๐‘›โˆ’2. The same reasoning applies for ๐ธ 1 , ๐‘‚ 0 , and ๐‘‚ 1. Hence each one of the four sets ๐ธ 0 , ๐ธ 1 , ๐‘‚ 0 , ๐‘‚ 1 is of size 2 ๐‘›โˆ’2. Since ๐‘ฅ โˆˆ {0, 1}๐‘›^ has an even number of ones if and only if ๐‘ฅ โˆˆ ๐ธ 0 โˆช ๐‘‚ 1 (i.e., either the first ๐‘› โˆ’ 1 coordinates sum up to an even number and the final coordinate is 0 or the first ๐‘› โˆ’ 1 coordinates sum up to an odd number and the final coordinate is 1 ), we get that the probability that ๐‘ฅ satisfies this property is

|๐ธ 0 โˆช๐‘‚ 1 | 2 ๐‘›^ =

2 ๐‘›โˆ’2^ + 2๐‘›โˆ’

2 ๐‘›^

=^1

using the fact that ๐ธ 0 and ๐‘‚ 1 are disjoint and hence |๐ธ 0 โˆช ๐‘‚ 1 | = |๐ธ 0 | + |๐‘‚ 1 |. โ–  We can also use the intersection (โˆฉ) and union (โˆช) operators to talk about the probability of both event ๐ด and event ๐ต happening, or the probability of event ๐ด or event ๐ต happening. For example, the probability ๐‘ that ๐‘ฅ has an even number of ones and ๐‘ฅ 0 = 1 is the same as Pr[๐ด โˆฉ ๐ต] where ๐ด = {๐‘ฅ โˆˆ {0, 1}๐‘›^ โˆถ โˆ‘๐‘›โˆ’1๐‘–=0 ๐‘ฅ๐‘– = 0 mod 2} and ๐ต = {๐‘ฅ โˆˆ {0, 1}๐‘›^ โˆถ ๐‘ฅ 0 = 1}. This probability is equal to 1/4 for ๐‘› > 1. (It is a great exercise for you to pause here and verify that you understand why this is the case.)

30 an intensive introduction to cryptography

Because intersection corresponds to considering the logical AND of the conditions that two events happen, while union corresponds to considering the logical OR, we will sometimes use the โˆง and โˆจ operators instead of โˆฉ and โˆช, and so write this probability ๐‘ = Pr[๐ด โˆฉ ๐ต] defined above also as

Pr ๐‘ฅโˆผ{0,1}๐‘›^

[โˆ‘

๐‘–

๐‘ฅ๐‘– = 0 mod 2 โˆง ๐‘ฅ 0 = 1].

If ๐ด โІ {0, 1}๐‘›^ is an event, then ๐ด = {0, 1}๐‘›^ โงต ๐ด corresponds to the event that ๐ด does not happen. Since |๐ด| = 2๐‘›^ โˆ’ |๐ด|, we get that

Pr[๐ด] = |๐ด| 2 ๐‘› = 2 ๐‘›โˆ’|๐ด| 2 ๐‘›^ = 1 โˆ’^

|๐ด| 2 ๐‘›^ = 1 โˆ’^ Pr[๐ด]

This makes sense: since ๐ด happens if and only if ๐ด does not happen, the probability of ๐ด should be one minus the probability of ๐ด.

R Remark 0.5 โ€” Remember the sample space. While the above definition might seem very simple and almost trivial, the human mind seems not to have evolved for probabilistic reasoning, and it is surprising how often people can get even the simplest settings of probability wrong. One way to make sure you donโ€™t get confused when trying to calculate probability statements is to always ask yourself the following two questions: (1) Do I understand what is the sample space that this probability is taken over?, and (2) Do I under- stand what is the definition of the event that we are analyzing?. For example, suppose that I were to randomize seating in my course, and then it turned out that students sitting in row 7 performed better on the final: how surprising should we find this? If we started out with the hypothesis that there is something special about the number 7 and chose it ahead of time, then the event that we are discussing is the event ๐ด that stu- dents sitting in number 7 had better performance on the final, and we might find it surprising. However, if we first looked at the results and then chose the row whose average performance is best, then the event we are discussing is the event ๐ต that there exists some row where the performance is higher than the over- all average. ๐ต is a superset of ๐ด, and its probability (even if there is no correlation between sitting and performance) can be quite significant.

0.3.1 Random variables Events correspond to Yes/No questions, but often we want to analyze finer questions. For example, if we make a bet at the roulette wheel,

32 an intensive introduction to cryptography

Figure 3 : The union bound tells us that the probability of ๐ด or ๐ต happening is at most the sum of the indi- vidual probabilities. We can see it by noting that for every two sets |๐ด โˆช ๐ต| โ‰ค |๐ด| + |๐ต| (with equality only if ๐ด and ๐ต have no intersection).

If ๐ด is an event, then (^1) ๐ด is the random variable such that (^1) ๐ด(๐‘ฅ) equals 1 if ๐‘ฅ โˆˆ ๐ด, and (^1) ๐ด(๐‘ฅ) = 0 otherwise. Note that Pr[๐ด] = ๐”ผ[1๐ด] (can you see why?). Using this and the linearity of expectation, we can show one of the most useful bounds in probability theory:

Lemma 0.7 โ€” Union bound. For every two events ๐ด, ๐ต, Pr[๐ด โˆช ๐ต] โ‰ค Pr[๐ด] + Pr[๐ต]

P Before looking at the proof, try to see why the union bound makes intuitive sense. We can also prove it directly from the definition of probabilities and the cardinality of sets, together with the equation |๐ด โˆช ๐ต| โ‰ค |๐ด| + |๐ต|. Can you see why the latter equation is true? (See also Fig. 3.)

Proof of Lemma 0.7. For every ๐‘ฅ, the variable (^1) ๐ดโˆช๐ต(๐‘ฅ) โ‰ค 1๐ด(๐‘ฅ) + 1๐ต(๐‘ฅ). Hence, Pr[๐ดโˆช๐ต] = ๐”ผ[1๐ดโˆช๐ต] โ‰ค ๐”ผ[1๐ด+1๐ต] = ๐”ผ[1๐ด]+๐”ผ[1๐ต] = Pr[๐ด]+Pr[๐ต]. โ– 

The way we often use this in theoretical computer science is to argue that, for example, if there is a list of 100 bad events that can hap- pen, and each one of them happens with probability at most 1/10000, then with probability at least 1 โˆ’ 100/10000 = 0.99, no bad event happens.

0.3.2 Distributions over strings While most of the time we think of random variables as having as output a real number , we sometimes consider random vari- ables whose output is a string. That is, we can think of a map ๐‘Œ โˆถ {0, 1}๐‘›^ โ†’ {0, 1}โˆ—^ and consider the โ€œrandom variableโ€ ๐‘Œ such that for every ๐‘ฆ โˆˆ {0, 1}โˆ—, the probability that ๐‘Œ outputs ๐‘ฆ is equal to (^21) ๐‘› |{๐‘ฅ โˆˆ {0, 1}๐‘›^ | ๐‘Œ (๐‘ฅ) = ๐‘ฆ}|. To avoid confusion, we will typically refer to such string-valued random variables as distributions over strings. So, a distribution ๐‘Œ over strings {0, 1}โˆ—^ can be thought of as a finite collection of strings ๐‘ฆ 0 , โ€ฆ , ๐‘ฆ๐‘€โˆ’1 โˆˆ {0, 1}โˆ—^ and probabilities ๐‘ 0 , โ€ฆ , ๐‘๐‘€โˆ’1 (which are non-negative numbers summing up to one), so that Pr[๐‘Œ = ๐‘ฆ๐‘–] = ๐‘๐‘–. Two distributions ๐‘Œ and ๐‘Œ โ€ฒ^ are identical if they assign the same probability to every string. For example, consider the following two functions ๐‘Œ , ๐‘Œ โ€ฒ^ โˆถ {0, 1}^2 โ†’ {0, 1}^2. For every ๐‘ฅ โˆˆ {0, 1}^2 , we define ๐‘Œ (๐‘ฅ) = ๐‘ฅ and ๐‘Œ โ€ฒ(๐‘ฅ) = ๐‘ฅ 0 (๐‘ฅ 0 โŠ• ๐‘ฅ 1 ) where โŠ• is the XOR operations. Al- though these are two different functions, they induce the same distri- bution over {0, 1}^2 when invoked on a uniform input. The distribution ๐‘Œ (๐‘ฅ) for ๐‘ฅ โˆผ {0, 1}^2 is of course the uniform distribution over {0, 1}^2.

mathematical background 33

Figure 4 : Two events ๐ด and ๐ต are independent if Pr[๐ด โˆฉ ๐ต] = Pr[๐ด] โ‹… Pr[๐ต]. In the two figures above, the empty ๐‘ฅ ร— ๐‘ฅ square is the sample space, and ๐ด and ๐ต are two events in this sample space. In the left figure, ๐ด and ๐ต are independent, while in the right figure they are negatively correlated, since ๐ต is less likely to occur if we condition on ๐ด (and vice versa). Mathematically, one can see this by noticing that in the left figure the areas of ๐ด and ๐ต respectively are ๐‘Ž โ‹… ๐‘ฅ and ๐‘ โ‹… ๐‘ฅ, and so their probabilities are ๐‘Žโ‹…๐‘ฅ๐‘ฅ 2 = ๐‘Ž๐‘ฅ and ๐‘โ‹…๐‘ฅ๐‘ฅ 2 = (^) ๐‘ฅ๐‘ respectively, while the area of ๐ด โˆฉ ๐ต is ๐‘Ž โ‹… ๐‘ which corresponds to the probability ๐‘Žโ‹…๐‘๐‘ฅ 2. In the right figure, the area of the triangle ๐ต is ๐‘โ‹…๐‘ฅ 2 which corresponds to a probability of (^) 2๐‘ฅ๐‘ , but the area of ๐ด โˆฉ ๐ต is ๐‘โ€ฒ 2 โ‹…๐‘Ž for some ๐‘โ€ฒ^ < ๐‘. This means that the probability of ๐ด โˆฉ ๐ต is ๐‘2๐‘ฅโ€ฒโ‹…๐‘Ž 2 < (^) 2๐‘ฅ๐‘ โ‹… ๐‘Ž๐‘ฅ , or in other words Pr[๐ด โˆฉ ๐ต] < Pr[๐ด] โ‹… Pr[๐ต].

On the other hand ๐‘Œ โ€ฒ^ is simply the map 00 โ†ฆ 00, 01 โ†ฆ 01, 10 โ†ฆ 11, 11 โ†ฆ 10 which is a permutation over the map ๐น โˆถ {0, 1}^2 โ†’ {0, 1}^2 defined as ๐น (๐‘ฅ 0 ๐‘ฅ 1 ) = ๐‘ฅ 0 ๐‘ฅ 1 and the map ๐บ โˆถ {0, 1}^2 โ†’ {0, 1}^2 defined as ๐บ(๐‘ฅ 0 ๐‘ฅ 1 ) = ๐‘ฅ 0 (๐‘ฅ 0 โŠ• ๐‘ฅ 1 )

0.3.3 More general sample spaces. While in this chapter we assume that the underlying probabilistic experiment corresponds to tossing ๐‘› independent coins, everything we say easily generalizes to sampling ๐‘ฅ from a more general finite or countable set ๐‘† (and not-so-easily generalizes to uncountable sets ๐‘† as well). A probability distribution over a finite set ๐‘† is simply a function ๐œ‡ โˆถ ๐‘† โ†’ [0, 1] such that โˆ‘๐‘ฅโˆˆ๐‘† ๐œ‡(๐‘ ) = 1. We think of this as the experiment where we obtain every ๐‘ฅ โˆˆ ๐‘† with probability ๐œ‡(๐‘ ), and sometimes denote this as ๐‘ฅ โˆผ ๐œ‡. An event ๐ด is a subset of ๐‘†, and the probability of ๐ด, which we denote by Pr๐œ‡[๐ด], is โˆ‘๐‘ฅโˆˆ๐ด ๐œ‡(๐‘ฅ). A random variable is a function ๐‘‹ โˆถ ๐‘† โ†’ โ„, where the probability that ๐‘‹ = ๐‘ฆ is equal to โˆ‘๐‘ฅโˆˆ๐‘† s.t. ๐‘‹(๐‘ฅ)=๐‘ฆ ๐œ‡(๐‘ฅ).

0.4 CORRELATIONS AND INDEPENDENCE

One of the most delicate but important concepts in probability is the notion of independence (and the opposing notion of correlations ). Subtle correlations are often behind surprises and errors in probability and statistical analysis, and several mistaken predictions have been blamed on miscalculating the correlations between, say, housing prices in Florida and Arizona, or voter preferences in Ohio and Michigan. See also Joe Blitzsteinโ€™s aptly named talk โ€œConditioning is the Soul of Statisticsโ€. (Another thorny issue is of course the difference between correlation and causation. Luckily, this is another point we donโ€™t need to worry about in our clean setting of tossing ๐‘› coins.) Two events ๐ด and ๐ต are independent if the fact that ๐ด happens makes ๐ต neither more nor less likely to happen. For example, if we think of the experiment of tossing 3 random coins ๐‘ฅ โˆˆ {0, 1}^3 , and we let ๐ด be the event that ๐‘ฅ 0 = 1 and ๐ต the event that ๐‘ฅ 0 + ๐‘ฅ 1 + ๐‘ฅ 2 โ‰ฅ 2, then if ๐ด happens it is more likely that ๐ต happens, and hence these events are not independent. On the other hand, if we let ๐ถ be the event that ๐‘ฅ 1 = 1, then because the second coin toss is not affected by the result of the first one, the events ๐ด and ๐ถ are independent. The formal definition is that events ๐ด and ๐ต are independent if Pr[๐ด โˆฉ ๐ต] = Pr[๐ด] โ‹… Pr[๐ต]. If Pr[๐ด โˆฉ ๐ต] > Pr[๐ด] โ‹… Pr[๐ต] then we say that ๐ด and ๐ต are positively correlated , while if Pr[๐ด โˆฉ ๐ต] < Pr[๐ด] โ‹… Pr[๐ต] then we say that ๐ด and ๐ต are negatively correlated (see Fig. 1). If we consider the above examples on the experiment of choosing ๐‘ฅ โˆˆ {0, 1}^3 then we can see that

mathematical background 35

0.4.1 Independent random variables We say that two random variables ๐‘‹ โˆถ {0, 1}๐‘›^ โ†’ โ„ and ๐‘Œ โˆถ {0, 1}๐‘›^ โ†’ โ„ are independent if for every ๐‘ข, ๐‘ฃ โˆˆ โ„, the events {๐‘‹ = ๐‘ข} and {๐‘Œ = ๐‘ฃ} are independent. (We use {๐‘‹ = ๐‘ข} as shorthand for {๐‘ฅ | ๐‘‹(๐‘ฅ) = ๐‘ข}.) In other words, ๐‘‹ and ๐‘Œ are independent if Pr[๐‘‹ = ๐‘ข โˆง ๐‘Œ = ๐‘ฃ] = Pr[๐‘‹ = ๐‘ข] Pr[๐‘Œ = ๐‘ฃ] for every ๐‘ข, ๐‘ฃ โˆˆ โ„. For example, if two random variables depend on the result of tossing different coins then they are independent:

Lemma 0.9 Suppose that ๐‘† = {๐‘  0 , โ€ฆ , ๐‘ ๐‘˜โˆ’1} and ๐‘‡ = {๐‘ก 0 , โ€ฆ , ๐‘ก๐‘šโˆ’1} are disjoint subsets of {0, โ€ฆ , ๐‘› โˆ’ 1} and let ๐‘‹, ๐‘Œ โˆถ {0, 1}๐‘›^ โ†’ โ„ be random variables such that ๐‘‹ = ๐น (๐‘ฅ๐‘  0 , โ€ฆ , ๐‘ฅ๐‘ ๐‘˜โˆ’1 ) and ๐‘Œ = ๐บ(๐‘ฅ๐‘ก 0 , โ€ฆ , ๐‘ฅ๐‘ก๐‘šโˆ’1 ) for some functions ๐น โˆถ {0, 1}๐‘˜^ โ†’ โ„ and ๐บ โˆถ {0, 1}๐‘š^ โ†’ โ„. Then ๐‘‹ and ๐‘Œ are independent.

P The notation in the lemmaโ€™s statement is a bit cum- bersome, but at the end of the day, it simply says that if ๐‘‹ and ๐‘Œ are random variables that depend on two disjoint sets ๐‘† and ๐‘‡ of coins (for example, ๐‘‹ might be the sum of the first ๐‘›/2 coins, and ๐‘Œ might be the largest consecutive stretch of zeroes in the second ๐‘›/ coins), then they are independent.

Proof of Lemma 0.9. Let ๐‘Ž, ๐‘ โˆˆ โ„, and let ๐ด = {๐‘ฅ โˆˆ {0, 1}๐‘˜^ โˆถ ๐น (๐‘ฅ) = ๐‘Ž} and ๐ต = {๐‘ฅ โˆˆ {0, 1}๐‘š^ โˆถ ๐บ(๐‘ฅ) = ๐‘}. Since ๐‘† and ๐‘‡ are disjoint, we can reorder the indices so that ๐‘† = {0, โ€ฆ , ๐‘˜ โˆ’ 1} and ๐‘‡ = {๐‘˜, โ€ฆ , ๐‘˜ + ๐‘š โˆ’ 1} without affecting any of the probabilities. Hence we can write Pr[๐‘‹ = ๐‘Ž โˆง ๐‘Œ = ๐‘] = |๐ถ|/2๐‘›^ where ๐ถ = {๐‘ฅ 0 , โ€ฆ , ๐‘ฅ๐‘›โˆ’1 โˆถ (๐‘ฅ 0 , โ€ฆ , ๐‘ฅ๐‘˜โˆ’1) โˆˆ ๐ด โˆง (๐‘ฅ๐‘˜, โ€ฆ , ๐‘ฅ๐‘˜+๐‘šโˆ’1) โˆˆ ๐ต}. Another way to write this using string concatenation is that ๐ถ = {๐‘ฅ๐‘ฆ๐‘ง โˆถ ๐‘ฅ โˆˆ ๐ด, ๐‘ฆ โˆˆ ๐ต, ๐‘ง โˆˆ {0, 1}๐‘›โˆ’๐‘˜โˆ’๐‘š}, and hence |๐ถ| = |๐ด||๐ต|2๐‘›โˆ’๐‘˜โˆ’๐‘š, which means that

|๐ถ| 2 ๐‘›^ =^

|๐ด| 2 ๐‘˜

|๐ต| 2 ๐‘š 2 ๐‘›โˆ’๐‘˜โˆ’๐‘š 2 ๐‘›โˆ’๐‘˜โˆ’๐‘š^ =^ Pr[๐‘‹ = ๐‘Ž]^ Pr[๐‘Œ = ๐‘].

โ– 

Note that if ๐‘‹ and ๐‘Œ are independent random variables then (if we let ๐‘†๐‘‹, ๐‘†๐‘Œ denote all the numbers that have positive probability of being the output of ๐‘‹ and ๐‘Œ , respectively) it holds that:

๐”ผ[ XY ] = โˆ‘ ๐‘Žโˆˆ๐‘†๐‘‹,๐‘โˆˆ๐‘†๐‘Œ

Pr[๐‘‹ = ๐‘Ž โˆง ๐‘Œ = ๐‘] โ‹… ๐‘Ž๐‘ =(1)^ โˆ‘ ๐‘Žโˆˆ๐‘†๐‘‹,๐‘โˆˆ๐‘†๐‘Œ

Pr[๐‘‹ = ๐‘Ž] Pr[๐‘Œ = ๐‘] โ‹… ๐‘Ž๐‘ =(2)

๐‘Žโˆˆ๐‘†๐‘‹

Pr[๐‘‹ = ๐‘Ž] โ‹… ๐‘Ž) ( โˆ‘ ๐‘โˆˆ๐‘†๐‘Œ

Pr[๐‘Œ = ๐‘]๐‘) =(3)

๐”ผ[๐‘‹] ๐”ผ[๐‘Œ ]

36 an intensive introduction to cryptography

where the first equality (=(1)) follows from the independence of ๐‘‹ and ๐‘Œ , the second equality (=(2)) follows by โ€œopening the parenthe- sesโ€ of the righthand side, and the third inequality (=(3)) follows from the definition of expectation. (This is not an โ€œif and only ifโ€; see Exercise 0.8.) Another useful fact is that if ๐‘‹ and ๐‘Œ are independent random variables, then so are ๐น (๐‘‹) and ๐บ(๐‘Œ ) for all functions ๐น , ๐บ โˆถ โ„ โ†’ ๐‘…. This is intuitively true since learning ๐น (๐‘‹) can only provide us with less information than does learning ๐‘‹ itself. Hence, if learning ๐‘‹ does not teach us anything about ๐‘Œ (and so also about ๐น (๐‘Œ )) then neither will learning ๐น (๐‘‹). Indeed, to prove this we can write for every ๐‘Ž, ๐‘ โˆˆ โ„:

Pr[๐น (๐‘‹) = ๐‘Ž โˆง ๐บ(๐‘Œ ) = ๐‘] = โˆ‘ ๐‘ฅ s.t.๐น (๐‘ฅ)=๐‘Ž,๐‘ฆ s.t. ๐บ(๐‘ฆ)=๐‘

Pr[๐‘‹ = ๐‘ฅ โˆง ๐‘Œ = ๐‘ฆ] =

โˆ‘ ๐‘ฅ s.t.๐น (๐‘ฅ)=๐‘Ž,๐‘ฆ s.t. ๐บ(๐‘ฆ)=๐‘

Pr[๐‘‹ = ๐‘ฅ] Pr[๐‘Œ = ๐‘ฆ] =

๐‘ฅ s.t.๐น (๐‘ฅ)=๐‘Ž

Pr[๐‘‹ = ๐‘ฅ]โŽžโŽŸ โŽ 

๐‘ฆ s.t.๐บ(๐‘ฆ)=๐‘

Pr[๐‘Œ = ๐‘ฆ]โŽžโŽŸ โŽ 

Pr[๐น (๐‘‹) = ๐‘Ž] Pr[๐บ(๐‘Œ ) = ๐‘].

0.4.2 Collections of independent random variables. We can extend the notions of independence to more than two random variables: we say that the random variables ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 are mutually independent if for every ๐‘Ž 0 , โ€ฆ , ๐‘Ž๐‘›โˆ’1 โˆˆ โ„,

Pr [๐‘‹ 0 = ๐‘Ž 0 โˆง โ‹ฏ โˆง ๐‘‹๐‘›โˆ’1 = ๐‘Ž๐‘›โˆ’1] = Pr[๐‘‹ 0 = ๐‘Ž 0 ] โ‹ฏ Pr[๐‘‹๐‘›โˆ’1 = ๐‘Ž๐‘›โˆ’1].

And similarly, we have that

Lemma 0.10 โ€” Expectation of product of independent random variables. If ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 are mutually independent then

๐”ผ[

๐‘›โˆ’ โˆ ๐‘–=

๐‘‹๐‘–] =

๐‘›โˆ’ โˆ ๐‘–=

๐”ผ[๐‘‹๐‘–].

Lemma 0.11 โ€” Functions preserve independence. If ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 are mu- tually independent, and ๐‘Œ 0 , โ€ฆ , ๐‘Œ๐‘›โˆ’1 are defined as ๐‘Œ๐‘– = ๐น๐‘–(๐‘‹๐‘–) for some functions ๐น 0 , โ€ฆ , ๐น๐‘›โˆ’1 โˆถ โ„ โ†’ โ„, then ๐‘Œ 0 , โ€ฆ , ๐‘Œ๐‘›โˆ’1 are mutually independent as well.

P We leave proving Lemma 0.10 and Lemma 0.11 as Exercise 0.9 Exercise 0.10. It is good idea for you stop now and do these exercises to make sure you are com-

38 an intensive introduction to cryptography

Figure 7 : Markovโ€™s Inequality tells us that a non- negative random variable ๐‘‹ cannot be much larger than its expectation, with high probability. For exam- ple, if the expectation of ๐‘‹ is ๐œ‡, then the probability that ๐‘‹ > 4๐œ‡ must be at most 1/4, as otherwise just the contribution from this part of the sample space will be too large.

Proof of Theorem 0.12. Let ๐œ‡ = ๐”ผ[๐‘‹] and define ๐‘Œ = 1๐‘‹โ‰ฅ๐‘˜๐œ‡. That is, ๐‘Œ (๐‘ฅ) = 1 if ๐‘‹(๐‘ฅ) โ‰ฅ ๐‘˜๐œ‡ and ๐‘Œ (๐‘ฅ) = 0 otherwise. Note that by definition, for every ๐‘ฅ, ๐‘Œ (๐‘ฅ) โ‰ค ๐‘‹/(๐‘˜๐œ‡). We need to show ๐”ผ[๐‘Œ ] โ‰ค 1/๐‘˜. But this follows since ๐”ผ[๐‘Œ ] โ‰ค ๐”ผ[๐‘‹/๐‘˜(๐œ‡)] = ๐”ผ[๐‘‹]/(๐‘˜๐œ‡) = ๐œ‡/(๐‘˜๐œ‡) = 1/๐‘˜. โ– 

Going beyond Markovโ€™s Inequality: Markovโ€™s inequality says that a (non- negative) random variable ๐‘‹ canโ€™t go too crazy and be, say, a million times its expectation, with significant probability. But ideally we would like to say that with high probability, ๐‘‹ should be very close to its expectation, e.g., in the range [0.99๐œ‡, 1.01๐œ‡] where ๐œ‡ = ๐”ผ[๐‘‹]. This is not generally true, but does turn out to hold when ๐‘‹ is obtained by combining (e.g., adding) many independent random variables. This phenomenon, variants of which are known as โ€œlaw of large num- bersโ€, โ€œcentral limit theoremโ€, โ€œinvariance principlesโ€ and โ€œChernoff boundsโ€, is one of the most fundamental in probability and statistics, and is one that we heavily use in computer science as well.

0.5.1 Chebyshevโ€™s Inequality A standard way to measure the deviation of a random variable from its expectation is by using its standard deviation. For a random variable ๐‘‹, we define the variance of ๐‘‹ as Var[๐‘‹] = ๐”ผ[(๐‘‹ โˆ’ ๐œ‡)^2 ] where ๐œ‡ = ๐”ผ[๐‘‹]; i.e., the variance is the average squared distance of ๐‘‹ from its expectation. The standard deviation of ๐‘‹ is defined as ๐œŽ[๐‘‹] = โˆšVar[๐‘‹]. (This is well-defined since the variance, being an average of a square, is always a non-negative number.) Using Chebyshevโ€™s inequality, we can control the probability that a random variable is too many standard deviations away from its expectation.

Theorem 0.13 โ€” Chebyshevโ€™s inequality. Suppose that ๐œ‡ = ๐”ผ[๐‘‹] and ๐œŽ^2 = Var[๐‘‹]. Then for every ๐‘˜ > 0, Pr[|๐‘‹ โˆ’ ๐œ‡| โ‰ฅ ๐‘˜๐œŽ] โ‰ค 1/๐‘˜^2.

Proof. The proof follows from Markovโ€™s inequality. We define the random variable ๐‘Œ = (๐‘‹ โˆ’ ๐œ‡)^2. Then ๐”ผ[๐‘Œ ] = Var[๐‘‹] = ๐œŽ^2 , and hence by Markov the probability that ๐‘Œ > ๐‘˜^2 ๐œŽ^2 is at most 1/๐‘˜^2. But clearly (๐‘‹ โˆ’ ๐œ‡)^2 โ‰ฅ ๐‘˜^2 ๐œŽ^2 if and only if |๐‘‹ โˆ’ ๐œ‡| โ‰ฅ ๐‘˜๐œŽ. โ– 

One example of how to use Chebyshevโ€™s inequality is the setting when ๐‘‹ = ๐‘‹ 1 + โ‹ฏ + ๐‘‹๐‘› where ๐‘‹๐‘–โ€™s are independent and identically distributed (i.i.d for short) variables with values in [0, 1] where each has expectation 1/2. Since ๐”ผ[๐‘‹] = โˆ‘๐‘– ๐”ผ[๐‘‹๐‘–] = ๐‘›/2, we would like to say that ๐‘‹ is very likely to be in, say, the interval [0.499๐‘›, 0.501๐‘›]. Us- ing Markovโ€™s inequality directly will not help us, since it will only tell

mathematical background 39

Figure 8 : In the normal distribution or the Bell curve, the probability of deviating ๐‘˜ standard deviations from the expectation shrinks exponentially in ๐‘˜^2 , and specifically with probability at least 1 โˆ’ 2๐‘’โˆ’๐‘˜^2 /2, a random variable ๐‘‹ of expectation ๐œ‡ and standard deviation ๐œŽ satisfies ๐œ‡ โˆ’ ๐‘˜๐œŽ โ‰ค ๐‘‹ โ‰ค ๐œ‡ + ๐‘˜๐œŽ. This figure gives more precise bounds for ๐‘˜ = 1, 2, 3, 4, 5, 6. (Image credit:Imran Baghirov)

us that ๐‘‹ is very likely to be at most 100๐‘› (which we already knew, since it always lies between 0 and ๐‘›). However, since ๐‘‹ 1 , โ€ฆ , ๐‘‹๐‘› are independent,

Var[๐‘‹ 1 + โ‹ฏ + ๐‘‹๐‘›] = Var[๐‘‹ 1 ] + โ‹ฏ + Var[๐‘‹๐‘›]. (1)

(We leave showing this to the reader as Exercise 0.11.) For every random variable ๐‘‹๐‘– in [0, 1], Var[๐‘‹๐‘–] โ‰ค 1 (if the variable is always in [0, 1], it canโ€™t be more than 1 away from its expectation), and hence (1) implies that Var[๐‘‹] โ‰ค ๐‘› and hence ๐œŽ[๐‘‹] โ‰ค

๐‘›. For large ๐‘›,

๐‘› โ‰ช 0.001๐‘›, and in particular if

๐‘› โ‰ค 0.001๐‘›/๐‘˜, we can use Chebyshevโ€™s inequality to bound the probability that ๐‘‹ is not in [0.499๐‘›, 0.501๐‘›] by 1/๐‘˜^2.

0.5.2 The Chernoff bound Chebyshevโ€™s inequality already shows a connection between inde- pendence and concentration, but in many cases we can hope for a quantitatively much stronger result. If, as in the example above, ๐‘‹ = ๐‘‹ 1 + โ€ฆ + ๐‘‹๐‘› where the ๐‘‹๐‘–โ€™s are bounded i.i.d random variables of mean 1/2, then as ๐‘› grows, the distribution of ๐‘‹ would be roughly the normal or Gaussian distributionโˆ’ that is, distributed according to the bell curve (see Fig. 6 and Fig. 8). This distribution has the property of being very concentrated in the sense that the probability of devi- ating ๐‘˜ standard deviations from the mean is not merely 1/๐‘˜^2 as is guaranteed by Chebyshev, but rather is roughly ๐‘’โˆ’๐‘˜^2. Specifically, for a normal random variable ๐‘‹ of expectation ๐œ‡ and standard deviation ๐œŽ, the probability that |๐‘‹ โˆ’ ๐œ‡| โ‰ฅ ๐‘˜๐œŽ is at most 2๐‘’โˆ’๐‘˜^2 /2. That is, we have an exponential decay of the probability of deviation. The following extremely useful theorem shows that such expo- nential decay occurs every time we have a sum of independent and bounded variables. This theorem is known under many names in dif- ferent communities, though it is mostly called the Chernoff bound in the computer science literature:

Theorem 0.14 โ€” Chernoff/Hoeffding bound. If ๐‘‹ 1 , โ€ฆ , ๐‘‹๐‘› are i.i.d random variables such that ๐‘‹๐‘– โˆˆ [0, 1] and ๐”ผ[๐‘‹๐‘–] = ๐‘ for every ๐‘–, then for every ๐œ– > 0

Pr[โˆฃ

๐‘›โˆ’ โˆ‘ ๐‘–=

๐‘‹๐‘– โˆ’ ๐‘๐‘›โˆฃ > ๐œ–๐‘›] โ‰ค 2 โ‹… ๐‘’โˆ’2๐œ–

(^2) ๐‘› .

We omit the proof, which appears in many texts, and uses Markovโ€™s inequality on i.i.d random variables ๐‘Œ 0 , โ€ฆ , ๐‘Œ๐‘› that are of the form ๐‘Œ๐‘– = ๐‘’๐œ†๐‘‹๐‘–^ for some carefully chosen parameter ๐œ†. See Exercise 0. for a proof of the simple (but highly useful and representative) case where each ๐‘‹๐‘– is {0, 1} valued and ๐‘ = 1/2. (See also Exercise 0.15 for a generalization.)

mathematical background 41

  1. Give an example for two random variables ๐‘‹, ๐‘Œ such that ๐”ผ[ XY ] โ‰  ๐”ผ[๐‘‹]๐”ผ[๐‘Œ ].
  2. Prove that if ๐‘‹ and ๐‘Œ are independent random variables (i.e., for every ๐‘ฅ, ๐‘ฆ, Pr[๐‘‹ = ๐‘ฅ โˆง ๐‘Œ = ๐‘ฆ] = Pr[๐‘‹ = ๐‘ฅ] Pr[๐‘Œ = ๐‘ฆ]) then ๐”ผ[ XY ] = ๐”ผ[๐‘‹]๐”ผ[๐‘Œ ] and ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹ + ๐‘Œ ] = ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹] + ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘Œ ].

โ– 

Exercise 0.5 โ€” Random hash function. Suppose that ๐ป is chosen to be a random function mapping the numbers {1, โ€ฆ , ๐‘›} to the numbers {1, .., ๐‘š}. That is, for every ๐‘– โˆˆ {1, โ€ฆ , ๐‘›}, ๐ป(๐‘–) is chosen to be a ran- dom number in {1, โ€ฆ , ๐‘š} and that choice is done independently for every ๐‘–. For every ๐‘– < ๐‘— โˆˆ {1, โ€ฆ , ๐‘›}, define the random variable ๐‘‹๐‘–,๐‘— to equal 1 if there was a collision between ๐ป(๐‘–) and ๐ป(๐‘—) in the sense that ๐ป(๐‘–) = ๐ป(๐‘—) and to equal 0 otherwise.

  1. For every ๐‘– < ๐‘—, compute ๐”ผ[๐‘‹๐‘–,๐‘—].
  2. Define ๐‘Œ = โˆ‘๐‘–<๐‘— ๐‘‹๐‘–,๐‘— to be the total number of collisions. Compute ๐”ผ[๐‘Œ ] as a function of ๐‘› and ๐‘š. In particular your answer should imply that if ๐‘š < ๐‘›^2 /1000 then ๐”ผ[๐‘Œ ] > 1 and hence in expectation there should be at least one collision and so the function ๐ป will not be one to one.
  3. Prove that if ๐‘š > 1000 โ‹… ๐‘›^2 then the probability that ๐ป is one to one is at least 0.9.
  4. Give an example of a random variable ๐‘ (unrelated to the function ๐ป) that is always equal to a non-negative integer, and such that ๐”ผ[๐‘] โ‰ฅ 1000 but Pr[๐‘ > 0] < 0.001.
  5. Prove that if ๐‘š < ๐‘›^2 /1000 then the probability that ๐ป is one to one is at most 0.1.

โ– 

0.7 EXERCISES

Exercise 0.6 Suppose that we toss three independent fair coins ๐‘Ž, ๐‘, ๐‘ โˆˆ {0, 1}. What is the probability that the XOR of ๐‘Ž,๐‘, and ๐‘ is equal to 1? What is the probability that the AND of these three values is equal to 1? Are these two events independent? โ– 

Exercise 0.7 Give an example of random variables ๐‘‹, ๐‘Œ โˆถ {0, 1}^3 โ†’ โ„ such that ๐”ผ[ XY ] โ‰  ๐”ผ[๐‘‹] ๐”ผ[๐‘Œ ]. โ– 

42 an intensive introduction to cryptography

(^3) While you donโ€™t need this to solve this exercise, this is the function that maps ๐‘ to the entropy (as defined in Exercise 0.12) of the ๐‘-biased coin distribution over {0, 1}, which is the function ๐œ‡ โˆถ {0, 1} โ†’ [0, 1] s.y. ๐œ‡(0) = 1 โˆ’ ๐‘ and ๐œ‡(1) = ๐‘. (^4) Hint: Use Stirlingโ€™s formula for approximating the factorial function.

Exercise 0.8 Give an example of random variables ๐‘‹, ๐‘Œ โˆถ {0, 1}^3 โ†’ โ„ such that ๐‘‹ and ๐‘Œ are not independent but ๐”ผ[ XY ] = ๐”ผ[๐‘‹] ๐”ผ[๐‘Œ ]. โ– 

Exercise 0.9 โ€” Product of expectations. Prove Lemma 0. โ– 

Exercise 0.10 โ€” Transformations preserve independence. Prove Lemma 0. โ– 

Exercise 0.11 โ€” Variance of independent random variables. Prove that if ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 are independent random variables then Var[๐‘‹ 0 + โ‹ฏ + ๐‘‹๐‘›โˆ’1] = โˆ‘๐‘›โˆ’1๐‘–=0 Var[๐‘‹๐‘–]. โ– 

Exercise 0.12 โ€” Entropy (challenge). Recall the definition of a distribution ๐œ‡ over some finite set ๐‘†. Shannon defined the entropy of a distribution ๐œ‡, denoted by ๐ป(๐œ‡), to be โˆ‘๐‘ฅโˆˆ๐‘† ๐œ‡(๐‘ฅ) log(1/๐œ‡(๐‘ฅ)). The idea is that if ๐œ‡ is a distribution of entropy ๐‘˜, then encoding members of ๐œ‡ will require ๐‘˜ bits, in an amortized sense. In this exercise we justify this definition. Let ๐œ‡ be such that ๐ป(๐œ‡) = ๐‘˜.

  1. Prove that for every one to one function ๐น โˆถ ๐‘† โ†’ {0, 1}โˆ—, ๐”ผ๐‘ฅโˆผ๐œ‡ |๐น (๐‘ฅ)| โ‰ฅ ๐‘˜.
  2. Prove that for every ๐œ–, there is some ๐‘› and a one-to-one function ๐น โˆถ ๐‘†๐‘›^ โ†’ {0, 1}โˆ—, such that ๐”ผ๐‘ฅโˆผ๐œ‡๐‘› |๐น (๐‘ฅ)| โ‰ค ๐‘›(๐‘˜ + ๐œ–), where ๐‘ฅ โˆผ ๐œ‡ denotes the experiments of choosing ๐‘ฅ 0 , โ€ฆ , ๐‘ฅ๐‘›โˆ’1 each independently from ๐‘† using the distribution ๐œ‡. โ– 

Exercise 0.13 โ€” Entropy approximation to binomial. Let ๐ป(๐‘) = ๐‘ log(1/๐‘) + (1 โˆ’ ๐‘) log(1/(1 โˆ’ ๐‘)).^3 Prove that for every ๐‘ โˆˆ (0, 1) and ๐œ– > 0, if ๐‘› is large enough then^4

where (๐‘›๐‘˜) is the binomial coefficient (^) ๐‘˜!(๐‘›โˆ’๐‘˜)!๐‘›! which is equal to the number of ๐‘˜-size subsets of {0, โ€ฆ , ๐‘› โˆ’ 1}. โ– 

Exercise 0.14 โ€” Chernoff using Stirling. 1. Prove that Pr๐‘ฅโˆผ{0,1}๐‘› [โˆ‘ ๐‘ฅ๐‘– = ๐‘˜] = (๐‘›๐‘˜)2โˆ’๐‘›.

  1. Use this and Exercise 0.13 to prove (an approximate version of) the Chernoff bound for the case that ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 are i.i.d. random variables over {0, 1} each equaling 0 and 1 with probability 1/2. That is, prove that for every ๐œ– > 0, and ๐‘‹ 0 , โ€ฆ , ๐‘‹๐‘›โˆ’1 as above, Pr[| โˆ‘๐‘›โˆ’1๐‘–=0 โˆ’ ๐‘›/2| > ๐œ–๐‘›] < 20.1โ‹…๐œ–^2 ๐‘›. โ–