














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















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
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
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 ๐^ =
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) ๐ .
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
โ
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.
โ
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 ๐ป(๐) = ๐.
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โ๐.