Let $S=\{1,2,\ldots,n\}$ and $\mathcal{F}=\{A_1,A_2,\ldots,A_k\}\subseteq\mathcal{P}(S)$ such that $|A_i\cap A_j|\geq r$ for all $1\leq i<j\leq k$, where $r\in\mathbb{N}_+$ and $1\leq r\leq n$. Find the maximum of $k$.
The special cases $r=n-1,n$ are trivial, where $\max k=2^{n-r}$. The case $r=1$ is easy. We pair each $A\subseteq S$ with $S\setminus A$. There are $2^{n-1}$ such pairs and the answer again is $\max k=2^{n-r}$ by the pigeonhole principle. However, $k\leq 2^{n-r}$ does not hold for all $r$. An example is $n=6$, $r=2$ and $\mathcal{F}$ consists of all subsets of $S$ of cardinality $\geq4$, in which case $k=22>2^4$. Is it possible to find the maximum for the general case and how do I proceed?