TITLE: Combinatorics of the Stasheff polytopes
QUESTION [12 upvotes]: First a little background for those unaware. The Stasheff polytopes (or associahedra) are certain convex polytopes that arise in the theory of $A_\infty$-algebras. There is one polytope for each $n\geq 2$ and is denoted by $K_n$. The $K_n$'s essentially encode the homotopies, higher homotopies and so on of the associativity relation. One way to describe $K_n$, which is has dimension $(n-2)$, is to take all rooted binary trees with $n$ leaves and take a suitable convex hull. For example, $K_2=\{\ast\}$, $K_3$ is an interval while $K_4$ is a pentagon. 
It is known that the number of vertices $v$ of $K_n$ is the $(n-1)^{th}$ Catalan number, i.e., $v=\frac{1}{n}{2n-2 \choose n-1}$. What can one say about the number of edges of $K_n$ and generally about counting faces of all codimension?

REPLY [11 votes]: Greg's explanation is way too complicated for a simple problem.  Here is a more direct combinatorial approach.  I know this is an old question, but just for the record.  
Fix a convex $n$-gon $Q \subset \Bbb R^2$ with set of vertices $V$. Consider a Gelfand-Kapranov-Zelevinsky realization of the associahedron in the space of functions: for every triangulation $T$ of $Q$, take $f_T: V \to \Bbb R$, where $f(v)=$area of triangles with vertex at $v \in V$.  Now consider a linear function $\phi: \Bbb R^n  \to \Bbb R$ by setting 
$$\phi(x_1,\ldots,x_n) = x_1 + \epsilon x_2 + \ldots \epsilon^{n-1} x_n,$$
where $\epsilon >0$ is very small.  Now, the triangulations $T$ of $Q$ correspond to binary trees and the edges of the associahedron are the pairs of triangulations obtained by a flip - the change of an edge in a quadrilateral. In the language of binary trees, these correspond to the edges as well. Let us compute the $h$-vector of the associahedron.  Recall that the index$(T)=$ the number of edges of $Q$ where $\phi$ is increasing, and observe that it is equal to the number of right edges in the corresponding binary tree.  Thus $h_i$ is equal to the Narayana number:
$$h_i = \frac{1}{n} \binom{n}{i}\binom{n}{i+1}$$
(you need to shift $n\gets n-2$ here).  Now the $f$-vector can be obtained via binomial identities:
$$F(t) = H(t+1), \ F(t)=\sum_k f_k t^k, \  H(t)=\sum_k h_k t^k$$
To see this example more carefully explained, see my book (chapter 8). For more on the associahedron and the ideas behind the GKZ realization, see Ziegler's Lectures on polytopes (chapter 4).