proof of gauge invariance for quantum 1D ring This is a question on gauge invariance in quantum mechanics.  I do some simple math on a 1D wave-function with periodic boundary conditions, and get that gauge invariance is violated.  What am I doing wrong?
Consider one coordinate dimension configured as a ring. The gauge dependent momentum operator can be written: 
$p_{op}=-i \frac{\partial}{\partial x} - k$
Units have been chosen so that $\hbar = 1$, $k$ is an arbitrary real constant different for each gauge and $x$ represents the coordinate.
The gauge dependent eigenfunction can be written
$\psi(x)= Ae^{i(n+k)x}$
where A is a constant determined by normalization.  As is well known in quantum mechanics, an operator applied to one of its eigenfunctions should yield a real constant eigenvalue multiplying the same eigenfunction:  Thus
$[-i \frac{\partial}{\partial x} - k]  Ae^{i(n+k)x}= nAe^{i(n+k)x}$
so that the real number n is the eigenvalue, which must be determined by the boundary conditions.   
The boundary condition for this periodic system must be that the wave function should join onto itself smoothly everywhere.  Thus, if the coordinate is chosen such that x extends from –$\pi$ around the ring to $\pi$ then the eigenfunction in equation 3 must have (n + k) = m, where m is an integer.  
Under these conditions, the eigenvalue n in equation 3 will be n = m – k.  This eigenvalue depends explicitly on k, and so is not gauge invariant. 
I'm assuming this simple situation should be gauge invariant, but I don't see where I goofed.  I'd appreciate any help. 
 A: 2nd Update
If you just want to think about a 1D universe with periodic boundary conditions, there is simply the point that there is no gauge transformation that takes from one you value of $A$ constant to another. Recall a gauge transformation takes $A_\mu\rightarrow A_\mu +\partial_\mu f$, where $f$ is an arbitrary smooth  function. To go from $A = A_1$ to $A=A_2$ you would want to gauge transform with $f(x) = (A_1-A_2)x$. But since your system is periodic in $x$ this is not a smooth function. That would be okay if $\exp(i f(x)$ was a single valued function but that only happens when $A_1 -A_2$ is an integer. It is an interesting fact about some topologically nontrivial spacetimes that there are gauge fields which give the same electromagnetic fields but are not equivalent by gauge transformation. And Quantum Mechanics actually cares about the gauge fields. So it does not break gauge invariance for different $A$ to give different physical answers, since they are not connected by a gauge transformation.
The update below is mainly concerned with thinking about your 1D quantum ring as embedded in actual space. Still worth reading
Update
Arthur, I applaud the fact you're still attempting to understand this. So I'm trying to re-explain what I wrote here. QMechanic and Marek have both provided good explanations, but they don't hit exactly the source of what seems to be your confusion. Let me try again to explain.  
-Your question is: I have this simple system with a gauge field, and my answer seems to be depend on my choice of gauge. How can this be? I thought nothing physical can depend on your choice of gauge.


*

*Let's step back and remember where we first met gauge invariance. We had these $E$ and $B$, the electromagnetic fields, and these are observable physical quantities. But these are a pain to work with so we introduce the gauge fields $A$. But these are massively redundant - I can gauge transform my fields $A$ to something completely different and still have the same $E$ and $B$.  Since $E$ and $B$ are what we care about in the first place we demand our theories be "gauge invariant" - nothing physical can change when I do a gauge transformation.

*Gauge invariance is created by the fact that different gauge fields lead to physically equivalent situations. There are lots of things that look like gauge fields - but only in those situations where gauge transformation connect physically equivalent situations  must gauge invariance be respected. 

*In the situations you mention yourself, the rigid rotator, there is something that looks a lot like a gauge field. We have a hamiltonian $H = \frac{1}{2m}(p - m\omega R)^2$, where $\omega$ is the angular velocity. This looks just like a gauge field $A= m\omega R$. But different values of $A$ and $\omega$ do not correspond to the same physical situation. The rotator is spinning at a different speed. This is visibly different. Because the different $A$ are physically inequivalent, there is no reason to expect the answer to be independent of the value of $A$. And thats what you find. Correctly.

*In the case where $A$ actually is the electromagnetic vector potential the situation is slightly more subtle, since thats really supposed to gauge invariant. But I show below in the original post that, here as well, different choices of $A$ correspond to different physical situations. 
Bottom Line: Just because something looks like a gauge field doesn't mean we must have gauge invariance. Gauge invariance is only a must when gauge transformations connect physically equivalent situations. In the systems that realize a 1D quantum ring different choices of $A$ are not physically equivalent.
Original Post
Your original calculation is correct. The energy levels do depend on the magnitude of the gauge vector $A$. 
How does this not break gauge invariance? Calculate $\oint A(r)\cdot dr$, that is the integral of your gauge field around the loop. This is $\int dS\cdot \nabla \times A$ by Stokes theorem. This is $\int dA \cdot B$ by the  definition of the gauge field. So its equal to the magnetic flux $\Phi$ threading through your ring.
So if you take $A$ to be constant like you did, then we have $A = \frac{\Phi}{2\pi R}$, where $R$ is the radius of your ring. But $\Phi$ is a physical quantity -  it can't change under gauge transformations. There is no gauge transformation that keeps $A$ constant and changes its magnitude.  So its okay that different $A$ give different energy levels - they correspond to different physical situations.
This is the basis for many physical phenomena: the Aharanov-Bohm effect, flux quantization, Little-Parks effect, weak localization etc.. It's all on wikipedia. 
By the way, the weird part here is not so much that your answer depends on the guage, since the different gauges are not equivalent. The weird part is that if I take a ring a light year in radius and put a magnetic field through the a meter-squared patch in the center of the ring, all the particles know about this magnetic field even though they are a light year away. But if I cut a meter long chunk out of my ring they suddenly forget all about that magnetic field.  (Only in the limit where everything is impossibly clean, but still, its wacky).
A: 1) Let us for simplicity put various constants to one: Speed of light $c=1$; Planck constant $\hbar=1$; Mass  $m=1$ of non-relativistic scalar (Bosonic) particle in $1+1$ dimensions; charge of particle $q=1$; Circumference of spatial circle $\ell=2\pi$.
2) The mechanical momentum (sometimes called the kinetic momentum) 
$$\hat{v}~=~\hat{p}-A_x~=~\frac{1}{i}\partial_x-A_x~=~\frac{1}{i}D_x$$
(or equivalently, the covariant derivative) commutes with the Hamiltonian $\hat{H}=\frac{1}{2}\hat{v}^2+\Phi$ in the temporal gauge $\Phi=A^t=0$, which we will assume from now on. (Recall that $\Phi=A^t$ is the temporal component of the gauge potential.)  So we can find common eigenstates. Suppressing the time dependence in what follows, we want to solve the mechanical momentum eigenvalue equation 
$$\hat{v}\psi_v(x)=v \psi_v(x),$$
where the mechanical momentum eigenvalue $v\in\mathbb{R}$ is related to the energy
$E=\frac{1}{2}v^2$. The solution is $e^{ivx}$ times a Wilson line:
$$\psi_v(x)~=~ \psi_v(0)\exp\left[ivx+i\int_0^x A_x(x')dx'\right] ,\qquad v\in\mathbb{R}.$$
3) Under a local gauge transformation 
$$\psi(x)\longrightarrow \tilde{\psi}(x):=e^{i\alpha(x)}\psi(x), \qquad A_x(x)\longrightarrow \tilde{A}_x(x):=A_x(x)+\partial_x\alpha(x), $$ 
it is well-known that the covariant derivative (or mechanical momentum) transforms covariantly,
$$D_x\psi(x)\longrightarrow e^{i\alpha(x)}D_x\psi(x), \qquad 
D_x \longrightarrow \tilde{D}_x ~=~ e^{i\alpha(x)}D_x e^{-i\alpha(x)}, 
\qquad \hat{v}\longrightarrow e^{i\alpha(x)}\hat{v} e^{-i\alpha(x)}.$$
It is true that they are not gauge invariant. They are only gauge covariant. However, we may easily construct manifestly gauge invariant quantities, for instance,  $|\psi(x)|^2$; $\psi^*(x) \hat{v}\psi(x)$. In particular, the mechanical momentum eigenvalue 
$$v~=~\frac{\hat{v}\psi_v(x)}{\psi_v(x)}~=~\pm\sqrt{2E}~\in~\mathbb{R}$$ 
is a gauge invariant (still assuming temporal gauge $A^t=0$).
4) Finally, we assume for simplicity that $A_x(x)=A_x\in\mathbb{R}$ and $\tilde{A}_x(x)=\tilde{A}_x\in\mathbb{R}$ are independent of $x$. This corresponds to a partial gauge fixing. We still have residual gauge transformations left where $\alpha(x)$ is an affine function of $x$. The eigenfunction becomes
$$\psi_v(x)~=~ \psi_v(0)e^{i(v+A_x)x},\qquad
\tilde{\psi}_v(x)~=~ \tilde{\psi}_v(0)e^{i(v+\tilde{A}_x)x},\qquad v\in\mathbb{R}. $$ 
We now recall that the $x$-coordinate is periodic $x\sim x +2\pi$. The wave function should be single-valued 
$$\psi_v(x+2\pi)=\psi_v(x),\qquad\tilde{\psi}_v(x+2\pi)=\tilde{\psi}_v(x),$$ 
so 
$$v+A_x,v+\tilde{A}_x~\in~\mathbb{Z},$$ 
as OP observes. In other words, $A_x$ and $\tilde{A}_x$ belong to the same shifted lattice $\mathbb{Z}-v$. The residual affine function $\alpha(x)$ must have $x$-independent integer-valued derivative 
$$\partial_x\alpha~=~\tilde{A}_x-A_x~=~(v+\tilde{A}_x)-(v+A_x)~\in~\mathbb{Z}.$$ 
5) So what have we learned? 


*

*On one hand, we may write $v\in\mathbb{Z}-A_x$, so we see that the energy $E=\frac{1}{2}v^2$ and the mechanical momentum $v$ depend on the gauge potential $A_x\in\mathbb{R}$. 

*On the other hand, we saw in section 3 that $E$ and $v$ are gauge invariants, i.e., they are invariant under gauge transformations (still assuming temporal gauge $A^t=0$). 
The two statements (1.) and (2.) do not clash in terms of physics, only in terms of semantics. In particular, if we perform a gauge transformation on the formula $v\in\mathbb{Z}-A_x$, we cannot claim that $v$ changes since a gauge transformation changes $A_x$ by an integer. ($A_x$ itself is not necessarily an integer.)
6) Another example is the canonical momentum operator $\hat{p}=\frac{1}{i}\partial_x$.


*

*On one hand, it is independent of the gauge potential $A_x$.

*On the other hand, it is not a gauge covariant quantity, i.e., it does not transform covariantly under a gauge transformation 
$$\hat{p}\longrightarrow  e^{i\alpha(x)}\hat{p} e^{-i\alpha(x)}~=~\hat{p}-\partial_x\alpha(x).$$
Again, the two statements (1.) and (2.) do not clash in terms of physics, only in terms of semantics.
7) Finally, let us connect to Marek's comment. We have a Hilbert space $L^2(\mathbb{R}/\mathbb{Z})$ of wave functions on a circle $\mathbb{R}/\mathbb{Z}$, and a Heisenberg algebra $[\hat{x},\hat{v}]=i$. (More precisely, the Stone-von Neumann theorem is a statement about the corresponding Heisenberg group to avoid issues with unbounded operators.) I interpret Marek's comment as roughly saying that
$$\hat{x}=x, \qquad \hat{v}=\frac{1}{i}\partial_x-A_x,$$ 
yields inequivalent irreducible representations of the Heisenberg algebra labeled by a continuous label $A_x\in[0,1[$. Changing $A_x \to A_x+1$ yields an equivalent representation due to gauge symmetry.
A: I believe you're seeing a problem where there isn't one. Indeed we have $n + k \in \mathbb{Z},$ so if you shift $k$, say $$k \mapsto k + \delta,$$ you need to adjust $$n \mapsto n - \delta.$$ I wouldn't say that $n$ explicitly depends on $k$, but shifting $k$ by an arbitrary real (= non-integer) constant does force an adjustment for $n$ - not very surprising. 
However, I think you can set up the problem in a more natural way. Forget about the gauge part, just consider the wave function $\phi(x) = e^{i n x}$; to satisfy the p.b.c., you find that $n \in \mathbb{Z}.$ Now add a gauge part, $U_k(x) = e^{ikx};$ you then find that the derivative changes to $\partial_x \mapsto D_x = \partial_x - ik$ (modulo a sign error) etc. The total wave function changes to $\phi(x) \mapsto U_k(x) \phi(x) = \Psi(x)$; again, you find that $k \in \mathbb{Z}$ etc.
In this new set-up, you find that you can change $k$ by an integer without punishment, and I think this is also meant in your problem; once you restrict yourself to the integers, you have integer freedom in your choice of gauge.
A: It's possible to do quantum mechanics on other domains than $\mathbb R^3$, but you have to make a few adjustments, which you forgot to do. Namely, the gauge transformation
$$ \psi(x) \mapsto e^{i\chi(x)} \psi(x) $$
must fulfill $e^{i\chi(0)}=e^{i\chi(2\pi)}$ to be single-valued on the circle, i.e.
$$\chi(2\pi)-\chi(0)=2\pi m \quad\text{ with } m\in\mathbb Z$$
In other words, your choice $\chi(x)=kx$ is only allowed for particular values of $k$, namely $k\in\mathbb Z$.

Moreover, the eigenvalue does not depend on the gauge, despite your claim to the contrary. That's because a gauge transformation will change the velocity operator
$$ v \mapsto v - \partial_x \chi(x) $$
and its eigenvalues stay the same. No physically measurable quantity will change after a gauge transformation, ever.
A: I would like to try an answer for my own question.
The straightforward interpretation of the 3 equations in the original post is that they do present a legitimate conflict.  This conflict disappears when the spatial domain is extended to infinity, and the role of the boundary conditions goes away.  So, the conflict, the violation of gauge invariance for the finite ring, suggests that either the ring is simply not covered by quantum mechanics, or there is something about the boundary conditions implied by the ring geometry that doesn't work.
So are there other boundary conditions that could be tried?  The obvious ones are to demand periodicity not of the wave function, but of the probability density and probability current density.  These are both real (not complex) quantities, would let the phase of the wave function have a discontinuity at the boundary, so long as the gradient of the phase was smooth.
Such a choice for the boundaries would allow the continuous eigenvalue spectrum of the infinite line to apply as well to the ring, which would restore gauge invariance.  But this comes at the expense of inhomogeneous and nonlinear boundary conditions. 
The nonlinear boundary conditions could be accepted if they are consistent with the standard type of Hilbert space of Hermitean operators, and the principle of superposition.
In a paper I recently posted on arxiv.org I go into some detail about how the nonlinear boundaries are indeed consistent with both gauge invariance and the standard structure of Hilbert space.  The bottom line is that the nonlinearity creates a continuous spectrum of eigenvalues, not all of which are superposable in Hilbert space.  The nonlinearity in the boundary allows a subset to be superposable.  The combination of continuous eigenvalues and superposable discreet eigenvalues makes a band structure for the Hilbert space, rather than simple discreet levels.
PLEASE CLICK HERE for the larger explanation.
So I think the correct solution of this problem is quite significant for quantum systems coupled to their environments, such as Josephson junctions used as qubits.
