Mathematical Foundations of Large Language Models