Mathematical Theory of Switching Circuits and Automata