Foundations of electromagnetic theory