Mathematics of topological phases