Diaconescu-Goodman-Myhill theorem