proving A092482's closed form

2026-08-23 [home]

this page contains generated content delineated using this shadowing style.

motivations

i am currently engaged in various side research projects, one of which requires me to build an evaluation set for grading the efficacy of an auto-research program built natively into a custom harness i have been rolling from scratch in Go.

i originally intended the eval set to be a set of formalization tasks and a few proof tasks over known results. i suppose i should not have been surprised that i picked off some low-hanging fruit in the process.

speaking of motivation, i was unfortunately not particularly motivated to spend more time on distilling and reducing the core kernels of the proof when writing this post; as such, you might notice that a larger portion of it is generated than usual. while i did spend hours in exploring and writing this post, i hope that it does not detract from your reading experience.

the sequence and the typo

a three-term arithmetic progression, or 3-AP, is a triple x<y<z satisfying x+z=2y; once some terms have been chosen, we say a candidate m is blocked if two earlier terms x<y<m satisfy

x+m=2y

the greedy rule chooses the least candidate that is not blocked, with (1,2,3) as the sole permitted exception.

A092482 is the greedy increasing sequence that contains no 3-AP other than its initial terms 1, 2, 3

1, 2, 3, 6, 7, 14, 15, 17, 18, 36, 37, 39, 40, 45, 46, 48, 49, 98, ...

in prose, it is defined as

a(1)=1, a(2)=2, a(3)=3; a(n) is least k such that no three terms of
a(1), a(2), ..., a(n-1), k form an arithmetic progression, except
for the first triple (1,2,3).

and the sequence contains a comment with the conjectured closed form

For n > 2, a(n+2) = 1 + 2^floor(log_2(n)) + Sum_{k=1..n}
(3^A007814(n) + 1)/2 = 1 + A053644(n) + A005836(n)
(conjectured and checked up to n=512).

the summand contains a typo: A007814(n) should be A007814(k). correcting it gives

a(n+2)=1+2log2n+k=1n3A007814(k)+12

let's define τ(n) as reading the binary digits of n as a base-3 numeral

0,1,2,3,4,5,6,7 τ 0,1,3,4,9,10,12,13

these are the values listed by A005836. in terms of its published one-based indexing,

τ(n)=A005836(n+1)

so the final equality in the quoted comment should read

a(n+2)=1+A053644(n)+A005836(n+1)

equivalently, the repaired theorem presents

a(n+2)=1+2log2n+τ(n) (n1)

which is ever so slightly stronger than the given n >2 stated on the entry. in the zero-indexed Lean definition, greedySeq r = a(r+1) and the precise formalization as

theorem greedySeq_add_two (m : ℕ) :
    greedySeq (m + 2) =
      1 + 2 ^ Nat.log 2 (m + 1) + binToTernary (m + 1)

here Nat.log 2 n is log2n and binToTernary is τ. at n=1,2,3, the formula gives 3,6,7, respectively. only n=1,2 extend the stated range n>2: they give the final seed value 3 (block L=0) and the first value after the seed, 6 (the start of block L=1). the n=3 case, giving 7, was already in the stated range and is the second value of block L=1.

why the sum is tau

incrementing a binary number flips its trailing ones to zeroes and carries a new one. if k has ν2(k) trailing zeroes, the step from k-1 to k, read in base-3, is

τ(k)-τ(k-1)=3ν2(k)+12

here ν2(k) is the largest j such that 2j divides k; it is also the number of trailing zeroes in the binary expansion of positive k. put j=ν2(k). then k-1 ends in exactly j binary ones. incrementing replaces those ones by zeroes (read: forces a carry) and changes the preceding zero to one. reading the same change in base 3 gives

3j-i=0j-13i=3j-3j-12=3j+12

for example,

k-1  = 3   011_2   tau(011_2) => 011_3 = 4
k    = 4   100_2   tau(100_2) => 100_3 = 9  # diff of 5=(3^2 + 1)/2

where _{n} is short-hand for the base and the absence of _{n} implies base-10.

telescoping from τ(0)=0 gives

τ(n)=k=1n3ν2(k)+12

Lean records the same identity without natural-number division:

theorem two_mul_binToTernary_eq_sum (n : ℕ) :
    2 * binToTernary n =
      ∑ k ∈ Finset.Icc 1 n, (3 ^ padicValNat 2 k + 1)

here padicValNat 2 k is ν2(k), and Finset.Icc 1 n is the integer interval {1,,n}.

the block geometry

similarly to my previous post, i just needed to see things: not an uncommon feeling in these contexts.

an explanation for the proof centers around decomposing and partitioning the sequence terms into blocks; with that, you can make arguments about which subsets belong in which blocks and how moving within and between blocks gives the greedy sequence by induction.

so, starting with how we construct the blocks

{1, 2} | 3 | 6 7 | 14 15 17 18 | 36 37 39 40 45 46 48 49 | 98 ...
        L=0  L=1       L=2                 L=3                L=4

let

BL=2L+3L+1

and let TL be the set of offsets (TL) below 3L whose ternary digits are all 0 or 1. equivalently,

TL={τ(r):0r<2L}

in the set notation below,

BL+TL={BL+t:tTL}

viewing offsets as length-L ternary strings padded with leading zeroes (with the empty string representing 0 when L=0), each digit may independently be 0 or 1, so

|TL|=2L, maxTL=3L-12, 2t<3L (tTL)

splitting by the leading ternary digit also gives

TL+1=TL(3L+TL)

we then propose the closed form V

V={1,2}L0(BL+TL)

for the first few blocks, we observe

L BL TL BL+TL
0 3 {0} {3}
1 6 {0,1} {6,7}
2 14 {0,1,3,4} {14,15,17,18}
3 36 {0,1,3,4,9,10,12,13} {36,37,39,40,45,46,48,49}

this rewrites the closed form as a block plus an offset within that block. for example, take the formula parameter n=6, which corresponds to the sequence term a(8). then n=22+2, so L=2, r=2, and τ(r)=103=3. the term is

a(8)=B2+τ(2)=14+3=17.

every positive n has a unique decomposition

n=2log2n+r, 0r<2log2n.

splitting off the leading binary one and reading in base 3 gives

τ(n)=3log2n+τ(r).

therefore

1+2log2n+τ(n)=1+2log2n+3log2n+τ(r)=Blog2n+τ(r).

as i understand it, this is just the fancy way of saying: in base-2, n has a leading 1 followed by exactly log2n bits: this resolves which block. the values of these bits form r. when read in base-2, r is the intra-block index; when read in base-3, τ(r), it is the actual offset from Blog2n.

we capture this as closedForm_eq_block in the Lean proof.

where the power-of-two term comes from

A005836 sequences a set of nonnegative integers such that all base-3 expansions contain only 0 and 1. adding one to each term gives A003278, the ordinary greedy 3-AP-free sequence beginning at 1:

1, 2, 4, 5, 10, 11, 13, 14, ...

notably, lemma 6.4 of Moy and Rolnick's Novel structures in Stanley sequences proves that these Stanley numbers (A005836) are 3-AP-free and greedy: no three distinct terms form an arithmetic progression, and every omitted number completes one with two earlier terms. (also, yes i linked the pre-print on purpose.)

A092482 differs in that it explicitly permits (1,2,3).

for an exact comparison, let

S(r)=A003278(r+1)=1+τ(r) G(r)=A092482(r+1)

both with zero-based arguments. in the Lean source these functions are stanleyGreedy and greedySeq, respectively. block L begins at index 2L in S but at index 2L+1 in G. thus the table below compares corresponding block starts, not equal sequence indices. subtracting the two block formulas below shows the displacement created by accepting the seed rule.

L:                  0       1       2       3       4
A092482 start:      3       6      14      36      98
zero-based index:   2       3       5       9      17
A003278 start:      2       4      10      28      82
zero-based index:   1       2       4       8      16
difference:         1       2       4       8      16

the difference doubles from one block to the next. formally,

greedySeq(2L+1)=stanleyGreedy(2L)+2L,

this is greedySeq_defect. it is the r=0 case of the stronger blockwise identity: whenever n=2L+r with 0r<2L,

S(n)=1+3L+τ(r) G(n+1)=1+3L+τ(r)+2L

therefore the entire A092482 block is the corresponding ordinary Stanley block translated by 2L. since L=log2n, this translation is exactly the 2log2n term in the closed form.

accepting 3 explains how the displacement begins: 4 is then blocked by (2,3,4) and 5 by (1,3,5), so the next term is 6. the later admissibility and covering arguments prove that the translated blocks continue to obey the greedy rule.

the proof

earlier, we constructed V such that

V={1,2}L0(BL+TL).

and, in the proof, we claim that enumeration of this set (in increasing order) is exactly the greedy process that gives us the closed form.

in order to prove this, we need further show:

  1. admissibility: no three distinct terms of V form an arithmetic progression except (1,2,3);

  2. minimality: every integer greater than 2 outside V is blocked by two smaller terms of V.

induction on the prefix length then forces the greedy process to select exactly the increasing enumeration of V.

admissibility

suppose a<b<c are terms of V and a+c=2b. if c=3, the only possibility is the permitted progression (1,2,3). now suppose that c lies in block L>0.

first note that twice any term before block L is at most BL.

indeed, the largest such term lies in block L-1, and

2(BL-1+maxTL-1)=2(2L-1+3L-1+1+3L-1-12)=BL.

if b were in an earlier block, then 2bBL, whereas

2b=a+c>cBL,

a contradiction. hence b and c lie in the same block. write

b=BL+s, c=BL+t, s<t, s,tTL.

then

a=BL+2s-t

if a were earlier than block L, the same bound would give 2aBL. but 2t<3L, so

2a=2BL+4s-2t >2BL-3L =BL+2L+1 >BL

again a contradiction.

all three terms must lie in block L. subtracting BL produces a nontrivial 3-AP in TL. but TL consists of the first 2L values of the zero-reindexed A005836.

we saw above that Moy and Rolnick's Lemma 6.4 proves that this ternary-digit sequence is 3-AP-free. this proves admissibility: the Lean theorem is noThreeAPExceptSeed_Vset.

minimality: within a block

now take a candidate in the L-th digit window,

m=BL+u, 0u<3L,

but suppose mV. then uTL, so at least one ternary digit of u is 2. replace every 2 by 0 to obtain keepOnes(u), and by 1 to obtain capDigits(u). digit by digit,

keepOnes(u)+u=2capDigits(u),

and the presence of a 2 gives

keepOnes(u)<capDigits(u)<u.

both replacements lie in TL. translating by BL gives

(BL+keepOnes(u))+(BL+u)=2(BL+capDigits(u)).

thus the two smaller block terms block m.

for example, B2=14 and the missing offset u=5=123 gives

keepOnes(12_3) = 10_3 = 3
capDigits(12_3) = 11_3 = 4

hence

14+3=17, 14+4=18, 14+5=19,

with 17+19=218. this is the internal branch of exists_blocking.

minimality: between the blocks

the digit argument covers every omitted value in the ambient digit window

[BL,BL+3L).

the actual block BL+TL is a sparse subset of this window. it remains to cover

[BL+3L,BL+1),

whose length is

BL+1-(BL+3L)=3L+2L.

for example, the block-3 digit window is [36,63), while the next block starts at 98; the inter-block gap is [63,98).

let

Pre(L)={1,2}j<L(Bj+Tj),

the terms before block L. the recursive invariant is

QL: 0μ<3L+2L tTL,pPre(L), μ+p=2t+2L+1

for m=BL+3L+μ, this gives

m+p=2(BL+t).

both witnesses are earlier: p<BL<m, and t<3L gives BL+t<BL+3Lm.

at L=0, T0={0} and Pre(0)={1,2}. the values μ=0,1 use (t,p)=(0,2) and (0,1):

4+2=23, 5+1=23.

for the induction step, abbreviate a=2L, b=3L, and BL=a+b+1. the level-(L+1) range is [0,2a+3b). the following inclusions will be used:

TLTL+1, b+TLTL+1, Pre(L)Pre(L+1).

for any 0u<b, there are also s,s'TL with u+s'=2s. if uTL, take s=s'=u; otherwise the capDigits/keepOnes construction from the preceding section supplies the witnesses. the four cases are:

range for μ reduced parameter witnesses at level L+1
[0,a) u=μ+b-a, with 0u<b from u+s'=2s, take t=s, p=BL+s'
[a,a+b) μ'=μ-a, with 0μ'<a+b from QL(μ'), keep t=s, p
[a+b,a+2b) u=μ-a-b, with 0u<b from u+s'=2s, take t=b+s, p=BL+s'
[a+2b,2a+3b) μ'=μ-a-2b, with 0μ'<a+b from QL(μ'), take t=b+s, keep p

here tb+t prefixes a leading ternary 1, which explains the second embedding. the four arithmetic checks are

μ+(BL+s') =u+2a+1+s'=2s+2a+1 μ+p =μ'+a+p=2s+2a+1 μ+(BL+s') =u+s'+2a+2b+1=2(b+s)+2a+1 μ+p =μ'+p+a+2b=2(b+s)+2a+1

in every case the final expression is 2t+2L+1+1, proving QL+1. this four-case induction is q_covering. together with internal digit blocking, it proves that every nonterm above 2 is blocked by two smaller terms of V.

some assembly required

admissibility is noThreeAPExceptSeed_Vset, and minimality is exists_blocking. the formal prefix induction starts from {1}. admissibility makes each next closed-form value legal. in the first two applications of nextGreedy_key, there is no integer strictly between 1 and 2, or between 2 and 3. thereafter every smaller unselected candidate is greater than 2, so minimality makes it illegal. the least legal next value is therefore the next closed-form value, and the induction gives

theorem greedySeq_eq_closedForm : greedySeq = closedForm

the induction derives the seed prefix {1,2,3}; the formal corollary recording this prefix is prefixSet_two.

Proofs/Enumerative/No3APGreedy.lean contains the complete formal proof: it compiles without sorry, admit, or non-standard axioms. the proved formula also derives the first 57 terms displayed on the OEIS entry.

literature check

a cursory literature check done with my harness did not yield anything adjacent or anything that would imply a previous formalization exists.

closing thoughts

i spent hours trying to understand this proof; what frustrated me the most, especially of all the proofs in my backlog, is that this one seemed to be the one that is closest to my understanding of maths as a programmer. yet, it took much longer than expected to figure out what the argument being made was.

nonetheless, i found the blockwise visualization to be quite coherent in trying to wrap my head around the proof: even more, i was surprised by the fidelity of the "conversations" i had with my research harness when trying to build intuition.

i will admit: there is something unsatisfying about formalizing and proving things in this manner; in part, i think it is because these results do not excite me, and i would rather be doing other things with my time than trying to elucidate a result i do not care about. though, that is not to say that this exercise is not without material benefit.