Unlocking the Secrets of AI: A New Mathematical Framework Reveals How Neural Networks Master Complexity