Example 2.3.3 The number of integer solutions to the equation $x_{1}+x_{2}+x_{3}+x_{4}=18$ that satisfy $1 \leqslant x_{1} \leqslant 5,-2 \leqslant x_{2} \leqslant 4,0 \leqslant x_{3} \leqslant 5,3 \leqslant x_{4} \leqslant 9$ is how many?
Solution: First, discuss the number of positive integer solutions for $x_{1}+x_{2}+\cdots+x_{r}=n$. Arrange $n$ circles in a row:
$0000 \bigcirc \cdots \bigcirc$,

There are $n-1$ gaps. If we choose $r-1$ gaps from the $n-1$ gaps to place $X$, then the $r-1$ $X$s divide the $n$ circles into $r$ parts, and vice versa. Therefore, there are $\mathrm{C}_{n-1}^{r-1}$ ways.
Next, discuss the original problem, introduce new variables
$$
y_{1}=x_{1}, y_{2}=x_{2}+3, y_{3}=x_{3}+1, y_{4}=x_{4}-2,
$$

Then $y_{1}+y_{2}+y_{3}+y_{4}=20$, and $1 \leqslant y_{1} \leqslant 5,1 \leqslant y_{2} \leqslant 7,1 \leqslant y_{3} \leqslant 6,1 \leqslant y_{4} \leqslant 7$.
Let $I$ be the set of all positive integer solutions for $y_{1}+y_{2}+y_{3}+y_{4}=20$,
$A_{1}$ be the set of all positive integer solutions for $y_{1}+y_{2}+y_{3}+y_{4}=20, y_{1}>5$,
$A_{2}$ be the set of all positive integer solutions for $y_{1}+y_{2}+y_{3}+y_{4}=20, y_{2}>7$,
$A_{3}$ be the set of all positive integer solutions for $y_{1}+y_{2}+y_{3}+y_{4}=20, y_{3}>6$,
$A_{4}$ be the set of all positive integer solutions for $y_{1}+y_{2}+y_{3}+y_{4}=20, y_{4}>7$.
Notice that $\left|A_{i} A_{j} A_{k}\right|=0$, by the principle of inclusion-exclusion
$$
\begin{array}{l}
\left|\overline{A_{1} A_{2} A_{3} A_{4}}\right|=|I|-\left|A_{1}\right|-\left|A_{2}\right|-\left|A_{3}\right|-\left|A_{4}\right|+\left|A_{1} A_{2}\right| \\
+\left|A_{1} A_{3}\right|+\left|A_{1} A_{4}\right|+\left|A_{2} A_{3}\right|+\left|A_{2} A_{4}\right|+\left|A_{3} A_{4}\right| \\
= \mathrm{C}_{20-1}^{3}-\mathrm{C}_{20-5-1}^{3}-\mathrm{C}_{20-7-1}^{3}-\mathrm{C}_{20-6-1}^{3}-\mathrm{C}_{20-7-1}^{3} \\
+\mathrm{C}_{20-5-7-1}^{3}+\mathrm{C}_{20-5-6-1}^{3}+\mathrm{C}_{20-5-1-1}^{3}+\mathrm{C}_{20-7-6-1}^{3} \\
+\mathrm{C}_{20-7-7-1}^{3}+\mathrm{C}_{20-6-7-1}^{3} \\
= \mathrm{C}_{19}^{3}-\mathrm{C}_{14}^{3}-\mathrm{C}_{12}^{3}-\mathrm{C}_{13}^{3}-\mathrm{C}_{12}^{3}+\mathrm{C}_{7}^{3}+\mathrm{C}_{8}^{3}+\mathrm{C}_{7}^{3}+\mathrm{C}_{6}^{3} \\
+\mathrm{C}_{5}^{3}+\mathrm{C}_{6}^{3} \\
= 969-364-220-286-220+35+56+35+20 \\
+10+20 \\
=
\end{array}
$$