Requested by cx-north-wren (entries 12760 item 2, 12877, 12890, thread of t-6d127193c0), who reports a proof on head bfb759f. It builds on the accepted ErdosSwarm/Erdos530ClassCountExample.lean (t-7ca9c8df0c: classCount_eq_card_residues_of_affine) and Erdos530SymbolSpace.lean (PreservesSums, symbol_preservesSums, classCount). It is the Lean form of the second paragraph of "An example where passing to a restriction matters" in experiments/erdos530/lower-middle-energy/NOTES.md §6: adding G = {0,…,H} ∪ H·{0,…,H} to a set inside [0,H²] forces every sum-preserving map on the whole set to be affine in the integer argument.
New file ErdosSwarm/Erdos530Scaffolding.lean, imported from ErdosSwarm.lean, in namespace ErdosSwarm.Erdos530SymbolSpace (or another namespace under ErdosSwarm; say which):
theorem eq_affine_of_preservesSums_scaffolding {H : ℕ} (hH : 1 ≤ H) {C : Finset ℕ}
(hlow : ∀ j ≤ H, j ∈ C) (hmul : ∀ i ≤ H, H * i ∈ C) (hmax : ∀ n ∈ C, n ≤ H ^ 2)
{G : Type*} [AddCommGroup G] (f : C → G) (hf : PreservesSums C f) :
∃ u v : G, ∀ n : C, f n = u + (n : ℕ) • v
theorem classCount_scaffolding {H : ℕ} (hH : 1 ≤ H) {C : Finset ℕ}
(hlow : ∀ j ≤ H, j ∈ C) (hmul : ∀ i ≤ H, H * i ∈ C) (hmax : ∀ n ∈ C, n ≤ H ^ 2)
(p : ℕ) [Fact p.Prime] :
classCount (ZMod p) C = (C.image (Nat.cast : ℕ → ZMod p)).card
Names, binder kinds and argument order may differ, and hH may be dropped (H = 0 is trivial); the hypotheses may not be stronger nor the conclusions weaker. Say in the submission what differs.
Paper proof. On [0,H], i + (j+1) = (i+1) + j makes the step f(j+1) − f(j) a constant v, so f(j) = u + j·v with u = f(0). On the multiples, H·i + H·(i+2) = 2·H·(i+1) makes the step f(H(i+1)) − f(Hi) constant, equal to f(H) − f(0) = H·v. For n ∈ C write n = H·t + r with r < H; then t ≤ H because n ≤ H², and n + 0 = H·t + r with 0, H·t, r ∈ C gives f(n) = f(Ht) + f(r) − f(0) = u + n·v. The second theorem is classCount_eq_card_residues_of_affine applied to the first with f = symbol (ZMod p) C.
At head 4bc98a5 both statements elaborate through import ErdosSwarm. With the first as sorry, I closed in a scratch file: the second (2 lines); classCount (ZMod p) C ≤ p; classCount (ZMod p) C = p when p ≤ H + 1; and for C = {0,1,2,3,4,6,9}, H = 3: classCount (ZMod 2) C = 2 and classCount (ZMod 7) C = 6. The first theorem is not proved by me.
Also update NOTES.md §6 (that paragraph, or a short "Lean status" sentence after it), saying precisely what is Lean-checked: for every finite C ⊆ [0,H²] containing the scaffolding, every sum-preserving map to an abelian group is affine and d_p(C) equals the number of residues of C modulo p, hence d_p(C) ≤ p. And what is not: the digit set B itself (its definition, its size, that it lies in [0,H²) with H = 4^r), d_p(B) = n for p > 7, and the energy and progression statements of the following paragraph. The middle-range implication of t-6d127193c0 stays open; nothing in Results.lean. If the literature could not be checked offline beyond the reference folder, say so.