#!/usr/bin/env cadabra2 \alpha_{n}^{\mu}::SelfNonCommuting; \vac::LaTeXForm("|k\rangle"); def post_process(ex): substitute(ex, $\sqrt{2} \sqrt{2} -> 2$) collect_terms(ex) {\alpha_{n}^{\mu}, \vac}::NonCommuting; {\mu,\nu,\rho}::Integer(0..d-1). {\mu,\nu,\rho}::Indices. {m,n}::Integer. {m,n}::Symbol. \delta{#}::KroneckerDelta. \delta{#}::Diagonal. chi1:= \alpha_{-1}^{\mu} \alpha_{-1}^{\mu} \vac; chi2:= \alpha_{0}^\mu \alpha_{-2}^\mu \vac; chi3:= \alpha_{0}^{\mu} \alpha_{-1}^{\mu} \alpha_{0}^{\nu} \alpha_{-1}^{\nu})\vac; rl:= { \alpha_{m}^{\mu} \alpha_{n}^{\nu} | m > n -> \alpha_{n}^{\nu} \alpha_{m}^{\mu} + m\delta_{m}_{-n} \delta^{\mu\nu}, \alpha_{m}^{\mu} \vac | m > 0 -> 0, \alpha_{0}^{\mu} \vac -> \sqrt{2} k^{\mu} \vac, k^{\mu} k^{\mu} -> -1 }; def L(m): ins='' for n in range(-10,10): if n!=-10: ins+='+ ' ins += r'1/2 \alpha_{'+str(m-n)+r'}^{\mu} \alpha_{'+str(n)+r'}^{\mu}' ex=Ex(ins) return ex L0=L(0); L1=L(1) L2=L(2) L1c1:= @(L1) @(chi1); L1c2:= @(L1) @(chi2). L1c3:= @(L1) @(chi3). def act(ex): converge(ex): distribute(ex) substitute(ex, rl) distribute(ex) eliminate_kronecker(ex) rename_dummies(ex) return ex act(L1c1); act(L1c2); act(L1c3); L2c1:= @(L2) @(chi1). L2c2:= @(L2) @(chi2). L2c3:= @(L2) @(chi3). act(L2c1); act(L2c2); act(L2c3); tst1:=@(L1c1) + A @(L1c2) + B @(L1c3) = 0; tst2:=@(L2c1) + A @(L2c2) + B @(L2c3) = 0;