No lattice point dominates another 
Suppose that $A,B$ are distinct lattice points in $\mathbb Z^n$. We say that $A$ dominates $B$ if all the components of $A-B$ are non-negative.
Given positive integers $a_1,a_2,\dots ,a_n$, let $S$ be a set of lattice points in the integer lattice $L=[0,a_1]\times[0,a_2]\times\dots\times[0,a_n]$ such that no element of $S$ dominates another element. What is the maximal value of $|S|$?

I encountered this problem in the context of posets and Dilworth's theorem. If we consider domination as a partial order on the elements of $L$, then by Dilworth's theorem, we need to find the minimal number of chains whose union is $L$. However, I'm unsure how to do this.
 A: We are asked for a formula for the maximum size of an antichain in the product of $n$ chains, $L=[0,a_1]\times\cdots\times[0,a_n]$. The lattice $L$ is graded, rank unimodal, and has the Sperner property. These facts reduce this problem so a counting problem where inclusion/exclusion is applicable.
To define terms, the statement that $L$ is ranked means that all maximal chains from a given $x\in L$ to the least element of $L$ have the same length, which is called the rank of $x$. Let $L_i$ be the set of elements of $L$ of rank $i$. The statement that $L$ is rank unimodal means that 
$$|L_0|\leq |L_1|\leq \cdots \leq |L_j|\geq |L_{j+1}|\geq \ldots\geq |L_K|$$ for some $j$, where $K=\sum a_i$. That is, the sizes of the $L_i$'s increase monotonically to some maximum, then decrease monotonically. Finally, $L$ is Sperner if the largest $L_i$ is a maximal antichain.
Sperner proved in 1928 that in a product $L$ of $n$ chains which each have length 2 a maximal antichain is a middle rank, which has size $\binom{n}{\lfloor n/2\rfloor}$. 
In 
de Bruijn, N. G.; van Ebbenhorst Tengbergen, Ca.; Kruyswijk, D.
On the set of divisors of a number.
Nieuw Arch. Wiskunde (2) 23, (1951). 191-193. 
one finds that, in any product $L=[0,a_1]\times\cdots\times[0,a_n]$ of $n$ chains, some middle rank is a maximal antichain. That is, if $K=\sum a_i$, then $L_{\lfloor K/2\rfloor}$ is a maximal antichain in $L$. This problem is therefore the problem of computing $|L_{\lfloor K/2\rfloor}|$.
This can be done through inclusion/exclusion. The number of $(x_1,\ldots,x_n)\in L_{\lfloor K/2\rfloor}$ is the number of solutions to 
$$x_1+x_2+\cdots+x_n = {\lfloor K/2\rfloor}$$
subject to the restrictions that $0\leq x_i\leq a_i$. Introduce some notation:
$R_i$ is the condition $x_i>a_i$. It represents the failure of the restriction $0\leq x_i\leq a_i$. 
$R = \{R_1,\ldots,R_n\}$.
If $S\subseteq R$, then $N(S)$ is the number of solutions to $x_1+x_2+\cdots+x_n = {\lfloor K/2\rfloor}$ for which $R_i$ is true for every $R_i\in S$. (If $S=\emptyset$, then  $N(S)$ is the number of solutions to $x_1+x_2+\cdots+x_n = {\lfloor K/2\rfloor}$ in nonnegative integers, with no further restrictions on the $x_i$'s. If $S = \{R_1\}$, then $N(S)$ is the number of solutions to $x_1+x_2+\cdots+x_n = {\lfloor K/2\rfloor}$ in nonnegative integers, with $x_1>a_1$. In this case, $N(S)$ is the number of solutions with $x_1$ too big.)
The final answer is $N(\emptyset) - \sum_{i} N(\{R_i\}) + \sum_{i,j} N(\{R_i,R_j\})-\cdots$. (Inclusion/Exclusion formula.)
If $t=\lfloor K/2\rfloor$, then $N(\emptyset)=\binom{n-1+t}{n-1}$, 
$N(\{R_i\})=\binom{n-1+(t-a_i-1)}{n-1}$, 
$N(\{R_i, R_j\})=\binom{n-1+(t-a_i-a_j-2)}{n-1}$, ETC. (Here I am using that the number of nonnegative integer solutions to 
$x_1+x_2+\cdots+x_n = t$ is $\binom{n-1+t}{n-1}$.)
Let me write out the answer explicitly in the first nontrivial case, namely the case where $L=[0,a_1]\times [0,a_2]\times [0,a_3]$ and $t=\lfloor K/2\rfloor=\lfloor (a_1+a_2+a_3)/2\rfloor$. The answer is 
$$\binom{2+t}{2}-\left(\binom{2+(t-a_1-1)}{2}+\binom{2+(t-a_2-1)}{2})+\binom{2+(t-a_3-1)}{2}\right)+\left(\binom{2+(t-a_1-a_2-2)}{2}+\binom{2+(t-a_1-a_3-2)}{2})+\binom{2+(t-a_1-a_3-2)}{2}\right)-\binom{2-(t-a_1-a_2-a_3-3)}{2}.$$
Some of these terms must be zero, but I left them in to show the pattern. 
