Foundations of Prompt Engineering