MITM attack isn't based on mathematics. Please review how it works. It is based on the simple idea: if attacker controls and can substitute all communication between two parties, then it can also substitute all key exchange, and re-encrypt all sent messages.
No key exchange design or mathematics can prevent this attack.
The only way to prevent or mitigate MITM attack is by using some out-of-band channel that attacker cannot substitute for passing some of the key material or hash.