Let $\mathfrak{A}$ be an algebra (in the sense of universal algebra). To each term $t(x_1,...,x_n)$ in the language of $\mathfrak{A}$ *in which each variable actually appears* we can assign a group $G_\mathfrak{A}(t)\subseteq S_n$ consisting of all permutations of the variables which results in the same function: $$G_\mathfrak{A}(t)=\{\sigma\in S_n: \forall a_1,...,a_n\in\mathfrak{A}(t(a_1,...,a_n)=t(a_{\sigma(1)},...,a_{\sigma(n)})\}.$$ Now let $\mathbb{G}(\mathfrak{A})$ be the class of *isomorphism types of* groups of the form $G_\mathfrak{A}(t)$ for some term $t$. I'm curious which classes of groups can arise this way. > Is there a snappy description of the classes of isomorphism types of finite groups which are of the form $\mathbb{G}(\mathfrak{A})$ for some algebra $\mathfrak{A}$? **EDIT: for a more focused subquestion, is there an $\mathfrak{A}$ such that $\mathbb{G}(\mathfrak{A})$ consists exactly of the finite [$2$-groups](https://en.wikipedia.org/wiki/P-group)?** Certainly it's possible to get only $2$-groups - see e.g. [this MSE answer of Eric Wofsey](https://math.stackexchange.com/a/4337962/28111). Here are some example $\mathbb{G}(\mathfrak{A})$s (ignoring up-to-isomorphism details): - If $\mathfrak{A}=(A;\star)$ where $\star:A^2\rightarrow A$ is a bijection, then $\mathbb{G}(\mathfrak{A})$ consists only of the trivial group. - If $\mathfrak{A}=(\mathbb{N};\max)$, then $\mathbb{G}(\mathfrak{A})=\{S_n:n\in\mathbb{N}\}$. - Already something like [the naturals with exponentiation](https://math.stackexchange.com/questions/4338046/what-are-the-symmetry-groups-of-exponentiation-only-terms) seems tricky: we can make things complicated by "nesting symmetries" as in $$(x^{[(a^b)^c]})^{[(u^v)^w]}$$ or by equating variables in terms which already give rise to complicated symmetry groups. The fact that [we really only have a single nontrivial equation to lean on](https://math.stackexchange.com/questions/2078937/what-nice-properties-does-exponentiation-have/2080920#2080920) doesn't seem to trivialize the situation.