A092482's closed form2026-08-23 [home]
this page contains generated content delineated using this shadowing style.
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.
a three-term arithmetic progression, or 3-AP, is a triple satisfying ; once some terms have been chosen, we say a candidate is blocked if two earlier terms satisfy
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
let's define as reading the binary digits of as a base-3 numeral
these are the values listed by A005836. in terms of its published
one-based indexing,
so the final equality in the quoted comment should read
equivalently, the repaired theorem presents
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 and binToTernary is
. at , the formula gives 3,6,7, respectively. only
extend the stated range : they give the final seed value 3
(block ) and the first value after the seed, 6 (the start of block
). the case, giving 7, was already in the stated range and is
the second value of block .
tauincrementing a binary number flips its trailing ones
to zeroes and carries a new one. if k has
trailing zeroes, the step from k-1 to k, read in
base-3, is
here is the largest such that divides ; it is also the number of trailing zeroes in the binary expansion of positive . put . then ends in exactly 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
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 gives
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 , and Finset.Icc 1 n is the
integer interval .
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
and let be the set of offsets ()
below whose ternary digits are all 0 or 1.
equivalently,
in the set notation below,
viewing offsets as length- ternary strings padded with leading zeroes
(with the empty string representing 0 when ), each digit may
independently be 0 or 1, so
splitting by the leading ternary digit also gives
we then propose the closed form
for the first few blocks, we observe
| 0 | 3 | ||
| 1 | 6 | ||
| 2 | 14 | ||
| 3 | 36 |
this rewrites the closed form as a block plus an offset within that block. for example, take the formula parameter , which corresponds to the sequence term . then , so , , and . the term is
every positive n has a unique decomposition
splitting off the leading binary one and reading in base 3 gives
therefore
as i understand it, this is just the fancy way of saying:
in base-2, has a leading 1 followed by exactly
bits: this resolves which block. the values of these
bits form . when read in base-2, is the intra-block
index; when read in base-3, , it is the actual
offset from .
we capture this as closedForm_eq_block in the Lean proof.
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
both with zero-based arguments. in the Lean source these functions are
stanleyGreedy and greedySeq, respectively. block begins at
index in but at index in . 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,
this is greedySeq_defect. it is the case of the stronger blockwise
identity: whenever with ,
therefore the entire A092482 block is the corresponding ordinary Stanley
block translated by . since , this translation
is exactly the 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.
earlier, we constructed such that
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:
admissibility: no three distinct terms of form an arithmetic
progression except (1,2,3);
minimality: every integer greater than 2 outside is blocked by two
smaller terms of .
induction on the prefix length then forces the greedy process to select exactly the increasing enumeration of .
suppose are terms of and . if , the only
possibility is the permitted progression (1,2,3). now suppose that lies
in block .
first note that twice any term before block is at most .
indeed, the largest such term lies in block , and
if were in an earlier block, then , whereas
a contradiction. hence and lie in the same block. write
then
if were earlier than block , the same bound would give . but , so
again a contradiction.
all three terms must lie in block . subtracting
produces a nontrivial 3-AP in . but
consists of the first 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.
now take a candidate in the -th digit window,
but suppose . then , so at least one ternary digit of
is 2. replace every 2 by 0 to obtain
, and by 1 to obtain
. digit by digit,
and the presence of a 2 gives
both replacements lie in . translating by gives
thus the two smaller block terms block .
for example, and the missing offset gives
keepOnes(12_3) = 10_3 = 3
capDigits(12_3) = 11_3 = 4
hence
with . this is the internal branch of exists_blocking.
the digit argument covers every omitted value in the ambient digit window
the actual block is a sparse subset of this window. it remains to cover
whose length is
for example, the block- digit window is [36,63), while the next block
starts at 98; the inter-block gap is [63,98).
let
the terms before block . the recursive invariant is
for , this gives
both witnesses are earlier: , and gives .
at , and . the values use and :
for the induction step, abbreviate , , and . the level- range is . the following inclusions will be used:
for any , there are also with . if
, take ; otherwise the capDigits/keepOnes construction
from the preceding section supplies the witnesses. the four cases are:
| range for | reduced parameter | witnesses at level |
|---|---|---|
| , with | from , take , | |
| , with | from , keep , | |
| , with | from , take , | |
| , with | from , take , keep |
here prefixes a leading ternary 1, which explains the
second embedding. the four arithmetic checks are
in every case the final expression is , proving
. 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 .
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.
a cursory literature check done with my harness did not yield anything adjacent or anything that would imply a previous formalization exists.
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.