Vakil's Foundations of Algebraic Geometry defines a quasi-separated scheme as (5.1.1) : "the intersection of any two quasicompact open subsets is quasicompact".
The next exercise (5.1.F) asks to prove that the being quasi-separated is equivalent to "the intersection of any two affine open subsets is a finite union of affine open subsets."
The Stacks Project defines quasi-separated schemes as (Definition 25.21.3) the diagonal map $X \rightarrow X \times_{Spec(\mathbb{Z})} X$ is quasi-compact.
I want to show that these are equivalent. I already proved that Vakil's definition implies the Stacks Project's definition, but I'm stuck on the converse.
Here's my approach: Let $S$ be the set of all collections of all affine open sets such that the intersection of any two is a finite union of affine open subsets. That is: an element of $S$ is a collection of affine open sets. Note that the empty set is in $S$, so $S$ is not empty.
Partially order $S$ by inclusion. Suppose $T$ is any totally ordered subset of $S$. Then, consider the union of all affine open sets in every element of $T$. If $U, V$ are affine open sets in that, then since $T$ is totally ordered, both $U$ and $V$ belong in some element of $T$ which is in $S$, so $U \cap V$ is a finite union of affine open sets.
Thus, Zorn's lemma gives a maximal element of $S$, call it $M$. Suppose $M$ does not contain every affine open set. Then, there is some $U$ that $M$ is not contained in. Since $M \cup U$ is strictly bigger than $M$, it is not in $S$. Therefore, there is some $V$ in $M$ such that $U \cap V$ is not a finite union of affine open sets.
Here's where I'm stuck. I know that I want to combine $\pi_1^{-1}(U)$ and $\pi_2^{-1}(V)$ somehow in $X \times_{Spec(\mathbb{Z})} X$ to get a compact set, but since the intersection and inverse image of compact sets is not necessarily compact, I don't know how to proceed. What should I do from here?