TITLE: Optimal bounds for an alternating sum on a downset
QUESTION [16 upvotes]: Let $n$ be a natural number, and consider the discrete cube $2^{[n]} := \{ A: A \subset \{1,\ldots,n\}\}$ consisting of all subsets of the $n$-element set $[n] := \{1,\ldots,n\}$.  Define a downset in $2^{[n]}$ to be a collection ${\mathcal D}$ of elements $A$ in $2^{[n]}$ with the property that if $A \in {\mathcal D}$ and $B \subset A$, then $B \in {\mathcal D}$.
My question is: what are the largest and smallest possible values for the alternating sum $\sum_{A \in {\mathcal D}} (-1)^{|A|}$, as ${\mathcal D}$ ranges over downsets in $2^{[n]}$, as a function of $n$?  (Here $|A|$ denotes the cardinality of $A$.)
The trivial bounds here are $\pm 2^{n-1}$, by taking only the positive or negative values of ${\mathcal D}$, but of course these values are attained on a "checkerboard" set which is very far from being a downset, and this suggests that significant improvement is possible.
By taking ${\mathcal D}$ to be the set of all subsets $A$ of $2^{[n]}$ of cardinality at most $r$ for some $1 \leq r \leq n-1$, this gives a value of $(-1)^r \binom{n-1}{r}$; setting $r$ close to $(n-1)/2$ then seems to give reasonably good extremals (of size about $2^n/\sqrt{n}$ asymptotically).  In the spirit of Sperner's lemma, one might tentatively conjecture that these are the extremal examples, but I was unable to prove or disprove this.  (I feel like I'm missing some obvious application of downset isoperimetric inequalities or something.)
One motivation for this question is from analytic number theory: partial divisor sums $\sum_{d|a: d \leq x} \mu(d)$ of the Mobius function (which show up from time to time in this subject) can be viewed as an alternating sum over a downset, where $n$ is the number of prime factors $p_1,\ldots,p_n$ of $a$, and ${\mathcal D}$ is the collection of subsets $A$ of $[n]$ for which $\prod_{i \in A} p_i \leq x$.  So any bounds on the general alternating-sum-of-downset problem would imply bounds on partial divisor sums of the Mobius function that depend only on the number of prime factors.
One small observation (using the shifting technology of Frankl) which may or may not be of use: given two natural numbers $1 \leq i < j \leq n$ and a downset ${\mathcal D}$, define the $ij$-shift of ${\mathcal D}$ to be the set formed by replacing any element of ${\mathcal D}$ of the form $A \cup \{j\}$ with $A \cup \{i\}$, if $A$ is disjoint from $\{i,j\}$ and $A \cup \{i\}$ is not already in A.  Note that this is again a downset.  Call a downset ${\mathcal D}$ shift-minimal if it is equal to all of its $ij$-shifts.  Then one can reduce without loss of generality to the shift-minimal case, because shifting does not affect the sum $\sum_{A \in {\mathcal D}} (-1)^{|A|}$.  In other contexts, the reduction to the shift-minimal case can be very powerful, but for some strange reason I was unable to exploit it here.

REPLY [2 votes]: Here is a simple proof which should give exact optimizers for "most" choices of n mod 4 and max/minimizing; and, near-sharp values for the remaining cases.  I'll do it for upsets instead of downsets.
--
Identify the discrete cube with $\{-1,1\}^n$ and let $f : \{-1,1\}^n \to \{0,1\}$ be the indicator of $\mathcal{D}$ which is monotone since $\mathcal{D}$ is an upset. Up to a factor of $2^n$ we are trying to min/maximize $E_x[f(x) \chi(x)]$, where $x$ is uniformly random on the cube and $\chi(x) = \prod_{i=1}^n x_i$.  Let $1 \leq j \leq n$ be uniformly random and let $x^{(j)}$ denote $x$ with its $j$th coordinate negated.  Since $x^{(j)}$ is also uniformly distributed, 
$E_x[f(x) \chi(x)] = E_{x,j}[\frac{f(x) \chi(x) + f(x^{(j)})\chi(x^{(j)})}{2}] = E[\chi(x)\frac{f(x)-f(x^{(j)})}{2}]$
where we used $\chi(x^{(j)}) = -\chi(x)$.  Thus in absolute value, the quantity is at most
$E[\bigl|\frac{f(x)-f(x^{(j)})}{2}\bigr|] = \frac{1}{2n}E_x\left[\sum_{i=1}^n \bigl|f(x)-f(x^{(i)})\bigr|\right] = \frac{1}{2n}E\left[\sum_{i=1}^n f(x)x_i\right]$,
where the last step uses that $f$ is monotone.  But 
$\frac{1}{2n}E\left[\sum_{i=1}^n f(x)x_i\right] = \frac{1}{2n} E\left[f(x)(\sum_{i=1}^n x_i)\right]$
is clearly maximized among $0$-$1$ functions $f$ by the "Hamming ball" which is $1$ when $\sum_{i=1}^n x_i > 0$ and $0$ when $\sum_{i=1}^n x_i < 0$.  (If $n$ is even and the sum is $0$, it doesn't matter what $f$'s values are there.)  
--
For the purposes of checking sharpness, note that the maximizing $f$ (or $f$'s) there happens to be monotone.  The only inequality used is in fact sharp if $n$ is odd and $n$ has the "right" (vis-a-vis min/maxing) remainder mod $4$; if $n$ is even then I think you can get a sharp inequality for any remainder mod $4$ by suitably making $f$ equal to $0$ or $1$ on the middle Hamming layer.  I hope a little trick can handle the case of odd $n$ congruent to the "wrong" value mod 4 but I didn't think about it.
--
For people familiar with "analysis of boolean functions", I think this result could be considered "folklore".  For example, it essentially appears at the end of page 8 here: http://cs.indstate.edu/~jkinne/research/mon.pdf