Square Packing Atlas
Discrete geometry · formal proof

Short of a Square

Remove c unit squares from a k × k grid. For small c the rest still needs a square of side k; for larger c, tilting lets them squeeze into a smaller one. Write c*(k) for the largest c with s(k² − c) = k. Every bound on this page is an explicit packing of k² − c squares in a square of side less than k, for every k in a range, checked by the Lean kernel.

Status. All theorems below are proved in Lean 4 with Mathlib, from the plain definition of a packing, using only the standard axioms (propext, Classical.choice, Quot.sound). Two of them are, as far as we know, new bounds; the others formalize results of Kevin Fang and Sungjoon Ryu, one of them on a wider range than its source. Not peer reviewed; the novelty check covers the jlevy/squares register and Ryu's preprint only.

kernel-checked in Lean, no hypothesis standard axioms only not peer reviewed Lean bundle on GitHub → every packing, drawn →
The theorems

Upper bounds on c*(k)

Each line is a Lean theorem ∀ k ≥ k₀, ∃ s < k, Packs (k·k − c) s, which gives c*(k) ≤ c − 1. Highlighted rows are new mathematics of ours; every Lean proof on this page is ours. The packings page shows where each one passes k² − k.

boundforLean theorem · mathematics
c*(n) ≤ n − 2n ≥ 15FangFinal.theorem1
Kevin Fang, after Arslanov–Mustafin–Shangitbayev
+ p + 2q more squares16p + 21q ≤ n − 15FangFinal.theorem2
Fang
c*(k) ≤ 8⌈√(k − 4)⌉ − 1k ≥ 6RyuBound.packs_sub_8sqrt
Ryu, Theorem 1.4
c*(k) ≤ 4⌈√(2k − 7)⌉ − 1k ≥ 7RyuLayers.packs_sub_4sqrt2_layers
ours: axis-filled band ends (new)
c*(k) < 18.9 k2/5 + 35.7 k1/5 + 122k ≥ 3·10⁵RyuStairBound.packs_stair_k25
ours: Ryu's staircase ends, our count (new)
c*(k) < 20.668 k2/5 + 0.623k ≥ 8·10⁶RyuStairBound.packs_ryu_thm12
Ryu, Theorem 1.2 (proved there for k ≥ 1.6·10⁷; the wider range is ours)

Which is smallest where: Fang's for 15 ≤ k ≤ 39; 4⌈√(2k − 7)⌉ − 1 from 40 to about 7.4·10⁵ (it is below Ryu's 8⌈√(k − 4)⌉ − 1 at every k ≥ 7); then the two-term k2/5 bound, which is below Ryu's Theorem 1.2 bound for every k ≥ 6.7·10⁶. At small k the record packings of the register are better than any of these formulas, and Ryu's tuned certificates are better at the three k where he computed them; his k3/8 bounds (not formalized here) take over for very large k.

kFang8√ (Ryu)4⌈√(2k−7)⌉ − 1two-term k2/5Ryu Thm 1.2
100907955
10⁴9 048799567
10⁵90 4762 5351 791
10⁶904 7627 9995 6595 435
10⁷25 30317 89112 94313 041
10⁸79 99956 57131 49732 757

Entries are the resulting bounds on c*(k). Lower bounds are far smaller: c*(k) ≥ 3 for k ≥ 6, and Ryu's preprint claims c*(k) → ∞ (at least logarithmically).

The construction

An L of tilted rows

All the square-root and k2/5 bounds use Ryu's L-shaped packing (after Erdős and Graham): an axis-parallel grid of (k − b)² squares, and two bands of rows of b squares each, tilted just enough that a row is a little narrower than b. The whole fits in side k − b + w < k. Each row is tilted, so successive rows are spaced slightly more than 1 apart, which costs about 2L/b along a band of length L: about 4k/b in all. The rest of the loss is at the four band ends, the triangles under the first row and over the last.

grid (k − b)² band band
Schematic (not to scale): the grid, the two bands of tilted rows, and the four end regions (gold). The ends decide the constant. The actual packings, for every k up to 300: Packings row by row.

Empty ends

Each end wastes about b. Total ≈ 4b + 4k/b, best at b ≈ √k: Ryu's 8√k.

Axis-filled ends (new)

About b/2 axis-parallel squares fit under the first row and over the last. Total ≈ 2b + 4k/b, best at b ≈ √(2k): 4√2·√k ≈ 5.66√k. With b = ⌈√(2k − 7)⌉ the four ends hold exactly 2b squares.

Staircase ends

Columns at one tilt, axis layers under them that follow the rising ceiling, and short rows at the wall (Ryu's §6, after Bui). End cost O(b2/3); with b ≈ k3/5 the exponent is 2/5.

For the axis-filled ends, a search over every b and every axis layering of this construction finds nothing better than 4⌈√(2k − 7)⌉ − 1 for 7 ≤ k ≤ 3·10⁵. Better packings at small k exist but come from search (de Winter's, for example), not from a formula.

The proof

What Lean checks

certificates/k2-minus-c/verify.sh          # Ryu-line theorems, a few minutes
certificates/k2-minus-c/verify.sh --fang   # also Fang's 18 pieces, ~20 min, ≤ 8 GB per job

Files: lean/Sqpack/RyuBand, RyuBound, RyuFill, RyuEnds, RyuLayers, RyuStair, RyuStairCount, RyuStairEnd, RyuStairBound, FangGlue, FangTheorem, FangFinal. Numerical companions in search/ryu/.

Credits

Whose mathematics

Original work

Ours (Evan Daniel, with Claude, October 2026)