Theoretical Foundations of Learning Environments