Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Erdős #195: the bit-reversal power-of-3 words W2nW_{2^n}W2n​

Definition
Erdos195_Wj

by Ethan Cheung Wang · Oct 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

arithmetic-progressionscombinatoricserdos-problems

For n≥0n\ge 0n≥0 let brn(p)\mathrm{br}_n(p)brn​(p) denote the nnn-bit reversal of an integer 0≤p<2n0\le p<2^n0≤p<2n: if p=∑i<npi2ip=\sum_{i<n}p_i2^ip=∑i<n​pi​2i then brn(p)=∑i<npi2 n−1−i\mathrm{br}_n(p)=\sum_{i<n}p_i2^{\,n-1-i}brn​(p)=∑i<n​pi​2n−1−i (Lean: br0(p)=0\mathrm{br}_0(p)=0br0​(p)=0, brn+1(p)=2 brn(p mod 2n)+⌊p/2n⌋\mathrm{br}_{n+1}(p)=2\,\mathrm{br}_n(p\bmod 2^n)+\lfloor p/2^n\rfloorbrn+1​(p)=2brn​(pmod2n)+⌊p/2n⌋). Put j=2nj=2^nj=2n and T=32j−3T=3^{2j-3}T=32j−3. The finite word WjW_jWj​ of integers is

Wj=(0, 9brn(p)⏟p=0,1,…,j−2, 3⋅9(brn(p)+j−2) mod j⏟p=j−1, j−2,…,1, p≠j/2, 2T, T).W_j=\Bigl(0,\ \underbrace{9^{\mathrm{br}_n(p)}}_{p=0,1,\dots,j-2},\ \underbrace{3\cdot 9^{(\mathrm{br}_n(p)+j-2)\bmod j}}_{p=j-1,\,j-2,\dots,1,\ p\neq j/2},\ 2T,\ T\Bigr).Wj​=(0, p=0,1,…,j−29brn​(p)​​, p=j−1,j−2,…,1, p=j/23⋅9(brn​(p)+j−2)modj​​, 2T, T).

Thus WjW_jWj​ lists 000, then the even powers 30,32,…,32j−43^0,3^2,\dots,3^{2j-4}30,32,…,32j−4 with 9t9^t9t ordered by increasing bit reversal of ttt, then the odd powers 31,…,32j−53^1,\dots,3^{2j-5}31,…,32j−5 with 3⋅9t3\cdot9^t3⋅9t ordered by decreasing bit reversal of t+2t+2t+2, then the ground 2T2T2T and the top TTT. For example W4=(0,1,81,9,27,3,486,243)W_4=(0,1,81,9,27,3,486,243)W4​=(0,1,81,9,27,3,486,243) and W8=(0,1,38,34,312,32,310,36,311,33,37,39,31,35,2⋅313,313)W_8=(0,1,3^8,3^4,3^{12},3^2,3^{10},3^6,3^{11},3^3,3^7,3^9,3^1,3^5,2\cdot3^{13},3^{13})W8​=(0,1,38,34,312,32,310,36,311,33,37,39,31,35,2⋅313,313).

These words arise in the tree-witness approach to Erdős Problem 195 (monotone 4-term progressions in permutations of Z\mathbb{Z}Z): they are arbitrarily long finite words that are safe for a tree-witness 222-adic order and release the root node, the ordering being dictated by the 222-adic structure ν2(9a−9b)=3+ν2(a−b)\nu_2(9^a-9^b)=3+\nu_2(a-b)ν2​(9a−9b)=3+ν2​(a−b).

Definition code
import Mathlib

/-!
# Erdős Problem 195 — the bit-reversal words `W_j`, `j = 2^n`

* `Erdos195.br n p`: the `n`-bit reversal of `p` (bit `i` of `p` becomes bit `n-1-i`, for `p < 2^n`).
* `Erdos195.Wj n`: the finite word `W_j` (`j = 2^n`, `T = 3^(2j-3)`):
  `0`, then the even powers `9^(br n p)` for `p = 0, …, j-2`, then the odd powers
  `3·9^((br n p + j - 2) mod j)` for `p = j-1, …, 1` with `p ≠ j/2`, then `2T`, then `T`.
-/

namespace Erdos195

/-- `n`-bit reversal. -/
def br : ℕ → ℕ → ℕ
  | 0, _ => 0
  | n + 1, p => 2 * br n (p % 2 ^ n) + p / 2 ^ n

/-- The word `W_{2^n}`. -/
def Wj (n : ℕ) : List ℤ :=
  [0] ++ (List.range (2 ^ n - 1)).map (fun p => (3 : ℤ) ^ (2 * br n p)) ++
  ((List.range (2 ^ n)).reverse.filter (fun p => p ≠ 0 ∧ p ≠ 2 ^ n / 2)).map
    (fun p => (3 : ℤ) ^ (2 * ((br n p + 2 ^ n - 2) % 2 ^ n) + 1)) ++
  [2 * 3 ^ (2 * 2 ^ n - 3), 3 ^ (2 * 2 ^ n - 3)]

end Erdos195
Source
Erdős Problem 195 (https://www.erdosproblems.com/195); construction of W_j found by Grok Bot for Ethan Cheung (computer-checked design, Oct 23 2026) with proof outline by GPT; formalized by Grok Bot

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me