# Create a superposition among the basis states of G for the hidden subgroup problem, implementing $\frac{1}{\sqrt{|G|}}\sum_{g\in G} | g,0\rangle$

I’ve been studying Simon’s problem and developing simulation models using Mathematica to extend the problem to other abelian groups and hidden subgroups of order $$\geq 2$$. I can now obtain the $$h^\perp$$ to any “hidden subgroup” $$h$$ of the 3 abelian groups of order 8 - AbelianGroup[{2,2,2}], AbelianGroup[{2,4}], or AbelianGroup[{8}].

I am now trying to further generalize the Mathematica program in my toy examples. One tiny baby step at generalization is to change what I would call the "order" of the elements of $$G$$ but that word is so overloaded in this context. For example, is the identity element $$e \in G$$ always to be encoded as $$|0 \rangle$$ in the left register? What about all the other $$g_i \in G$$?

My question is very similar to the one posed in In the hidden subgroup problem for finite Abelian groups, where does the state $\frac{1}{\sqrt{|G|}}\sum_{g\in G} |g,0\rangle$ come from?, but I trying to make my question more pointed and the answer to my question is not found there.

When I use the the a list of $$g_i$$ in the sequence that Mathematica gives them to me for the assignment $$g_i \rightarrow |i \rangle$$ I get the correct $$h^\perp$$. When I manually change the sequence of $$g_i$$ in that list it of course remains same group of elements and I get the same cosets of $$h$$ in $$G$$, just in a different sequence, but then I don't (always) get the correct $$h^\perp$$ in all three toy cases.

What am I missing in the correct implementation of $$\frac{1}{\sqrt{|G|}}\sum_{g\in G} | g,0\rangle$$.

I hope my question is clearly conveyed.