TITLE: Inclusion-exclusion principle: Number of integer solutions to equations
QUESTION [12 upvotes]: The problem is:
Find the number of integer solutions to the equation
$$
x_1 + x_2 + x_3 + x_4 = 15
$$
satisfying
$$
\begin{align}
2 \leq &x_1 \leq 4, \\
-2 \leq &x_2 \leq 1, \\
 0 \leq &x_3 \leq 6, \text{ and,} \\
 3 \leq &x_4 \leq 8 \>.
\end{align}
$$
I have read some papers on this question, but none of them explain clearly enough. I am especially confused when you must decrease the total amount of solutions to the equation—with no regard to the restrictions—from the solutions that we don't want. How do we find the intersection of the sets that we don't want? Either way, in helping me with this, please explain this step.

REPLY [6 votes]: If you don't get the larger question, start smaller first.

How many solutions to $x_1 + x_2 = 15$, no restrictions? (infinite of course)
How many solutions  where $0\le x_1$, $0\le x_2$?
How many solutions  where $6\le x_1$, $0\le x_2$? 
How many solutions  where $6\le x_1$, $6\le x_2$? (these last questions don't really say anything about inclusion-exclusion yet)
How many solutions where $0\le x_1\le 5$, $0\le x_2$? Hint: exclude the complement. This is the fist step of the exclusion.
How many solutions where $0\le x_1\le 5$, $0\le x_2\le7$?  Hint: exclude the both complements, but re-include where those two complements overlap (the intersection of those two excluded ranges - what is it), because you excluded the intersection twice.

That is the gist of it. Now it gets harder, because you need to do it for 4 variables not just 2. But that's the exercise, figuring out how to manage including/excluding/then including  back of what you threw away too much of /then excluding back again that littlest bit messed up in that last step.