It’s not a terribly complicated idea, really. You can train it to output formatted calculations when presented with a problem, then something in the middle watches for those and inserts the solution for it behind the scenes. You might even trigger another generation to let it appear more smooth when presented to the user.