\section{Formal verification and reproducibility}\label{sec:replay} The archive \path{square-packing-referee-sources.zip} accompanies this paper. It contains a Lean~4 development of the results, the programs that generate the packings, and verification records. This appendix states what the formal development proves, how its statements correspond to the numbered results of the paper, and how to rebuild it. \subsection{The quantified objects}\label{sec:formal-model} The formal statements use two coordinate descriptions of the same finite packing. In Daniel's geometry library~\cite{Daniel} a centre is a point in \(\mathbb R\times\mathbb R\) and the angle is an arbitrary real number. Here are the source definitions from \path{Sqpack/Spec.lean}, with line breaks for print. In Lean, {\rmfamily\textquotesingle{}\textquotesingle{}} denotes the image of a set and \(\times^{\mathrm s}\) its Cartesian product. \begingroup\small \begin{quote}\raggedright \ttfamily def unitSq (c : \(\mathbb R\times\mathbb R\)) (\(\theta\) : \(\mathbb R\)) : Set (\(\mathbb R\times\mathbb R\)) :=\\ \hspace*{1em}(fun p \(\Rightarrow\) c + rot \(\theta\) p) {\rmfamily\textquotesingle{}\textquotesingle{}} (Icc (-1/2) (1/2) \(\times^{\mathrm s}\) Icc (-1/2) (1/2))\\[4pt] def container (s : \(\mathbb R\)) : Set (\(\mathbb R\times\mathbb R\)) := Icc 0 s \(\times^{\mathrm s}\) Icc 0 s\\[4pt] def Packs (n : \(\mathbb N\)) (s : \(\mathbb R\)) : Prop :=\\ \hspace*{1em}\(\exists\) (c : Fin n \(\to\mathbb R\times\mathbb R\)) (\(\theta\) : Fin n \(\to\mathbb R\)),\\ \hspace*{1.8em}(\(\forall\) i, unitSq (c i) (\(\theta\) i) \(\subseteq\) container s) \(\land\)\\ \hspace*{1.8em}Pairwise fun i j \(\Rightarrow\) Disjoint\\ \hspace*{3em}(interior (unitSq (c i) (\(\theta\) i)))\\ \hspace*{3em}(interior (unitSq (c j) (\(\theta\) j))) \end{quote} \endgroup The map \texttt{rot} is the usual counterclockwise rotation matrix. The analytic proof represents the plane by \(\mathbb C\) and uses a structure \texttt{Integration.Packing}\;\(x\) with a number \(n\) of tiles, centres in \(\mathbb C\), real angles, containment of the closed footprints in the box and pairwise disjointness of their interiors. The theorem \lean{SharpPacking.Model.packs_iff} proves \[ \texttt{Packs}\;n\;x\quad\longleftrightarrow\quad \exists\,P:\texttt{Integration.Packing}\;x,\quad P.n=n . \] In these two models the waste of a particular packing and the optimum are the following quantities. \begingroup\small \begin{quote}\ttfamily\raggedright def waste \{x : \(\mathbb R\)\} (P : Packing x) : \(\mathbb R\) := x\^{}2 - P.n\\[4pt] def bestCount (x : \(\mathbb R\)) : \(\mathbb N\) :=\\ \hspace*{1em}Nat.findGreatest (fun n \(\Rightarrow\) UnitSquarePacking.Packs n x) \(\lfloor\texttt{x\^{}2}\rfloor_{\mathbb N}\)\\[4pt] def minimumWaste (x : \(\mathbb R\)) : \(\mathbb R\) := x\^{}2 - bestCount x \end{quote} \endgroup The natural-number floor is denoted by \(\lfloor\,\cdot\,\rfloor_{\mathbb N}\). For \(x\ge0\), integration over disjoint unit interiors bounds the count by \(\lfloor x^2\rfloor_{\mathbb N}\), and the empty packing supplies a feasible count. The theorems \texttt{Model.minimum\_le} and \texttt{Model.minimum\_attained} identify \texttt{minimumWaste} with the least achievable waste \(W(x)\). The wall mismatch \(d(x)\) is \texttt{Integration.mismatch}\;\(x=\min\{1,\|e^{2\pi i x}-1\|\}\). \subsection{Correspondence with the paper}\label{sec:formal-map} Tables~\ref{tab:formal-analytic} and~\ref{tab:formal-constructive} match the main results with formal declarations. Names are relative to the namespace \texttt{SharpPacking}; the two names that begin with \texttt{\_root\_} lie outside it. A formal statement agrees with the printed one unless a difference is noted. Where the formal statement is weaker, the printed statement rests on the proof given in the text. \begin{table}[!tb] \centering \caption{Lower bounds and their consequences.} \label{tab:formal-analytic} \smallskip\small \begin{tabular}{@{}>{\raggedright\arraybackslash}p{.27\linewidth}>{\raggedright\arraybackslash}p{.69\linewidth}@{}} \toprule Result & Formal declaration\\ \midrule Theorem~\ref{thm:finite} & \lean{EffectiveRefinedBound.lower_estimate}\\ Lemma~\ref{lem:rv-local} & \lean{RVChain.rothVaughan_of_packing}, with the constant \(262440\)\\ Lemma~\ref{lem:mesh-jumps} & \lean{MeshGeometry.mesh_faceTV} for \eqref{eq:mesh-jumps} and \lean{MeshGeometry.original_occupied_L1} for \eqref{eq:mesh-compare}, both for any labels that obey the local bound; \lean{RVChain.mesh_angle_labels} supplies that bound for the two labels\\ Corollary~\ref{cor:theta} & \lean{Bounds.uniform_upper} (\(W(x)\le800000\,x^{3/5}\) for \(x\ge0\)); \lean{Bounds.half_integer_theta} (the order at \(\alpha=1/2\), without explicit constants); \lean{Model.impossible_uniform}. The inequality with \(c_\alpha\) is not a separate declaration; it follows from Theorem~\ref{thm:finite}\\ \(W(x)>8\sqrt x\) at \(x=10^{340}+\frac12\) & \lean{EffectiveRefinedBound.explicit_counterexample}\\ Proposition~\ref{prop:one-mode} & \lean{SubcriticalMode.one_mode}: the weaker form \(x\,d(x)\le8\pi(1+\Cmesh^2)W(1+W)\), obtained there with a different test function\\ Lemma~\ref{lem:below-floor} & \lean{SubcriticalMode.below_waste_floor}, with the smaller floor \(\min\{1/2,\,1/(64\pi(1+\Cmesh^2))\}\)\\ Proposition~\ref{prop:small-wall} & \lean{SmallAmplitude.wall}\\ Proposition~\ref{prop:above-profile}, Theorem~\ref{thm:profile}(a) & \lean{AboveProfile.above_integer_order} (upper constant \(800000\)); \lean{AboveProfile.positive_excess_liminf} for \eqref{eq:above-ratio}\\ Corollary~\ref{cor:above-finite} & \lean{FiniteAbove.positive_stripe} and \lean{FiniteAbove.above_window}, for its two assertions\\ Proposition~\ref{prop:below-lower} & \lean{SmallWaste.minimum_below}\\ Theorem~\ref{thm:profile}(b) & lower bound: \lean{SmallWaste.minimum_below}; upper bound: \lean{AllScales.all_shortfalls}. Also \lean{MatchedBelow.matched_rate}, which bounds \(W+\sqrt x\) on both sides by multiples of \(\max\{\sqrt K,K^{3/5}\delta^{2/5}\}\)\\ Corollary~\ref{cor:pointwise} & \lean{StrictDistance.lower}\\ Theorem~\ref{thm:windows}(i) & \lean{Criterion.sequence_iff}\\ Theorem~\ref{thm:windows}(ii) & \lean{StrictDesign.minimum_iff}\\ Propositions~\ref{prop:rectangles} and~\ref{prop:rect-pinwheel} & not formalized\\ \bottomrule \end{tabular} \end{table} \begin{table}[!tb] \centering \caption{Constructions and exactly counted examples.} \label{tab:formal-constructive} \smallskip\small \begin{tabular}{@{}>{\raggedright\arraybackslash}p{.27\linewidth}>{\raggedright\arraybackslash}p{.69\linewidth}@{}} \toprule Result & Formal declaration\\ \midrule Proposition~\ref{prop:construct-rate} & real \(\delta\): \lean{AllScales.all_shortfalls} (every \(K\ge1\), constant \(400000\)) and \lean{AllScales.uniform_three_fifths}. The constant \(270624\) is formal at rational sides only: \lean{MultiRational.generate_certificate} and \lean{MultiRational.generate_large}\\ Corollary~\ref{cor:8560} & \lean{_root_.SharpPackingStair.Rounded.count_certificate}; \lean{RationalGenerator.countAt_certificate} for the count computed at rational sides\\ Proposition~\ref{prop:shallow-rate} & rational \(\delta\le K^{-1/4}\), \(K\ge2^{80}\): \lean{AdaptiveShallow.certificate} (constant \(5520272\)). Real \(\delta\le K^{-1/4}/2\): \lean{AdaptiveShallow.real_certificate} (constant \(11040546\)). For real \(\delta\) in the other half of the window the bound follows from Corollary~\ref{cor:8560}\\ Section~\ref{subsec:plain-figure}, the packing at \(63.99\) & \lean{Selector.pictured}\\ Section~\ref{sec:blocks} & at rational sides: \lean{BlockProgram.raw_waste} (the identity), \lean{BlockProgram.guard_rate} and \lean{BlockProgram.fixed_below} (the bound), \lean{BlockExample.small_packs} (the example at \(1027/4\)). \lean{BlockReal.attains_iff} is the resulting statement for real sequences\\ Corollary~\ref{cor:program} & \lean{RealDesign.certificate} (constant \(4400002\)); \lean{RealDesign.approximation}\\ Corollary~\ref{cor:shallow-unit} & \lean{ShallowProgram.real_coefficient_one}\\ Proposition~\ref{prop:family-coefficient} & \lean{_root_.CoefficientOneFamily.family}\\ Count at \(x=2^{60}-2^{-60}\) & \lean{OptimizedWitness.certificate}\\ Count at \(x=2^{38}-2^{-29}\) & \lean{CompactWide.dyadic_example}\\ Sides \(10^{400}\pm10^{-150}\) & \lean{FiniteAbove.opposite_sides}\\ Count at \(x=64^4-1/64\) (Section~\ref{sec:construct-rate}) & not a formal statement; see below\\ \bottomrule \end{tabular} \end{table} The formal development proves the statements of the tables. It does not contain the remarks, the heuristic discussion of Section~\ref{sec:scales-intro}, the comparison with the announcements quoted in Section~\ref{sec:scope}, or Section~\ref{sec:rectangles}. The intermediate lemmas of Sections~\ref{sec:lower}--\ref{sec:construction} have formal counterparts organized differently from the text; the tables list only the end results. The numerical bookkeeping of Appendix~\ref{sec:constant} follows the formal proof. The count at \(x=64^4-1/64\) in Section~\ref{sec:construct-rate} is the output of the program of Section~\ref{sec:packing-commands}, confirmed by an independent recomputation from the text. It is not a statement of the formal development. \lean{RationalGenerator.countAt_certificate} shows that the count defined in the formal development for this construction is, at every rational side with \(K\ge64^4\) and \(K\delta^4\le1\), the number of units of a packing with waste at most \(8560\sqrt x\). A literal example of this construction is formalized at the side \(64^4-64^{-4}\): \lean{RoundedExample.packing} gives \(281474976162038\) units and waste \(548616+2^{-48}\). \subsection{What has been checked}\label{sec:formal-dependencies} The native project consists of \(404\) modules of this work and ten modules of the geometry library, about \(66\,000\) lines. With Lean \(4.30.0\) and the pinned mathlib revision all \(414\) modules compile. No declaration uses \texttt{sorry}, no axiom is declared, and \texttt{native\_decide} is not used. Each of the \(897\) \texttt{\#print axioms} commands in the sources reports only the three standard axioms \texttt{propext}, \texttt{Classical.choice} and \texttt{Quot.sound}; this includes every declaration named in this appendix and in Appendix~\ref{sec:constant}. The copy of the geometry library in the native project differs from its upstream revision only in the spelling of one lemma on membership in a set, as required by Lean~4.30. The archive also records a replay of the proof terms of \(72\) selected statements in an initially empty kernel environment, by the official Lean kernel and by the Lean-for-Lean implementation. Of these, \(33\) belong to the main proof and were replayed on the preceding release of the project, which had \(389\) modules; the other \(39\) cover the coordinate programs and the strict square-root construction and were replayed on the present \(414\) modules. Not every declaration of the two tables is among the \(72\). In each run an intentionally ill-typed theorem is submitted first and rejected. The two implementations share Lean's object reader and representation of expressions. The geometric definitions of Section~\ref{sec:formal-model} specify the meaning of the accepted statements. \subsection{Building the sources}\label{sec:formal-build} Extract the archive. With the toolchain selected by the included \texttt{lean-toolchain} file, run \begin{verbatim} cd native lake update lake exe cache get lake build lake env lean ../formal-statements/Inspect.lean \end{verbatim} The first two Lake commands obtain the pinned dependency sources and their compiled library cache. The third builds the \(414\) modules and prints the axioms of every declaration for which the sources contain a \texttt{\#print axioms} command. The last prints the types and the axioms of \(78\) selected statements: the \(72\) above and six on the model and the geometry. The file \path{REFEREE.txt} in the archive describes its contents, the statement and ownership records, and the commands that repeat the independent proof-term checks. The archive is the one that accompanied the previous version of this paper and has not been changed. Where \path{REFEREE.txt} refers to Appendix~A of the paper and to ten statements printed there, the present appendix is meant; those ten statements are listed in \path{formal-statements/historical-targets.tsv}. \begin{center} \small \begin{tabular}{@{}ll@{}} \toprule Component & Source revision\\ \midrule Lean 4.30.0 & \texttt{d024af099ca4bf2c86f649261ebf59565dc8c622}\\ mathlib & \texttt{c5ea00351c28e24afc9f0f84379aa41082b1188f}\\ Daniel's Sqpack & \texttt{bb4cc78e5b35103c1f177db55e9cf08974e66563}\\ Lean-for-Lean & \texttt{7842f3878e9c4b107bf488114b6fc28067ed3ee5}\\ \bottomrule \end{tabular} \end{center} \subsection{Reproducing a packing}\label{sec:packing-commands} From the \texttt{experiments} subdirectory of the archive, the following commands return a count and its exact waste, four vertices of one specified square, and an independent recount of the cap rows in Section~\ref{sec:family}, respectively. \begin{verbatim} python design_packing.py 1073741823/64 python design_packing.py 1073741823/64 --tile right lower column 0 7 0 python coefficient_one_family.py 4096 --audit \end{verbatim} The first side is \(64^4-1/64\). It yields \(281474974387278\) units and waste \(7369072641/4096\), the numbers of Section~\ref{sec:construct-rate}. The description in Section~\ref{sec:chain} is complete enough to recompute these numbers without the program: the cuts, the angles, the thresholds and the joined rows are determined by the formulas given there. \path{SUPPLEMENT.txt} gives commands for the checked coordinate and count programs. For a real \(x\ge1\), take \(K=\lceil x\rceil\) and \(z=\lfloor Kx\rfloor/K\). The units constructed at \(z\) fit at \(x\), with \(0\le x^2-z^2<2\). For the strict square-root criterion, run \texttt{python strict\_design.py} with the positive rational side as its argument. When the integer ceiling \(K\) of the side is at least \(2^{80}\) and the shortfall satisfies \(K\delta^4\le1\), the program chooses the shallow staircase of Section~\ref{sec:shallow}, with an exact grid at an integer side. Otherwise it uses the selector of Section~\ref{sec:selector}. For example, at \(x=\sqrt{2^{320}-2}\) the program gives the integer waste \[ 37\,871\,165\,590\,256\,049\,207\,015 < \sqrt{x}/25. \] Here \(\lfloor Kx\rfloor\) is the integer square root of \(K^2(2^{320}-2)\); this gives a rational input and an exact integer comparison for the claimed bound.