# Algorithm to construct basis for Kac-Moody algebra

Suppose I have a Kac-Moody algebra (maybe even Borcherds-Kac-Moody) $$\mathfrak{g}$$ with symmetric cartan matrix $$A$$. Let the simple roots be $$e_{\alpha_i}$$ for $$i = 1, \ldots n$$.

I know there is Peterson's multiplicity formula to compute the multiplicities of the root spaces $$\mathfrak{g}_\alpha$$.

How do I figure out a basis for, say, a positive root $$\alpha$$? The first approach is to note that if $$\alpha = \sum_{i = 1}^n k_i \alpha_i$$ then every element $$x$$ of $$\mathfrak{g}_\alpha$$ can be written as a linear combination of elements of the form $$[e_{\alpha_{i_1}} [e_{\alpha_{i_2}} [\cdots e_{\alpha_{i_N}}]]]$$ where $$\sum \alpha_{i_j} = \alpha$$ but I can't seem to figure out an efficent way to use the Lie algebra relations write out a basis for this, even using that I can already compute the multiplicity. Any help?

I suppose that asking publicly somehow gave me the inspiration to figure it out after I had been stuck with it for a while. The answer is actually fairly straightforward. We can construct the Gram matrix for the sets of vectors $$\{[e_{\alpha_{i_1}} [e_{\alpha_{i_2}} [\cdots e_{\alpha_{i_N}}]]]\}$$ and $$\{[f_{\beta_{i_1}} [f_{\beta_{i_2}} [\cdots f_{\beta_{i_N}}]]]\}$$ using simple properties of the invariant form and the Jacobi identity, by induction on the height of $$\alpha = \sum k_i \alpha_i$$ where $$\operatorname{ht}(\alpha) = \sum k_i$$. Suppose it has been calculated for height $$N-1$$. Then let $$f_i := f_{\beta_i}\\ f_{>i} := [f_{i+1} [\cdots f_{N}]]$$ and analogous definitions for $$e_j, e_{> i}, e_{< N}$$ etc. We can then calculate $$(f_{\ge 1}| e_{\ge 1}) = ([f_1, f_{> 1}]|[e_1 , e_{> 1}])\\ = (f_1 | [f_{> 1}, [e_1 , e_{> 1}]])\\ = (f_1 | [[f_{>1}, e_1],e_{>1} ]) + ([f_1, e_1] | [f_{>1},e_{> 1}])\\ = (f_1 | [[f_{>1}, e_1],e_{>1} ]) + \delta_{\alpha_1, \beta_1}([h_{\alpha_1} f_{> 1}] | e_{> 1})\\ = (f_1 | [[f_{>1}, e_1],e_{>1} ]) + \tilde{c} (f_{> 1} | e_{> 1})$$ Then we just use repeated applications of Jacobi and $$[e_i, f_j] = \delta_{\alpha_i, \beta_j} h_{\alpha_i}$$ to show that $$[f_{>1}, e_1] = \sum_{i=2}^N c_i f_{> i} + d [f_2 [ \cdots f_{N-1}]]$$ for easily computable constants $$c_i$$ and $$d$$. Thus our sum becomes $$\sum_{i = 2}^N c_i ([f_1, f_{> i}] | e_{>1}) + d (f_{1}) + \tilde{c} (f_{>1} | e_{> 1})$$ for constants $$c_i, d, \tilde{c}$$ straightforwardly computable. Thus we have written the pairing in terms of pairings of lower height. From here we can just use linear algebra to pick a basis so the Gram matrix has full rank on this subspace.