Standard Model and General Relativity Derived from Mathematical Self-Consistency