Erdős #195: the bit-reversal power-of-3 words
DefinitionErdos195_Wjarithmetic-progressionscombinatoricserdos-problems
For let denote the -bit reversal of an integer : if then (Lean: , ). Put and . The finite word of integers is
Thus lists , then the even powers with ordered by increasing bit reversal of , then the odd powers with ordered by decreasing bit reversal of , then the ground and the top . For example and .
These words arise in the tree-witness approach to Erdős Problem 195 (monotone 4-term progressions in permutations of ): they are arbitrarily long finite words that are safe for a tree-witness -adic order and release the root node, the ordering being dictated by the -adic structure .
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