Petty’s Notebook

The Collision Invariant

About this paperRepository PDFZenodoarXiv
Cite this paper

A. S. Petty, The Collision Invariant, arXiv:2604.00045, DOI: 10.5281/zenodo.21855821.

Lean proofs

Abstract

When bb is a primitive root modulo a prime pp, the number Cp(bℓ)C_p(b^\ell) of equal digit coordinates is the agreement form of cyclic-shift Hamming correlation for the base-bb repetend of 1/p1/p. We place this observable on the complete nonzero residue ensemble, where the lag theory requires neither primality nor a primitive-root hypothesis. Multiplication by bb conjugates the digit bins to ordinary residue classes modulo bb. For every prime p>bp>b, the resulting coordinate formula shows that every Cp(g)C_p(g) is even and that precisely b−1b-1 multipliers have no collisions. They are −ub−u(modp),1≤u<b.-\frac{u}{b-u}\pmod p, \qquad 1\leq u<b. For the multiplier bℓb^\ell, if N>bℓ+1N>b^{\ell+1} and (N,b)=1(N,b)=1, then Sℓ(N)=CN(bℓ)−⌊N−1b⌋S_\ell(N)=C_N(b^\ell)-\left\lfloor\frac{N-1}{b}\right\rfloor depends only on NN modulo bℓ+1b^{\ell+1}, and no smaller power of bb determines it. Reflection gives Sℓ(a)+Sℓ(−a)=−1S_\ell(a)+S_\ell(-a)=-1, an exact mean of −1/2-1/2, and a half-group law for every interior wrapping set.

March 2026 (revised September 2026)
2020 Mathematics Subject Classification: 11A63, 11A07

The Base-Only Gate

How many digits of a repetend survive a cyclic shift? When bb is a primitive root modulo pp, the powers of bb visit every nonzero residue. The digit in the position indexed by a residue rr is ⌊br/p⌋\lfloor br/p\rfloor, and shifting the repetend by ℓ\ell positions replaces rr by bℓrb^\ell r. Thus Cp(bℓ)C_p(b^\ell) is exactly the number of agreements with that cyclic shift, while p−1−Cp(bℓ)p-1-C_p(b^\ell) is its Hamming distance.

Sequence agreement under cyclic shift belongs to classical Hamming correlation theory [1]. Kak and Chatterjee studied prime-reciprocal digit sequences as communication codes and obtained bounds for their Hamming distance from cyclic shifts and for their autocorrelation [2]. Armstrong and Armstrong study changing bases, repetend multiplication, and its group structure [3]. These sources establish that the shift observable and its group-theoretic setting are prior art.

A neighboring number-theoretic literature weights digit values along a reciprocal orbit. Under primitive-root hypotheses, Girstmair connected those values with class-number factors and expressed digit variance using a Dedekind sum [4, 5]. Murty and Thangadurai extended digit-average questions to bases of prescribed order using generalized Bernoulli numbers and Dirichlet LL-functions  [6]. Those value statistics are distinct from the equality indicator considered here, but they identify the established arithmetic setting around reciprocal digits.

The present question is a family question rather than a claim to have introduced cyclic-shift agreement. Replace a single reciprocal orbit by the complete set of nonzero residues. In the full-reptend case the two ensembles coincide. When the order of bb is smaller, the complete ensemble contains every orbit, and for the lag results the modulus need not be prime. Multiplication by the base then turns the digit intervals into ordinary residue classes. This conjugation gives the collision-coordinate formula, the base-only zero gate, the sharp determining modulus, and the reflection and half-group laws proved below. No priority claim is made for the underlying Hamming observable.

Let p>b≥2p>b\geq2, with pp prime. The digit function δ(r)=⌊br/p⌋\delta(r)=\lfloor br/p\rfloor assigns to each nonzero residue modulo pp its leading digit in base bb. It partitions the residues into bb bins Bd={r:δ(r)=d}B_d=\{r:\delta(r)=d\}. More explicitly, ∣Bd∣=⌊(d+1)pb⌋−⌊dpb⌋−1{d=b−1}.|B_d| =\left\lfloor\frac{(d+1)p}{b}\right\rfloor -\left\lfloor\frac{dp}{b}\right\rfloor -\mathbf 1_{\{d=b-1\}}. If p−1=bQ+Rp-1=bQ+R with 0≤R<b0\leq R<b, then RR bins have size Q+1Q+1 and the others have size QQ. Nothing probabilistic enters this partition. It is the direct division of the interval {1,…,p−1}\{1,\ldots,p-1\} by the first base-bb digit.

The definitions extend without change to every integer N>bN>b with (N,b)=1(N,b)=1. For 1≤r<N1\leq r<N, put δN(r)=⌊brN⌋.\delta_N(r)=\left\lfloor\frac{br}{N}\right\rfloor. For an integer xx, let [x]N[x]_N denote its least nonnegative residue modulo NN.

Definition 1. For g∈(Z/NZ)×g\in(\mathbb Z/N\mathbb Z)^\times, the collision count is CN(g)=#{r∈{1,…,N−1}:δN(r)=δN([gr]N)}.C_N(g)=\#\{r\in\{1,\ldots,N-1\}: \delta_N(r)=\delta_N([gr]_N)\}.

The collision count measures how many residues share a bin with their image under multiplication by gg. It is a function on the multiplicative group that encodes the interaction between the additive structure of the bins and the multiplicative action of gg.

For ℓ≥1\ell\geq1, the collision deviation at lag ℓ\ell is Sℓ(N)=CN([bℓ]N)−⌊N−1b⌋.S_\ell(N)=C_N([b^\ell]_N) -\left\lfloor\frac{N-1}{b}\right\rfloor. For prime pp we write δ\delta, CC, and Sℓ(p)S_\ell(p) when the modulus is clear.

The Linearization

The key structural observation is that multiplication by bb transforms the bin partition into a congruence partition.

Lemma 2 (Conjugation). Let N>bN>b with (N,b)=1(N,b)=1. For 1≤r<N1\leq r<N, put x=[br]Nx=[br]_N. Then br=NδN(r)+xbr=N\delta_N(r)+x and δN(r)=δN(s)⟺[br]N≡[bs]N(modb).\delta_N(r)=\delta_N(s) \quad\Longleftrightarrow\quad [br]_N\equiv[bs]_N\pmod b. Under the permutation r↦[br]Nr\mapsto[br]_N, the digit bins become the residue classes modulo bb inside {1,…,N−1}\{1,\ldots,N-1\}.

Proof. The first identity is Euclidean division. Reducing it modulo bb gives x≡−NδN(r)(modb).x\equiv-N\delta_N(r)\pmod b. The integer NN is invertible modulo bb, and the digit lies in {0,…,b−1}\{0,\ldots,b-1\}. Thus the residue of xx modulo bb determines the digit and is determined by it. Multiplication by bb permutes the nonzero residue classes modulo NN. ◻

The interval problem has become a congruence problem. The rest of the argument stays in that coordinate system.

Lemma 3 (Collision congruence). For every g∈(Z/NZ)×g\in(\mathbb Z/N\mathbb Z)^\times, CN(g)=#{x∈{1,…,N−1}:x≡[gx]N(modb)}.C_N(g)=\#\{x\in\{1,\ldots,N-1\}: x\equiv[gx]_N\pmod b\}.

Proof. Apply Lemma 2 to the pair rr and [gr]N[gr]_N, then replace [br]N[br]_N by xx. The second transformed residue is [gx]N[gx]_N. ◻

The Gate Width Theorem

Fix a prime p>bp>b and write p−1=bQ+R,0≤R<b.p-1=bQ+R, \qquad 0\leq R<b. For g∈Fp×∖{1}g\in\mathbb F_p^\times\setminus\{1\}, define the least positive residue c(g)=[b(1−g)−1]p.c(g)=\bigl[b(1-g)^{-1}\bigr]_p.

Lemma 4 (Collision coordinate). For every g∈Fp×∖{1}g\in\mathbb F_p^\times\setminus\{1\}, C(g)=2#{j∈{1,…,Q}:[jc(g)]p>jb}.C(g)=2\#\{j\in\{1,\ldots,Q\}:[jc(g)]_p>jb\}.

Proof. By Lemma 3, a collision is a pair x,y∈{1,…,p−1}x,y\in\{1,\ldots,p-1\} satisfying y=[gx]p,y=x+kby=[gx]_p, \qquad y=x+kb for a nonzero integer kk with ∣k∣≤Q|k|\leq Q. The case k=0k=0 would force g=1g=1, and the bound follows from ∣y−x∣≤p−2|y-x|\leq p-2. The defining congruence c(g)(1−g)≡b(modp)c(g)(1-g)\equiv b\pmod p gives x+kc(g)≡0(modp).x+kc(g)\equiv0\pmod p.

Let 1≤j≤Q1\leq j\leq Q. For k=jk=j, the unique candidate is x=p−[jc(g)]px=p-[jc(g)]_p, and x+jb≤p−1x+jb\leq p-1 exactly when [jc(g)]p>jb[jc(g)]_p>jb. For k=−jk=-j, the unique candidate is x=[jc(g)]px=[jc(g)]_p, and x−jb≥1x-jb\geq1 under the same condition. Thus every successful jj supplies two collisions and every collision arises in one of these two ways. The two displacements have opposite signs, so the two collisions are distinct. ◻

Corollary 5 (Bilateral parity). The integer C(g)C(g) is even for every g∈Fp×g\in\mathbb F_p^\times.

Proof. Lemma 4 handles g≠1g\neq1. For the identity, C(1)=p−1C(1)=p-1, which is even. ◻

Theorem 6 (Gate width). For any prime p>bp > b, {g∈(Z/pZ)×:C(g)=0}={−ub−u mod p:u=1,…,b−1}.\{g \in (\mathbb{Z}/p\mathbb{Z})^{\times} : C(g) = 0\} = \left\{-\frac{u}{b - u} \bmod p : u = 1, \ldots, b{-}1\right\}. In particular, exactly b−1b - 1 multipliers have C(g)=0C(g) = 0, independent of pp.

Proof. The identity has C(1)=p−1C(1)=p-1. For g≠1g\neq1, the value c(g)=bc(g)=b would imply (1−g)−1=1(1-g)^{-1}=1 and hence g=0g=0. If c(g)<bc(g)<b, then for 1≤j≤Q1\leq j\leq Q we have jc(g)≤Q(b−1)<pand[jc(g)]p=jc(g)<jb.jc(g)\leq Q(b-1)<p \quad\hbox{and}\quad [jc(g)]_p=jc(g)<jb. Lemma 4 gives C(g)=0C(g)=0. If c(g)>bc(g)>b, the index j=1j=1 contributes and C(g)>0C(g)>0. Therefore the zero set is given by 1≤c(g)<b1\leq c(g)<b.

Solving c(1−g)=bc(1-g)=b and putting u=b−cu=b-c gives g=−ub−u(modp),1≤u<b.g=-\frac{u}{b-u}\pmod p, \qquad 1\leq u<b. The identity g=1−bc(g)−1g=1-bc(g)^{-1} recovers gg from c(g)c(g). Thus the b−1b-1 elements are distinct. ◻

Remark 7. The deranging multipliers form a rational family parameterized by uu. The count b−1b - 1 depends only on the base, not on the prime. No primitive-root hypothesis is needed.

The Finite Determination Theorem

Theorem 8 (Finite determination). Let b≥2b\geq2 and ℓ≥1\ell\geq1. For every integer N>bℓ+1N>b^{\ell+1} with (N,b)=1(N,b)=1, the collision deviation Sℓ(N)S_\ell(N) depends only on NN modulo bℓ+1b^{\ell+1}.

Proof. Put B=bℓ,m=bB=bℓ+1.B=b^\ell, \qquad m=bB=b^{\ell+1}. For 1≤r<N1\leq r<N, define the slice index n(r)=⌊mr/N⌋n(r)=\lfloor mr/N\rfloor. Dividing the inequalities n(r)≤mr/N<n(r)+1n(r)\leq mr/N<n(r)+1 by BB shows that the original digit is δN(r)=⌊n(r)B⌋.\delta_N(r)=\left\lfloor\frac{n(r)}{B}\right\rfloor. To read the transformed digit, write Br=qN+yBr=qN+y with 1≤y<N1\leq y<N. Then mr=bBr=bqN+bymr=bBr=bqN+by and therefore n(r)=bq+δN(y),δN([Br]N)=n(r) mod b.n(r)=bq+\delta_N(y), \qquad \delta_N([Br]_N)=n(r)\bmod b.

The two digits agree exactly on the diagonal set Gℓ,b={n∈{0,…,m−1}:⌊n/B⌋=n mod b}.G_{\ell,b} =\{n\in\{0,\ldots,m-1\}: \lfloor n/B\rfloor=n\bmod b\}. It has the explicit form Gℓ,b={d(B+1)+bk:0≤d<b, 0≤k<bℓ−1}.G_{\ell,b} =\{d(B+1)+bk: 0\leq d<b,\ 0\leq k<b^{\ell-1}\}. Indeed, dd is the leading base-bb digit of the slice index, while the congruence condition fixes its final digit. In particular, ∣Gℓ,b∣=B|G_{\ell,b}|=B and both 00 and m−1m-1 belong to it.

For 0≤n<m0\leq n<m, the floor difference ⌊(n+1)Nm⌋−⌊nNm⌋\left\lfloor\frac{(n+1)N}{m}\right\rfloor -\left\lfloor\frac{nN}{m}\right\rfloor counts the integers in slice nn, except that the final difference also includes the endpoint r=Nr=N. All internal slice endpoints are nonintegral because (N,m)=1(N,m)=1. Since the final slice is diagonal, the extra endpoint is removed by CN([B]N)=−1+∑n∈Gℓ,b(⌊(n+1)Nm⌋−⌊nNm⌋).C_N([B]_N) =-1+\sum_{n\in G_{\ell,b}} \left( \left\lfloor\frac{(n+1)N}{m}\right\rfloor -\left\lfloor\frac{nN}{m}\right\rfloor \right).

Write N=mt+aN=mt+a with 1≤a<m1\leq a<m. The coprimality condition makes aa a unit modulo mm, so b∤ab\nmid a. Every summand separates as t+⌊(n+1)am⌋−⌊nam⌋.t+\left\lfloor\frac{(n+1)a}{m}\right\rfloor -\left\lfloor\frac{na}{m}\right\rfloor. Also ⌊N−1b⌋=Bt+⌊a−1b⌋=Bt+⌊ab⌋.\left\lfloor\frac{N-1}{b}\right\rfloor =Bt+\left\lfloor\frac{a-1}{b}\right\rfloor =Bt+\left\lfloor\frac ab\right\rfloor. The BB copies of tt cancel, leaving Sℓ(N)=−1−⌊ab⌋+∑n∈Gℓ,b(⌊(n+1)am⌋−⌊nam⌋).S_\ell(N) =-1-\left\lfloor\frac ab\right\rfloor +\sum_{n\in G_{\ell,b}} \left( \left\lfloor\frac{(n+1)a}{m}\right\rfloor -\left\lfloor\frac{na}{m}\right\rfloor \right). The right side depends only on the least positive residue a=[N]ma=[N]_m. ◻

Definition 9. Let m=bℓ+1m=b^{\ell+1}. Represent each unit class modulo mm by its least positive integer a∈{1,…,m−1}a\in\{1,\ldots,m-1\}. Define Sℓ(a)S_\ell(a) by the right side of (1). Equivalently, it is the common value of Sℓ(N)S_\ell(N) over all N>mN>m with N≡a(modm)N\equiv a\pmod m.

Among powers of bb, the modulus in Theorem 8 cannot be lowered.

Proposition 10 (Optimal base power). Put B=bℓB=b^\ell and m=bBm=bB. The unit classes a=1,a′=m−B+1a=1, \qquad a'=m-B+1 are congruent modulo BB, while Sℓ(a)=0,Sℓ(a′)=−(b−1)bℓ−1.S_\ell(a)=0, \qquad S_\ell(a')=-(b-1)b^{\ell-1}. Thus no power bkb^k with k≤ℓk\leq\ell determines SℓS_\ell.

Proof. Both classes are congruent to 11 modulo bb and are therefore units modulo mm. In (1), the only diagonal increment for a=1a=1 occurs at n=m−1n=m-1. Hence Sℓ(1)=0S_\ell(1)=0.

Write a diagonal index as n=d(B+1)+bk,0≤d<b,0≤k<bℓ−1.n=d(B+1)+bk, \qquad 0\leq d<b, \qquad 0\leq k<b^{\ell-1}. Since a′=m−B+1a'=m-B+1, reduction modulo mm gives [na′]m=[n(1−B)]m=d+bk.[na']_m=[n(1-B)]_m=d+bk. This lies between 00 and B−1B-1. The corresponding floor increment is 11 exactly when [na′]m≥m−a′=B−1[na']_m\geq m-a'=B-1. Equality occurs only for d=b−1d=b-1 and k=bℓ−1−1k=b^{\ell-1}-1, which gives n=m−1n=m-1. Thus the diagonal sum is again 11. Finally, ⌊a′b⌋=(b−1)bℓ−1,\left\lfloor\frac{a'}b\right\rfloor =(b-1)b^{\ell-1}, and the claimed value follows from (1). ◻

The Reflection Identity

Theorem 11 (Reflection). Let m=bℓ+1m=b^{\ell+1} and let aa be the least positive representative of a unit modulo mm. Then Sℓ(a)+Sℓ(m−a)=−1.S_\ell(a)+S_\ell(m-a)=-1.

Proof. Write dn(a)=⌊(n+1)am⌋−⌊nam⌋.d_n(a)=\left\lfloor\frac{(n+1)a}{m}\right\rfloor -\left\lfloor\frac{na}{m}\right\rfloor. Equation (1) gives Sℓ(a)=−1−⌊ab⌋+∑n∈Gℓ,bdn(a).S_\ell(a) =-1-\left\lfloor\frac ab\right\rfloor +\sum_{n\in G_{\ell,b}}d_n(a).

For 1≤n≤m−21\leq n\leq m-2, neither nana nor (n+1)a(n+1)a is divisible by mm. Hence ⌊n(m−a)m⌋=n−1−⌊nam⌋\left\lfloor\frac{n(m-a)}m\right\rfloor =n-1-\left\lfloor\frac{na}m\right\rfloor and dn(m−a)=1−dn(a).d_n(m-a)=1-d_n(a).

At the two endpoints, d0(a)=0,dm−1(a)=1.d_0(a)=0, \qquad d_{m-1}(a)=1. Both endpoints lie in Gℓ,bG_{\ell,b}. Their paired totals are therefore 00 and 22, while each of the other bℓ−2b^\ell-2 diagonal slices has paired total 11.

Since b∤ab\nmid a, ⌊ab⌋+⌊m−ab⌋=bℓ−1.\left\lfloor\frac ab\right\rfloor +\left\lfloor\frac{m-a}b\right\rfloor =b^\ell-1. Combining the floor terms and diagonal contributions gives Sℓ(a)+Sℓ(m−a)=−2−(bℓ−1)+0+2+(bℓ−2)=−1.S_\ell(a)+S_\ell(m-a) =-2-(b^\ell-1)+0+2+(b^\ell-2)=-1. ◻

Corollary 12 (Grand mean). The average of SℓS_{\ell} over all units modulo bℓ+1b^{\ell+1} is −1/2-1/2.

Proof. The map a↦m−aa\mapsto m-a permutes the units. Summing the reflection identity over every unit counts the total of SℓS_\ell twice and gives −ϕ(m)-\phi(m). Division by 2ϕ(m)2\phi(m) gives the mean. ◻

The Half-Group Structure

The finite formula for Sℓ(a)S_\ell(a) is a sum of floor increments. The increment at index nn equals 11 when (n+1)a(n+1)a crosses a multiple of mm. This local balance does not depend on whether nn belongs to the collision diagonal.

Let m≥3m\geq3 and let 1≤n≤m−21\leq n\leq m-2. Using least positive representatives for the units, define Wn={a∈(Z/mZ)×:[(n+1)a]m<a}.W_n=\{a\in(\mathbb Z/m\mathbb Z)^\times: [(n+1)a]_m<a\}.

Theorem 13 (Half-group). For every m≥3m\geq3 and every 1≤n≤m−21\leq n\leq m-2, ∣Wn∣=ϕ(m)2.|W_n|=\frac{\phi(m)}2.

Proof. Put c=n+1c=n+1, so 2≤c≤m−12\leq c\leq m-1. If aa is a unit, then [ca]m[ca]_m is nonzero. Also [ca]m=a[ca]_m=a would imply (c−1)a≡0(modm)(c-1)a\equiv0\pmod m and hence c≡1(modm)c\equiv1\pmod m, which is impossible. Therefore [ca]m[ca]_m is always strictly below or strictly above aa.

Reflection gives [c(m−a)]m=m−[ca]m.[c(m-a)]_m=m-[ca]_m. It reverses the strict comparison with aa. Thus a↦m−aa\mapsto m-a carries WnW_n bijectively onto its complement in the unit group. The two sets have the same size. ◻

Corollary 14. For m=bℓ+1m=b^{\ell+1}, every diagonal slice in Gℓ,bG_{\ell,b} other than 00 and m−1m-1 has a wrapping set of size ϕ(m)/2\phi(m)/2.

The collision diagonal chooses which local increments enter SℓS_\ell. Their exact half-group balance is already present on every interior slice.

Finite Checks

The results above are symbolic. Independent exact checks with nfield [7] evaluated the gate theorem for all 404404 pairs with 2≤b≤162\leq b\leq16 and prime b<p≤127b<p\leq127. At lag one, finite determination was checked for every eligible prime through 50005000 in bases 3,5,7,3,5,7, and 1010, giving 26232623 prime instances with every unit class represented. Reflection and the exact mean were checked on every unit class in those four finite tables. For base 33 and lags 1,2,31,2,3, finite determination was also checked for all 29862986 eligible prime instances through 80008000. These finite calculations are independent checks and are not used in the proofs.

Finite Arithmetic

In a full repetend, Cp(bℓ)C_p(b^\ell) counts the coordinates retained by a cyclic shift. The complete-residue formulation keeps that observable when bb does not generate the multiplicative group and when the lag modulus is composite. It also exposes statements about an entire denominator family that cannot be read from a single reciprocal sequence.

The first such statement is the gate theorem. Its collision coordinate pairs the two possible displacement directions, proves evenness, and classifies the zero set by b−1b-1 explicit multipliers. The second is sharp finite determination. At lag ℓ\ell, the deviation is a function on the units modulo bℓ+1b^{\ell+1}, and the two witnesses in Proposition 10 show that no lower power of the base carries the same information. Reflection then gives both the mean −1/2-1/2 and the half-group law for every interior wrapping cut.

These conclusions concern finite modular arithmetic, not the distribution of primes. Primes provide one source of unit classes, but primality is absent from the all-lag determination and reflection theorems. The contribution is therefore not a new definition of Hamming correlation. It is the exact complete-ensemble coordinate and the resulting classification of its zero gate, determining modulus, and reflection balance. This finite table is consequently ready for character or prime sampling without confusing those later questions with what has already been proved here.

References

[1]A. Lempel and H. Greenberger, Families of sequences with optimal Hamming-correlation properties, IEEE Trans. Inform. Theory 20 (1974), no. 1, 90–94. https://doi.org/10.1109/TIT.1974.1055169

[2]S. C. Kak and A. Chatterjee, On decimal sequences, IEEE Trans. Inform. Theory 27 (1981), no. 5, 647–652. https://doi.org/10.1109/TIT.1981.1056394

[3]N. J. Armstrong and R. J. Armstrong, Some properties of repetends, Math. Gaz. 87 (2003), no. 510, 437–443. https://doi.org/10.1017/S0025557200173619

[4]K. Girstmair, The digits of 1/p1/p in connection with class number factors, Acta Arith. 67 (1994), no. 4, 381–386. https://doi.org/10.4064/aa-67-4-381-386

[5]K. Girstmair, Digit variance and Dedekind sums, J. Number Theory 65 (1997), no. 2, 197–205. https://doi.org/10.1006/jnth.1997.2149

[6]M. R. Murty and R. Thangadurai, The class number of Q(−p)\mathbb{Q}(\sqrt{-p}) and digits of 1/p1/p, Proc. Amer. Math. Soc. 139 (2011), no. 4, 1277–1289. https://doi.org/10.1090/S0002-9939-2010-10560-9

[7]A. S. Petty, nfield, software repository. https://github.com/alexspetty/nfield