Probability cheat sheet webpage
Union bound
Imagine I have two random variables (XXX and YYY) each of which can have value AAA or BBB. Imagine I want to know the expected number of As I get. This will be:
E[number of As]=1⋅p(X=A and Y=B)+2⋅p(X=A and Y=A)E[\text{number of }A\text{s}]=1\cdot p(X=A\text{ and }Y=B)+2\cdot p(X=A\text{ and }Y=A)E[number of As]=1⋅p(X=A and Y=B)+2⋅p(X=A and Y=A) +1⋅p(X=B and Y=A)+1\cdot p(X=B\text{ and }Y=A)+1⋅p(X=B and Y=A)
=(p(X=A and Y=B)+p(X=A and Y=A))=(p(X=A\text{ and }Y=B)+p(X=A\text{ and }Y=A))=(p(X=A and Y=B)+p(X=A and Y=A)) +(p(X=B and Y=A)+p(X=A and Y=A))+(p(X=B\text{ and }Y=A)+p(X=A\text{ and }Y=A))+(p(X=B and Y=A)+p(X=A and Y=A))
=p(X=A)+p(Y=A)=p(X=A)+p(Y=A)=p(X=A)+p(Y=A)
And this result works whether XXX and YYY are independent random variables or not. The only thing we require is that getting X=AX=AX=A and X=BX=BX=B are mutually exclusive (and similarly for YYY).
https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle