% Appendix A. The formal companion. \section{The formal companion}\label{app:formal} \subsection{Scope}\label{ss:formal-scope} The formal companion is a Lean~4 package of $66$ modules, about $10\,600$ lines. Its core is formed by the ten modules \begin{center} \begin{tabular}{@{}lll@{}} \code{AlienHodge} & \code{AlienHodgeNode1} & \code{AlienHodgePrinciples}\\ \code{AlienHodgeWalls} & \code{AlienHodgeWorlds} & \code{AlienHodgeOverF}\\ \code{AlienHodgeII} & \code{AlienHodgeTheory} & \code{AlienHodgeDiscriminant}\\ \code{AlienHodgeIII} & & \end{tabular} \end{center} in the namespace \code{GaiMua.Research.StandardConjectures}. The other modules are those of the GAI-MUA library on which these depend: Hilbert symbols and their product formula, Hasse invariants, the determination of signatures modulo four, and $\mathfrak{sl}_2$-triples. It is built with the toolchain \code{leanprover/lean4:v4.36.0-rc2}, a release candidate, and with Mathlib at the commit \code{b7fb16a940e9d6383e4376cecea18bb818a2d2e3}. The Lean statements formalise the arithmetic of the proofs. The geometric inputs, namely the realisations, their comparison isomorphisms, the action of correspondences, the crystalline cycle classes and Ogus's classification, enter as hypotheses: a Lean theorem such as \code{AlienHodgeWorlds.cm_block_pos_ab} says that a rational number $r$ satisfying the local symbol conditions at a finite set of primes is positive, and the paper supplies, from the geometry, the fact that the square of an algebraic class satisfies these conditions. \Cref{tab:formal} lists, for the main statements of the paper, the declarations they rest on and the hypotheses of these declarations that are geometric. \begin{longtable}{@{}>{\raggedright\arraybackslash}p{.2\textwidth}>{\raggedright\footnotesize\arraybackslash}p{.38\textwidth} >{\raggedright\arraybackslash}p{.36\textwidth}@{}} \caption{Main statements, their Lean declarations (in the namespace \texttt{GaiMua.Research.StandardConjectures}), and the hypotheses of the declarations that the paper supplies from the geometry.}\label{tab:formal}\\ \toprule Statement & Lean declarations & Geometric hypotheses\\\midrule\endfirsthead \toprule Statement & Lean declarations & Geometric hypotheses\\\midrule\endhead \Cref{lem:real} & \code{ModFour.local_data_mod4}, \code{mod4_sharp} & none\\ \Cref{lem:disc-binary} & \code{AlienHodgeNode1.disc_similitude} & none\\ \Cref{thm:binary,cor:dichotomy} & \code{AlienHodge.ahm_T1}, \code{ahm_dichotomy} & local invariants of the block\\ \Cref{thm:wall-equivalence,thm:general-wall} & \code{AlienHodge.wall_hr_iff_ahc}, \code{AlienHodgeII.hr_iff_ahc_local} & the decomposition \eqref{eq:kappa}, the crystalline invariant $\ve_p(A)$\\ \Cref{thm:tate-hdg-ahc} & \code{AlienHodge.ahc_of_tate_hr} & the Tate part is spanned by algebraic classes\\ \Cref{thm:sign-law} & \code{AlienHodgePrinciples.rank2_sign_law} & $B_\ell\simeq\form{a,b}\otimes\Ql$ for $\ell\ne p$\\ \Cref{thm:decide,prop:blind} & \code{AlienHodgePrinciples.decide_le3}, \code{blind_rank4} & none\\ \Cref{prop:same-sign,thm:anchor} & \code{AlienHodgeDiscriminant.rank4_wall_bit}, \code{AlienHodgeOverF.anchor_principle} & square classes of the lines at almost all $\ell$\\ Props.~\ref{prop:levelt}, \ref{prop:split} & \code{AlienHodgeNode1.sigma_A}, \dots, \code{gram_minus}; \code{AlienHodgeWorlds.S33.*}, \code{S3.*} & none (identities of integer matrices)\\ \Cref{prop:line} & \code{AlienHodgeNode1.line_pos} & $L\simeq\form{u}\otimes\Ql$ for almost all $\ell$\\ \Cref{prop:ogus} & \code{AlienHodgeNode1.ogus_rank2} & Ogus's normal form of $T_H$\\ \Cref{prop:cm} & \code{AlienHodgeWorlds.cm_block_pos_ab}, \code{ogus_bridge_ab} & representation of $r$ by $C_\ell$ and by $T_H\otimes\Q_q$\\ \Cref{thm:A}(i) & \code{AlienHodgeNode1.node1_hr}, \code{AlienHodgeWorlds.world_hr}, \code{AlienHodgeTheory.summand_hr_split}, \code{summand_hr_inert} & the orthogonal splitting of the algebraic classes by $\sigma$\\ \Cref{thm:reversal} & \code{AlienHodgeTheory.alien_sign_flip} & as for \cref{prop:cm}\\ \Cref{thm:ahc1-summit} & \code{AlienHodge.asl_hr}, \code{AlienHodgeII.pos_of_blocks} & the embedding of \AHCI{}(b)\\ \Cref{thm:ahc2-summit} & \code{AlienHodgeII.lambda_diag}, \code{AlienHodge.lambda_of_blocks} & the triples of \AHCII{}(ii)\\ \bottomrule \end{longtable} Not formalised: the density theorem (\cref{thm:density}), whose proof uses the Chebotarev density theorem for $\ell$-adic Lie groups, and the classification of the Lie algebra of the image; the existence theorem for rational quadratic forms used in \cref{thm:ahc1-case}; and the computations of \cref{app:data}, which are carried out in exact rational and modular arithmetic outside Lean. \subsection{Verification record}\label{ss:formal-record} The package was built from a clean build directory with the pinned toolchain and Mathlib. All $8186$ build jobs completed without errors. For each of the $210$ theorems of the ten modules, the command \texttt{\#print axioms} was run; each depends on no axioms other than \code{propext}, \code{Classical.choice} and \code{Quot.sound}, and two of them depend on none. The environment of the package was then replayed by the kernel checker \code{leanchecker} in fresh mode, which re-checks every declaration of the imported environment; it terminated with exit status zero and no error. The axiom report, the build log and the replay log are part of the deposit. \subsection{Anchors}\label{ss:formal-anchors} Every statement of the paper that rests on the formal companion carries an anchor, a list of the declarations it rests on, which the build of the paper checks against the declarations of the package. The table below gives, for each section, the number of anchored statements and of distinct declarations, and the module folders in which they lie. The statement-by-statement list is in the deposit. \AHMleansummary