Hard-coding explanations does seem like the way to go here. It's what researchers at Carnegie Mellon did back in 1984 with demonstrated success. See: Intelligent tutoring Systems: The ACT Project https://www.youtube.com/watch?v=boDH_pW14B0
My question is, if we've had intelligent math tutoring demonstrating success in real classrooms since 1984, then why haven't we been actually using them to help teach math?