Greedy Floor-Square-Root Run Blocks
Abstract
The greedy floor-square-root sequence has exactly the conjectured decreasing runs.
OEIS A399084, submitted by Vasilios Mavroudis on 2026-08-18, gives the history-dependent sequence and records the run-length pattern as a conjecture. The definitions and proofs here were first derived in this repository; no external proof is claimed.
Every displayed variable ranges over the natural numbers unless another domain is shown. Arithmetic is natural-number arithmetic: natSub is truncated subtraction, floorSqrt is the natural square root, and groupOf(n) abbreviates natDiv(floorSqrt(4n+5)-1,2). Thus natural division is integer division, never rational division.
Definition 1.1 (Literal history-dependent sequence).
Formalization. D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq (✓ std3).
Source. Repository-derived.
Commentary.
The public sequence is the value field of a private prefix state. State zero is (0,{0}), state one is (1,{0,1}), and each later state tests value-1 against the accumulated finite set before either adding floorSqrt(value) or accepting that predecessor. The next value is inserted into the same history, so the definition implements the literal OEIS rule rather than a recurrence that assumes a closed form.
Theorem 1.2 (Sequence value at zero).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_zero (✓ std3). ∎
Source. Repository-derived.
Commentary.
The initial prefix state has value zero.
Theorem 1.3 (Sequence value at one).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_one (✓ std3). ∎
Source. Repository-derived.
Commentary.
The second prefix state has value one.
Theorem 1.4 (Literal unused-predecessor rule).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_succ_succ (✓ std3). ∎
Source. Repository-derived.
Commentary.
At index n+2 the candidate is seq(n+1)-1. Membership is tested in the image of seq on range((n+1)+1), exactly the indices already present. A seen candidate triggers the floor-square-root jump; an unseen one becomes the next value.
Definition 1.5 (Four-block group start).
Formalization. D5/S1/Digit/GreedyFloorSqrtRunBlocks.groupStart (✓ std3).
Source. Repository-derived.
Commentary.
For parameter m, the four consecutive blocks begin at s=m^2+m-1.
Definition 1.6 (Explicit four-block closed form).
Formalization. D5/S1/Digit/GreedyFloorSqrtRunBlocks.closedForm (✓ std3).
Source. Repository-derived.
Commentary.
For n below five the value is n. Otherwise m=groupOf(n), s=groupStart(m), and r=n-s. The four branches are respectively s+m-1-r, s+m, s+3m+1-r, and s+2m+1, with tests r<m, r=m, and r<=2m. This is the preregistered candidate without an equivalent replacement.
Theorem 1.7 (Square interval invariant).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.interval_invariant (✓ std3). ∎
Source. Repository-derived.
Commentary.
Writing s=groupStart(m), the ten displayed inequalities place s-1, s, s+m, and s+m+1 between m^2 and (m+1)^2, while s+2m+1 lies between (m+1)^2 and (m+2)^2. These bounds fix all five natural square roots used at the jump boundaries.
Theorem 1.8 (Closed form obeys the literal rule).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.closedForm_follows_rule (✓ std3). ∎
Source. Repository-derived.
Commentary.
Involutivity makes membership in the closed-form history equivalent to closedForm(x)<N. The square bounds then determine each jump, and an exhaustive split across the four offsets proves the exact recursive equation.
Theorem 1.9 (Recursive sequence equals the closed form).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_eq_closedForm (✓ std3). ∎
Source. Repository-derived.
Commentary.
Strong induction transports the literal history image from seq to the closed form and applies the preceding rule theorem at each index.
Theorem 1.10 (Sequence values in four blocks).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_four_blocks (✓ std3). ∎
Source. Repository-derived.
Commentary.
For every m at least two and s=groupStart(m), the first m values descend from s+m-1 to s, the next value is fixed, the following m values descend from s+2m to s+m+1, and the final value is fixed.
Definition 1.11 (Maximal decreasing run predicate).
Formalization. D5/S1/Digit/GreedyFloorSqrtRunBlocks.IsMaximalDecreasingRun (✓ std3).
Source. Repository-derived.
Commentary.
A run has positive length, decreases at every internal adjacent pair, cannot be extended to the left unless it starts at zero, and cannot be extended to the right. The last condition compares indices start+len-1 and start+len.
Theorem 1.12 (Complete maximal-run classification).
Proof. Machine-checked in Lean as D5/S1/Digit/GreedyFloorSqrtRunBlocks.maximal_decreasing_run_lengths (✓ std3). ∎
Source. Repository-derived.
Commentary.
The maximal runs are exactly the five initial singleton runs and, for each m at least two, runs (s,m), (s+m,1), (s+m+1,m), and (s+2m+1,1), where s=groupStart(m). Consequently their lengths are 1,1,1,1,1 followed by m,1,m,1 for m=2,3,4,… . Coverage of every index by one listed run and uniqueness of overlapping maximal runs make the classification exhaustive.
References
- Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.IsMaximalDecreasingRun - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.closedForm - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.closedForm_follows_rule - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.groupStart - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.interval_invariant - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.maximal_decreasing_run_lengths - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_eq_closedForm - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_four_blocks - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_one - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_succ_succ - Truth anchor:
D5/S1/Digit/GreedyFloorSqrtRunBlocks.seq_zero