Cartan formula

The Cartan formula distributes a squaring operation over a product of classes. This program helps with the expansion of the Cartan formula, which easily contains very many terms and is then inaccessible for computation by hand.

Code for the program

Explanation of the code:
The function “CartanTerms[k,n]” generates the appropriate set of partitions of n into k terms. “HowManyTerms” computes the obvious thing.
The function “CartanList[B,n]” computes (Sq^n)on the product of terms in the list B. It takes in a list of the classes, B, which has length Length[B], the number of terms in the product (k) and applies the appropriate set of partitions to it:  A = CartanTerms[Length[B], n].
This creates a symbolic sum of products of terms of the form (Subscript[Sq, i y]), where this symbol represents (Sq^i) acting on class y, which we can later replace with the value of this operation. By construction the sum is homogeneous.
In Mod2CartanList we reduce the coefficients modulo 2. Note that we will need to do so again after replacing the symbols.
Generally we want to apply the Cartan formula to a product rather than first write out the product as a list.

The function “Cartan[x,n]” computes (Sq^n)of a product of classes x and outputs a symbolic sum of terms of the form (Subscript[Sq, i y]), where this symbol represents (Sq^i) acting on a ring generator y, which we can later replace with the value of this operation.
In Mod2Cartan we reduce the coefficients modulo 2. Note that we will need to do so again after replacing the symbols.

SqTwoTerms[x_]:=Table[{x-i,i}, {i,0,x}]
SqTwoTerms2[A_]:=Flatten[Table[Table[{A[[j]][[1]]-i,i,Drop[A[[j]],1]}//Flatten, {i,0,A[[j]][[1]]}], {j,Length[A]}],1]
CartanTerms[k_,n_]:=Nest[SqTwoTerms2,SqTwoTerms[n],k-2]
HowManyTerms[k_, n_]:= Length[CartanTerms[k,n]]
CartanList[B_, n_]:=Sum[Product[(Subscript[(Subscript[Sq, CartanTerms[Length[B],n][[i]][[j]]]), B[[j]]]) ,{j,1,Length[B]}], {i,1,Length[CartanTerms[Length[B],n]]}]
Mod2CartanList[B_, n_]:=PolynomialMod[Cartan[B,n], 2]
MakeitaList[x_]:= Flatten[Table[Table[FactorList[x][[i]][[1]], {j, 1, FactorList[x][[i]][[2]]}], {i, 2, Length[FactorList[x]]}]]
Cartan[x_, n_]:= CartanList[MakeitaList[x], n]
Mod2Cartan[x_, n_]:= Mod2CartanList[MakeitaList[x],n]

Apply the program

The function “Cartan[x,n]” computes (Sq^n)of a product of classes x and outputs a symbolic sum of products of terms of the form (Subscript[Sq, i x]), where this symbol represents (Sq^i) acting on class x, which we can later replace with the value of this operation.
Mod2Cartan reduces the coefficients modulo 2. Note that we will need to do so again after replacing the symbols.

Let k be the number of classes in your product and n the degree of the Steenrod square you want to apply it to.
It is quite easy to make the product too large for Mathematica to handle.
Check first how many terms there are.

HowManyTerms[12,8]

Cartan[x^3 y^2 z,4]

Mod2Cartan[x^3 y^2 z,4]

Examples

CartanTerms[3,3]

CartanTerms[2,2]

CartanTerms[12,2]

CartanTerms[2,12]

B={(Subscript[y, 2]),(Subscript[y, 20]),(Subscript[y, 20]),(Subscript[y, 20])};

CartanList[B, 4]

Mod2CartanList[B,4]

MakeitaList[x^3 y^2 z]

Cartan[x^3 y^2 z,4]

Cartan[x^3 y^2 z,8]