Definability of linear equation systems over groups and rings (Logical Methods in Computer Science, 2013)