### How to use Sage (or other software) to simplify this algebraic expression ?

Background: I was trying to understand the IBM 1 machine translation models when I came across a summation involving summation over Kronecker Delta, which was later simplified. I want to know if it is possible to automagically simplify complicated summations in Sage (I haven't ever used symbolic math toolbozes before)

All images are screenshots of some slides of NLP course at jhu

Detailed Question: Is it possible to use Sage to simplify equations such as the following

and the definitions of the terms are $\delta$ is the Kronecker delta and $p(a | e,f)$ is defined as

where a and t are defined as

The final simplified form of the equation is