Discovering Empirical Theories of Modular Software Systems. An Algebraic Approach