Theoretical Foundations of AI in Cybersecurity