TITLE: A tough set theory problem
QUESTION [5 upvotes]: $A_1,A_2, A_3,\ldots, A_n$ are subsets of a set $S$ with $|S|=2019$ such that the union of any three of the $A_k$s gives $S$ whereas the union of any two isn't equal to $S$. Find the maximum value of $n$.
I am finding this problem very hard to do. I guess it involves the knowledge of very advanced set theory which probably I don't know.
Any help will be greatly appreciated.

REPLY [2 votes]: HINT: Let us consider an equivalent problem:
Let $A^c_1,\ldots, A^c_n$, for some integer $n$, each be subsets of $\{1,2,\ldots, 2019\}$ so that:
A. The intersection of $A^c_i$ and $A^c_j$ is nonempty for any $i,j$.
B. For any $3$ distinct $i_1,i_2,i_3$,
the set $A^c_{i_1} \cap A^c_{i_2} \cap A^c_{i_3}$ is empty.
Then how large can $n$ be? Note that given $A^c_1,\ldots, A^c_n$, the sets $A_1,\ldots, A_n$, where each $A_i$ satisfies $$A_i = \{1,2,3,\ldots, 2019\} \setminus A^c_i,$$ satisfy the desired properties iff $A^c_1,\ldots, A^c_n$ satisfy A. and B. above.
Suppose we are given such an $A^c_1,\ldots, A^c_n$, for some $n$ that we do not know yet. Then from this we can construct a unique multigraph $G$ [perhaps more than one edge between a pair of vertices but each edge has $2$ endpoints] with $n$ vertices $\{v_1,\ldots, v_n\}$ and with a set $S$ of at most $2019$ edges; $S \subseteq \{1,2,\ldots, 2019\}$, that satisfy the following:

For each $k \in S$ and each $i,j \in \{1,\ldots, n\}$: If $k$ is in $A^c_i \cap A^c_j$, then edge $k$ has endpoints $v_i$ and $v_j$.

Between $v_i$ and $v_j$ there is at least one edge. So $G$ is a multigraph with at most $2019$ edges and $G$ has a subgraph a complete graph on $\{v_1,\ldots, v_n\}$.


Now, that this multigraph is well-defined i.e., every edge $k$ has at most $2$ endpoints follows from the fact that the $A^c_i$s satisfy B. above, or equivalently, there are at most $2$ integers $i$ such that $k$ is in $A^c_i$. [If $k$ is in only $1$ or $0$ of the $A^c_i$s then don't put $k$ into $S$.] Also, that there is at least one edge between $v_i$ and $v_j$ for each distinct $i,j$ follows from the fact that the $A^c_i$s satisfy A. above i.e., $A^c_i$ and $A^c_j$ intersect for each pair $i,j$.
Now, for $G$ to have at most $2019$ edges and have as a subgraph a complete graph on $n$ vertices [for some integer $n$] it follows that the following inequality holds:
$${n \choose 2} \le 2019,$$
or $n \le 64$.
We now construct $A^c_1, \ldots, A^c_{64}$. First, let $G'$ be the complete graph on $64$ vertices $\{v_1,\ldots, v_{64}\}$. So $G'$ has exactly ${{64} \choose 2}=$ $2016$ edges. Now add $3$ more edges between $v_1$ and $v_2$ and call the resulting graph $G$; this has exactly $2019$ edges. So now arbitrarily assign each edge in $G$ a unique number in $\{1,\ldots, 2019\}$. Then for each $i=1,\ldots, 64$, the integer $k \in \{1,2,\ldots, 2019\}$ is in $A^c_i$ iff there is an edge incident to $v_i$ assigned the number $k$. This gives the $A^c_1,\ldots, A^c_{64}$s. Check that the $A^c_i$s; $i=1,2,\ldots, 64$, indeed satisfy A. and B. above.
For each $i=1,2,\ldots, 64$, let $A_i=\{1,2,\ldots, 2019\} \setminus A^c_i$. Then that the $A^c_i$s; $i=1,2,\ldots, 64$, satisfy A. and B. above, imply that the $A_i$s; $i=1,2,\ldots, 64$, have the desired properties.

ALTERNATIVE PROOF: If you don't like graph theory, you can also look at it this way: For each $k \in \{1,2,\ldots, 2019\}$ such that $k$ is in at least $2$ of $A^c_1,\ldots, A^c_n$ [for some integer $n$] assign to $k$ a $2$-element subset $E_k=\{i,j\}$ of $\{1,2,\ldots, n\}$, where $E_k=\{i,j\}$ satisfies both $k \in A^c_i$ and $A^c_j$.
That no $3$ of the $A^c_i$s intersect implies that for each such $k$ there are at most $2$ integers $i$, $j$ such that $k$ is in both $A^c_i$ and $A^c_j$. Thus, for each $k \in \{1,2,\ldots, 2019\}$, there is at most $1$ choice for $E_k$. That $A^c_i \cap A^c_j$ is nonempty for every $i,j \in \{1,2,\ldots, n\}$ implies that for every one $E$ of the ${n \choose 2}$ $2$-element sets of $\{1,2,\ldots, n\}$, there is a $k \in \{1,2,\ldots, 2019\}$ such that $E_k=E$.
So as there are ${n \choose 2}$ subsets of $\{1,2,\ldots, n\}$, this gives the inequality $${n \choose 2} \le 2019,$$
or as before, $n \le 64$.
Then to construct $A^c_1,\ldots, A^c_{64}$ that satisfy A. and B. as above, first assign for each $k \in \{1,2,\ldots, 2019\}$ a $2$-element subset $E_k$ of $\{1,2,\ldots, 64\}$, so that for every $2$-element subset $E$ of $\{1,2,\ldots, 64\}$, there is a $k$ such that $E=E_k$. As there are precisely $2016\le2019$ $2$-element subsets of $\{1,2,\ldots, 64\}$, this is possible. Then $k$ is in $A^c_i$ iff $i$ is in $E_k$.
Then for each $i=1,2,\ldots, 64$, set $$A_i=
\{1,2,\ldots, 2019\} \setminus A^c_i.$$