Finding cocycles that square to zero Suppose $x$ is a chosen class in the singular cohomology (integer coefficients) of a space $X$. I'm thinking primarily of classes of odd degree on a simply connected  space. What are necessary conditions (besides $x^2=0$) for the existence of a cocycle representing $x$ whose cup-square equals zero as a cocycle? Sufficient conditions?
Take your pick of the precise form of the question: you can fix a cochain model for cup products before or after choosing $x$, or even allow a DGA quasi-isomorphic to the singular cochains on $X$.
You may feel inclined to mutter "Steenrod square" or "Massey product" - but which, and why?
 A: The triple product $\langle x,x,x\rangle$ has to contain zero.
Indeed, if $a$, $b$, $c$ are odd cohomology classes such that $ab=0$ and $bc=0$, to compute the triple product $\langle a, b, c\rangle$, one picks representative cocycles $\alpha$, $\beta$ and $\gamma$, then picks cochains $\delta$ and $\eta$ such that $\alpha\beta=d\delta$ and $\beta\gamma=d\eta$, and then observes that $\tau=\alpha\eta+\delta\gamma$ is a cocycle. Then $\tau$ is a representative of $\langle a,b,c\rangle$ in an appropriate quotient of the cohomology group which contains the class of $\tau$.
In your case, suppose we can represent the class $x$ by a cocycle $\xi$ such that $\xi^2=0$. Then if we take $a=b=c=x$, we can take $\alpha=\beta=\gamma=\xi$ and $\delta=\eta=0$, so that $\tau=0$, that is, $0\in \langle x,x,x\rangle$.
In fact, all Massey products $\langle x,x,\dots,x\rangle$ ("Massey powers"?) have to be zero, by a similar computation---see the book by McCleary on spectral sequences, chapter 8, for a speedy description of these.
A: I don't know what your application is, so the below may not be sufficient, but it was fun to think about.

The issue we run into here is that being (respresentable by) a square-zero cocycle is not a homotopical condition, and is certainly not invariant under quasi-isomorphisms. For instance, $C^*(S^3)$ contains no square-zero 3-cocycles representing top cohomology: if $\sigma:\Delta^3 \to S^3$ is a singular 3-simplex  with $\sigma$ constant on $\partial \Delta^3$, on which $\phi(\sigma) = 1$, then we can always find a 6-simplex $\overline \sigma$ with $\overline \sigma_{[0, 3]} = \sigma$ and $\overline \sigma_{[3, 6]} = \sigma$. (Choose a projection $\Delta^6 \to \Delta^3 \vee \Delta^3$ and compose with the map $\sigma \vee \sigma$, which makes sense because $\sigma$ is constant on the boundary.) Then $(\phi \cup \phi)(\overline \sigma) = 1$. Of course, if you instead work with the quasi-isomorphic dg-algebra of simplicial cochains, every representative is square-zero because $C^6_\Delta(S^3) = 0$.
A more homotopical condition is being coherently square zero (in the literature, being a 'twisting element', though this is a very special case of a general theory).  If $[x_1]$ is a cohomology class of odd degree $2n+1$, then a coherently square-zero extension is a sequence of cochains $x_2, x_3, \cdots$ with $|x_i| = 2ni + 1$, so that $$dx_k + \sum_{\substack{i+j = k \\ i,j \geq 1}} x_i x_j = 0.$$
There are two natural ways to come up with this formula.
First: consider the dg-algebra $\Bbb Z[2n+1]$, which is a copy of $\Bbb Z$ in degree 3 with zero differential and zero product. Then a dg-algebra homomorphism $\Bbb Z[2n+1] \to C^*(X;\Bbb Z)$ is precisely a square-zero cocycle. When we want more "homotopical" conditions, we learn to generalize from dg-algebra maps to $A_\infty$ maps. And the above is (maybe up to sign, I didn't check) the same thing as an $A_\infty$-homomorphism $\Bbb Z[2n+1] \to C^*(X;\Bbb Z)$.
Second: you might be looking for a "twisted differential" on the cochain complex $C^*(X;\Bbb Z) \otimes \Bbb Z[T, T^{-1}]$ which incorporates cup-product with $x_1$. The first formula you would guess is $d_{tw} = d + L_1 T$, where $L_1(y) = x_1 y$. The conditon $d_{tw}^2 = 0$ is equivalent to the demand that $dx_1 = 0$ and $x_1^2 = 0$.
When you give up on finding $x_1^2 = 0$, you might try to correct for this by adding higher terms. You could then guess that the right differential is $d_{tw} = d + L_1 T + L_2 T^2 + \cdots$ where $L_m(y) = x_m y$. The claim that $d_{tw}^2 = 0$ is now precisely the formulae I wrote above.

(There is also a notion of homotopy of these. A non-trivial but not too difficult fact is that if $A$ and $B$ are algebras equipped with a cup-1 product satisfying the Hirsch formula, and if $f: A \to B$ is a quasi-isomorphism of dg-algebras which preserves the cup-1 product, then $f$ induces a bijection on the sets of twisting sequences as above up to homotopy.)


Theorem. Suppose $X$ is a topological space with $H^*(X;\Bbb Z)$ is torsion-free. Then if $c \in H^{2n+1}(X;\Bbb Z)$ is an odd class, there is always a coherently square-zero extension $(x_1, x_2, \cdots) \in \prod_{i \geq 1} C^{2ni+1}(X;\Bbb Z)$ with $[x_1] = c$.

More generally --- as in Mariano's nice answer --- all we need to demand is that all Massey powers $\langle c, \cdots, c\rangle$ is well-defined and equal to zero.
Proof: Construct this by induction.
Choose $x_1$ to be any cocycle with $[x_1] = c$. Inductively suppose that we have constructed $x_1, \cdots, x_m$ with $$dx_k + \sum_{\substack{i+j = k \\ i,j \geq 1}} x_i x_j = 0$$ for all $k \leq m$. Then by explicit computation the term $$\sum_{\substack{i+j = m + 1 \\ i,j \geq 1}} x_i x_j$$ is a cocycle, and referring to Kraines, "Massey higher products", Section 3, you see that this is a representative for the so-called Massey power $\langle c\rangle^{m+1}$.
By Kraines, "Massey higher products", Theorem 15, these vanish in rational cohomology; by naturality of Massey products under change-of-coefficients and injectivity of the map $H^*(X;\Bbb Z) \to H^*(X;\Bbb Q)$, it follows that these vanish integrally. Thus there exists an $x_{m+1}$ so that $$dx_{m+1} + \sum_{\substack{i+j = m + 1 \\ i,j \geq 1}} x_i x_j = 0,$$ completing the induction.

Notice that the simplest case of this is that $c^2 = 0$ in rational cohomology because $c^2$ is 2-torsion. The Massey powers are a sequence of higher torsion obstructions to such an extension.
One can further analyze the obstructions to such sequences being homotopic, but I will not do so here. A special case is that if $x_1^2 = y_1^2 = 0$ in your dga with cup-1 products satisfying the Hirsch formula, then if you have torsion-free cohomology then in fact $(x_1, 0, \cdots)$ and $(y_1, 0, \cdots)$ are homotopic as twisting sequences if and only if $[x_1] = [y_1]$. To manage the higher cases one has to also ask that certain higher cohomology classes are equal, where the higher cohomology classes are made out of iterated cup-1 products of lower ones.

In particular you can extend every odd cohomology class on $SU(n)$ to a twisting sequence. (If you're trying to extend the 3-dimensional generator and you work with simplicial cochains, I can prove that you can find a representative with $x_k = 0$ for $k \geq n$, but this is a little tedious.)
The argument I outlined above that you will never be able to construct an honest square-zero cocycle in the singular chains on $S^3$ works just as well to show you won't be able to do that in the singular chains on $SU(n)$. I don't think you can do it in simplicial chains on $SU(n)$ for $n > 2$, either, but I haven't thought about that so much.
