The finite specification of the polynomial
The target polynomial \(P_*\) is defined by construction. It is a finite composition of existential polynomial gadgets: a template is a polynomial in parameter and witness variables, a call substitutes parameter polynomials and moves the callee's witnesses into a fresh private block of the caller, a sum of squares expresses conjunction over \(\mathbb Q\), and a product expresses disjunction. A few astronomically large integers and finite polynomials enter through three constructors whose values are never expanded. This chapter defines the expression language and its semantics, proves the semantic lemmas that make the gadgets behave as intended, defines every template, recipe, constant and constructor of the manuscript's specification exactly, and defines \(P_*\) with its witness accounting. Whether each template expresses its intended relation is proved in the chapters that use it; the inventory at the end says where.
The expression language
Scalar nodes, templates, calls with witness blocks and recipes denote integer polynomials.
Over \(\mathbb Q\) a sum of squares vanishes exactly when every term does, and a product when some factor does. Inverses are equations \(uv=1\), and pairs of rationals represent the arithmetic of \(K_0=\mathbb Q(\sqrt2)\) faithfully.
TheoremInverse witnesses#✓
Inverses are expressed by equations \(uv=1\), never by partial division.
- For \(a\in\mathbb Q\): \(a\ne0\iff\exists w\in\mathbb Q,\ aw=1\), and then \(w=1/a\).
- For \(a_0,a_1\in\mathbb Q\) and \(s=\sqrt2\): \(a_0+a_1s\ne0\iff a_0^2-2a_1^2\ne0\iff \exists w\in\mathbb Q,\ (a_0^2-2a_1^2)\,w=1\).
Consequently the gadget \(\mathrm{NZ}(a)\) is satisfiable by a choice of its fresh variable exactly when \(a\ne0\), and \(\mathrm{NZ}(a_0^2-2a_1^2)\) exactly when the pair \((a_0,a_1)\) is not \((0,0)\).
Proof sketch. Part 1 is the field structure of \(\mathbb Q\). For part 2, if \(a_0^2=2a_1^2\) with \(a_1\ne0\) then \((a_0/a_1)^2=2\), contradicting the irrationality of \(\sqrt2\); so \(a_0^2-2a_1^2=0\) forces \(a_1=0\) and then \(a_0=0\). Conversely \((0,0)\) has norm \(0\). Then apply part 1 to the norm. Since \(1,s\) are linearly independent over \(\mathbb Q\), \(a_0+a_1s=0\) exactly when \(a_0=a_1=0\).
theorem exists_mul_eq_one_iff (a : ℚ) : (∃ w : ℚ, a * w = 1) ↔ a ≠ 0
theorem exists_mul_pairNorm_eq_one_iff (a0 a1 : ℚ) :
(∃ w : ℚ, (a0 ^ 2 - 2 * a1 ^ 2) * w = 1) ↔ (⟨a0, a1⟩ : K0) ≠ 0
abbrev K0 : Type := QuadraticAlgebra ℚ 2 0
ZInQKernel/Hypotheses/MordellWeil.lean:25
Uses 1 · Used by 6
TheoremPair arithmetic represents the quadratic field#✓
For a rational pair \(u=(u_0,u_1)\) write \([u]=u_0+u_1s\in K_0\). For rational pairs \(u,u'\) and an integer \(k\):
- \([u+u']=[u]+[u']\), \([-u]=-[u]\), \([ku]=k[u]\), \([u\cdot u']=[u][u']\), \([\bar u]=\sigma[u]\) where \(\sigma\) is the conjugation \(s\mapsto-s\), and \(N(u)=[u]\,\sigma[u]\in\mathbb Q\);
- \(u\doteq u'\) holds exactly when \([u]=[u']\);
- \(\mathrm{NZ}_K(u)\) is satisfiable by its fresh variable exactly when \([u]\ne0\);
- \(\mathrm{Div}(n,d)\) holds for some value of its fresh variables with value \(q\) exactly when \([d]\ne0\) and \([q]=[n]/[d]\);
- for a rational point code \(p\) and pairs \(\zeta\), \(v\): \(Z(p,\zeta)\) holds for some value of its fresh variable exactly when either \(p=O\) and \([\zeta]=0\), or \(p_0=0\), \([y(p)]\ne0\) and \([\zeta]=-[x(p)]/[y(p)]\); and \(I\!X(p,v)\) holds exactly when either \(p=O\) and \([v]=0\), or \(p_0=0\) and \([x(p)][v]=1\).
Proof sketch. Part 1 is \(s^2=2\) and the definition of \(\sigma\). Part 2 is the linear independence of \(1,s\) over \(\mathbb Q\). Part 3 is the inverse-witness statement for pairs. Part 4 combines 2 and 3 with \([d][q]=[n]\). Part 5 unfolds the two disjunctions with the compilation theorem; the branches are exclusive because \(p_0=1\) in the first and \(p_0=0\) in the second.
noncomputable def val (x : ℕ → ℚ) (u : Pair) : K0 := ⟨ev x u.1, ev x u.2⟩
theorem holds_feq (x : ℕ → ℚ) (u v : Pair) : (feq u v).Holds x ↔ Pair.val x u = Pair.val x v
theorem holds_curve (x : ℕ → ℚ) (X Y : Pair) :
(curve X Y).Holds x ↔ Pair.val x Y ^ 2 = Pair.val x X ^ 3 + -genD ^ 2 * Pair.val x X
abbrev Pair : Type := Poly × Poly
ZInQKernel/Syntax/Language/Pairs.lean:20
abbrev K0 : Type := QuadraticAlgebra ℚ 2 0
ZInQKernel/Hypotheses/MordellWeil.lean:25
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
noncomputable def feq (u v : Pair) : Formula := .and [.eq u.1 v.1, .eq u.2 v.2]
ZInQKernel/Syntax/Language/Pairs.lean:81
noncomputable def val (x : ℕ → ℚ) (u : Pair) : K0 := ⟨ev x u.1, ev x u.2⟩
ZInQKernel/Syntax/Language/Pairs.lean:179
noncomputable def curve (X Y : Pair) : Formula :=
feq Y.sq ((X.sq.mul X).add (Pair.A.mul X))
ZInQKernel/Syntax/Language/Pairs.lean:122
def genD : K0 := ⟨75, -53⟩
ZInQKernel/Hypotheses/MordellWeil.lean:31
Uses 3 · Used by 9
Formulas, the template constructions that compile them, the scope of private witness blocks, rational constants, positivity, absolute value and point references are developed in their own section.
Fixed constants and division polynomials
The fixed integer constants, the prime catalogue, the least formal multiple and the false-triple product form one section.
The constructor psi_component inserts one coordinate of a normalized division
polynomial. The normalized recurrences agree with the classical division polynomials; the
classical multiplication-by-\(n\) formulas, stated as a proposition, give the fixed-scalar
ordinate equation \(2y([n]P)\psi_n(P)^4=\psi_{2n}(P)\), and with it the meaning of the
fixed-scalar templates on \(2E(K_0)\).
DefinitionNormalized division polynomials and their components#✓
Let \(R\) be a commutative ring and \(A\in R\). The normalized division polynomials \(f_n\in R[x]\), \(n\ge0\), of \(y^2=x^3+Ax\) are defined by $\(f_0=0,\quad f_1=f_2=1,\quad f_3=3x^4+6Ax^2-A^2,\quad f_4=2(x^6+5Ax^4-5A^2x^2-A^3),\)$ and, for larger indices, $\(f_{2m}=f_m\bigl(f_{m+2}f_{m-1}^2-f_{m-2}f_{m+1}^2\bigr)\qquad(m\ge3),\)$ $\(f_{2m+1}=\begin{cases}D_0L-R_m,& m\text{ even},\\ L-D_0R_m,& m\text{ odd},\end{cases}\qquad(m\ge2),\)$ where \(L=f_{m+2}f_m^3\), \(R_m=f_{m-1}f_{m+1}^3\) and \(D_0=16(x^3+Ax)^2\). The recursion terminates because every index on the right is smaller than the index on the left for \(n\ge5\). The division polynomials \(\psi_n\in R[x,y]\), \(n\in\mathbb Z\), are $\(\psi_n=f_n\ (n\ge0\text{ odd}),\qquad\psi_n=2y\,f_n\ (n\ge0\text{ even}),\qquad\psi_{-n}=-\psi_n .\)$
Components. Take \(R=\mathbb Z[x_0,x_1,y_0,y_1][s]/(s^2-2)\), whose elements are pairs over \(\mathbb Z[x_0,x_1,y_0,y_1]\) with the pair product \((a,b)(c,d)=(ac+2bd,ad+bc)\), and \(A=-11243+7950s\). For \(n\in\mathbb Z\) and \(c\in\{0,1\}\), the component polynomial \(\Psi_{n,c}\in\mathbb Z[x_0,x_1,y_0,y_1]\) is the coefficient of \(s^c\) in \(\psi_n(x_0+x_1s,\ y_0+y_1s)\). The constructor \(\mathrm{psi}\ e\ (a_0,\dots,a_3)\ c\) denotes \(\Psi_{\mathrm{val}(e),c}\) evaluated at the polynomials of its four argument nodes.
The index of every occurring component is a fixed integer expression (\(n\), \(n+1\), \(n-1\) or \(2n\) for a fixed index \(n\) of a scalar template); the polynomials \(\Psi_{n,c}\) for the astronomical index \(c_*\) are never expanded, and every statement about them is proved from the recurrences.
This is a definition.
noncomputable def normDiv (A : R) (n : ℕ) : R[X] :=
preNormEDS' (divD0 A) (divF3 A) (divF4 A) n
noncomputable def divPsi (A : R) (n : ℤ) : R[X][Y] :=
(n.sign : R[X][Y]) * (C (normDiv A n.natAbs) * if Even n then 2 * Y else 1)
noncomputable def psiComponent (n : ℤ) (c : Fin 2) : MvPolynomial (Fin 4) ℤ :=
let v : ComponentRing := psiEval componentA n ⟨.X 0, .X 1⟩ ⟨.X 2, .X 3⟩
![v.re, v.im] c
noncomputable def divD0 (A : R) : R[X] := 16 * (X ^ 3 + C A * X) ^ 2
ZInQKernel/Model/DivisionPolynomials/Defs.lean:25
noncomputable def divF3 (A : R) : R[X] := 3 * X ^ 4 + 6 * C A * X ^ 2 - C A ^ 2
ZInQKernel/Model/DivisionPolynomials/Defs.lean:28
noncomputable def divF4 (A : R) : R[X] :=
2 * (X ^ 6 + 5 * C A * X ^ 4 - 5 * C A ^ 2 * X ^ 2 - C A ^ 3)
ZInQKernel/Model/DivisionPolynomials/Defs.lean:31
noncomputable def normDiv (A : R) (n : ℕ) : R[X] :=
preNormEDS' (divD0 A) (divF3 A) (divF4 A) n
ZInQKernel/Model/DivisionPolynomials/Defs.lean:35
abbrev ComponentRing : Type := QuadraticAlgebra (MvPolynomial (Fin 4) ℤ) 2 0
ZInQKernel/Model/DivisionPolynomials/Defs.lean:117
noncomputable def psiEval (A : R) (n : ℤ) (x y : R) : R :=
(divPsi A n).evalEval x y
ZInQKernel/Model/DivisionPolynomials/Defs.lean:103
noncomputable def componentA : ComponentRing := ⟨-11243, 7950⟩
ZInQKernel/Model/DivisionPolynomials/Defs.lean:120
Used by 9
TheoremAgreement with the classical division polynomials#✓
Let \(R\) be a commutative ring, \(A\in R\), and let \(W_A\) be the Weierstrass curve \(y^2=x^3+Ax\) (\(a_1=a_2=a_3=a_6=0\), \(a_4=A\)), so that \(b_2=b_6=0\), \(b_4=2A\), \(b_8=-A^2\). Let \(\mathrm{pre}\Psi_n\in R[x]\) and \(\Psi_n\in R[x,y]\) (\(n\in\mathbb Z\)) be the classical normalized division polynomials of \(W_A\): \(\mathrm{pre}\Psi_n\) is the normalized elliptic divisibility sequence with initial values \(0,1,1,\Psi_3,\mathrm{pre}\Psi_4\) and parameter \((\Psi_2^{\rm Sq})^2\), where \(\Psi_2^{\rm Sq}=4x^3+b_2x^2+2b_4x+b_6\), \(\Psi_3=3x^4+b_2x^3+3b_4x^2+3b_6x+b_8\), and \(\mathrm{pre}\Psi_4=2x^6+b_2x^5+5b_4x^4+10b_6x^3+10b_8x^2+(b_2b_8-b_4b_6)x+(b_4b_8-b_6^2)\); and \(\Psi_n=\mathrm{pre}\Psi_n\cdot2y\) for even \(n\), \(\Psi_n=\mathrm{pre}\Psi_n\) for odd \(n\). Then $\(f_n=\mathrm{pre}\Psi_n\ \ (n\ge0),\qquad \psi_n=\Psi_n\ \ (n\in\mathbb Z).\)$ Moreover \(\Psi_n\) agrees with the classical bivariate division polynomial modulo the curve equation, so the two take the same values at every point of \(W_A\).
Proof sketch. For \(W_A\): \(\Psi_2^{\rm Sq}=4(x^3+Ax)\), so \((\Psi_2^{\rm Sq})^2=D_0\); \(\Psi_3=3x^4+6Ax^2-A^2=f_3\); and \(\mathrm{pre}\Psi_4=2x^6+10Ax^4-10A^2x^2-2A^3=f_4\). The normalized sequence satisfies \(\mathrm{pre}\Psi_{2m}=\mathrm{pre}\Psi_{m-1}^2\mathrm{pre}\Psi_m\mathrm{pre}\Psi_{m+2} -\mathrm{pre}\Psi_{m-2}\mathrm{pre}\Psi_m\mathrm{pre}\Psi_{m+1}^2\) and \(\mathrm{pre}\Psi_{2m+1}=\mathrm{pre}\Psi_{m+2}\mathrm{pre}\Psi_m^3\cdot\epsilon_m-\mathrm{pre}\Psi_{m-1}\mathrm{pre}\Psi_{m+1}^3\cdot\epsilon_m'\) with \((\epsilon_m,\epsilon'_m)=(D_0,1)\) for even \(m\) and \((1,D_0)\) for odd \(m\), which are the recurrences of \(f_n\). Strong induction on \(n\) gives \(f_n=\mathrm{pre}\Psi_n\); the formulas for \(\psi_n\) and \(\Psi_n\), including \(\psi_{-n}=-\psi_n\) and the oddness of the sequence, then agree. The final assertion is the classical congruence between the two bivariate families in the coordinate ring.
theorem normDiv_eq_preΨ' (n : ℕ) : normDiv A n = (WA A).preΨ' n
theorem divPsi_eq_Ψ (n : ℤ) : divPsi A n = (WA A).Ψ n
theorem mk_divPsi (n : ℤ) : WeierstrassCurve.Affine.CoordinateRing.mk (WA A) (divPsi A n) =
WeierstrassCurve.Affine.CoordinateRing.mk (WA A) ((WA A).ψ n)
noncomputable def normDiv (A : R) (n : ℕ) : R[X] :=
preNormEDS' (divD0 A) (divF3 A) (divF4 A) n
ZInQKernel/Model/DivisionPolynomials/Defs.lean:35
def WA (A : R) : WeierstrassCurve R where
a₁ := 0
a₂ := 0
a₃ := 0
a₄ := A
a₆ := 0
ZInQKernel/Model/DivisionPolynomials/Classical.lean:22
noncomputable def divPsi (A : R) (n : ℤ) : R[X][Y] :=
(n.sign : R[X][Y]) * (C (normDiv A n.natAbs) * if Even n then 2 * Y else 1)
ZInQKernel/Model/DivisionPolynomials/Defs.lean:77
Uses 1 · Used by 1
DefinitionThe multiplication-by-n formulas#✓
This article states, as a proposition, the classical formulas for multiplication by \(n\) on \(E:y^2=x^3-d^2x\) over \(K_0\) (so \(A=-d^2=-11243+7950s\)). The proposition asserts: for every affine point \(P=(x,y)\in E(K_0)\) and every integer \(n\ne0\),
- \([n]P=O\) if and only if \(\psi_n(x,y)=0\);
- if \([n]P\ne O\), then $\(x([n]P)=x-\frac{\psi_{n+1}(x,y)\,\psi_{n-1}(x,y)}{\psi_n(x,y)^2},\qquad y([n]P)=\frac{\psi_{2n}(x,y)}{2\,\psi_n(x,y)^4}.\)$
Equivalently \(x([n]P)=\phi_n/\psi_n^2\) and \(y([n]P)=\omega_n/\psi_n^3\) with \(\phi_n=x\psi_n^2-\psi_{n+1}\psi_{n-1}\), \(\omega_n=(\psi_{n+2}\psi_{n-1}^2-\psi_{n-2}\psi_{n+1}^2)/(4y)\) and \(\psi_{2n}=2\psi_n\omega_n\); the second formula is the fixed-scalar ordinate equation \(2y([n]P)\psi_n(P)^4=\psi_{2n}(P)\).
This is classical (Sutherland §§5.5-5.6, Lemmas 5.20 and 5.24 and Theorem 5.21; Silverman, Exercise 3.7; Washington, Theorem 9.33) for every elliptic curve in short Weierstrass form over a field of characteristic \(0\). It enters the proof only through the fixed-scalar templates. This article fixes the statement as a proposition; the elliptic-model chapter proves it as a background theorem, and the fixed-scalar semantics uses that theorem. Its formal proof is a substantial project independent of this manuscript.
def DivisionPolynomialMultiplication : Prop :=
∀ (x y : K0) (h : genCurve.toAffine.Nonsingular x y) (n : ℤ), n ≠ 0 →
(n • Affine.Point.some x y h = 0 ↔ psiEval genA n x y = 0) ∧
(n • Affine.Point.some x y h ≠ 0 →
∃ h' : genCurve.toAffine.Nonsingular
(x - psiEval genA (n + 1) x y * psiEval genA (n - 1) x y / psiEval genA n x y ^ 2)
(psiEval genA (2 * n) x y / (2 * psiEval genA n x y ^ 4)),
n • Affine.Point.some x y h = Affine.Point.some _ _ h')
abbrev K0 : Type := QuadraticAlgebra ℚ 2 0
ZInQKernel/Hypotheses/MordellWeil.lean:25
def genCurve : WeierstrassCurve K0 where
a₁ := 0
a₂ := 0
a₃ := 0
a₄ := -genD ^ 2
a₆ := 0
ZInQKernel/Hypotheses/MordellWeil.lean:34
noncomputable def psiEval (A : R) (n : ℤ) (x y : R) : R :=
(divPsi A n).evalEval x y
ZInQKernel/Model/DivisionPolynomials/Defs.lean:103
noncomputable def genA : K0 := -genD ^ 2
ZInQKernel/Model/DivisionPolynomials/MulByN.lean:18
Uses 2 · Used by 1 · Informal links 1
The semantics of the fixed-scalar templates rests on these formulas and on the generator, so it is stated in the elliptic model chapter (semantics of the fixed-scalar templates).
The template library
The two basic elliptic templates express membership in \(2E(K_0)\) and raw addition of canonical codes.
DefinitionThe membership template#✓
The template \(\mathtt{member}\) has \(5\) parameters and \(7\) witnesses (\(12\) variables). Its variables are: the point \(p=(X_0,\dots,X_4)\); the pairs \(X=(X_5,X_6)\), \(Y=(X_7,X_8)\) and \(H=(X_9,X_{10})\); and the inverse witness \(u=X_{11}\) of \(\mathrm{NZ}_K(Y)\). With \(x_P=H^2-2X\) and \(y_P=H\cdot(X-x_P)-Y\), its formula is $\(\varphi_{\rm member}=\bigvee\Bigl(\mathrm{isO}(p),\ \bigwedge\bigl(\mathrm{fin}(p),\ \mathrm{curve}(X,Y),\ N(Y)\,u\doteq1,\ (2Y)\cdot H\doteq3X^2+A,\ x(p)\doteq x_P,\ y(p)\doteq y_P\bigr)\Bigr),\)$ and, having no rational constants, its polynomial is \([\![\mathtt{member}]\!]=\kappa(\varphi_{\rm member})^2\).
The second branch says: \((X,Y)\in E(K_0)\) with \(Y\ne0\), \(H\) is the tangent slope at \((X,Y)\), and \(p\) is the code of the affine point \(2(X,Y)\). That \(\mathrm{Rel}_{\mathtt{member}}(p)\) holds exactly for the codes of points of \(2E(K_0)\) is the membership statement of the model chapter.
This is a definition (template index \(0\) of the library).
noncomputable def memberTemplate : ExPoly := Build.template 5 (memberBuild (varPoint 0))
theorem memberTemplate_rel_iff (a : Fin 5 → ℚ) :
memberTemplate.Rel a ↔ ∃ y : Fin 7 → ℚ,
(memberFormula (varPoint 0) (varPair 5) (varPair 7) (varPair 9) 11).Holds
(assign 5 7 a y)
structure ExPoly where
/-- The parameter count `p`; the parameters are `X_0, …, X_{p-1}`. -/
params : ℕ
/-- The witness count `m`; the witnesses are `X_p, …, X_{p+m-1}`. -/
witnesses : ℕ
/-- The polynomial. -/
poly : Poly
ZInQKernel/Syntax/Language/Basic.lean:172
noncomputable def Build.template (p : ℕ) (b : Build Formula) : ExPoly :=
⟨p, (b ⟨p, []⟩).2.next - p,
(Formula.and ((b ⟨p, []⟩).2.globals.map globalEq ++ [(b ⟨p, []⟩).1])).compile⟩
ZInQKernel/Syntax/Language/Build.lean:108
noncomputable def memberBuild (p : Code) : Build Formula := do
let X ← Build.freshPair
let Y ← Build.freshPair
let H ← Build.freshPair
let u ← Build.freshIdx
pure (memberFormula p X Y H u)
ZInQKernel/Syntax/Templates/Member.lean:30
noncomputable def varPoint (k : ℕ) : Code := fun i => X (k + i)
ZInQKernel/Syntax/Templates/Scope.lean:466
noncomputable def memberTemplate : ExPoly := Build.template 5 (memberBuild (varPoint 0))
ZInQKernel/Syntax/Templates/Member.lean:38
noncomputable def memberFormula (p : Code) (X Y H : Pair) (u : ℕ) : Formula :=
let xP := H.sq.sub (Pair.smul 2 X)
let yP := (H.mul (X.sub xP)).sub Y
.or [isO p, .and [fin p, curve X Y, nzFormula Y.norm u,
feq ((Pair.smul 2 Y).mul H) ((Pair.smul 3 X.sq).add Pair.A), feq p.x xP, feq p.y yP]]
ZInQKernel/Syntax/Templates/Member.lean:22
noncomputable def varPair (k : ℕ) : Pair := (X k, X (k + 1))
ZInQKernel/Syntax/Templates/Scope.lean:469
def assign (p m : ℕ) (a : Fin p → ℚ) (y : Fin m → ℚ) (i : ℕ) : ℚ :=
if h : i < p then a ⟨i, h⟩ else if h' : i - p < m then y ⟨i - p, h'⟩ else 0
ZInQKernel/Syntax/Language/Basic.lean:181
Uses 2 · Used by 10
DefinitionThe raw addition template#✓
The template \(\mathtt{raw\_add}\) has \(15\) parameters and \(6\) witnesses (\(21\) variables). Its variables are the points \(p=(X_0,\dots,X_4)\), \(q=(X_5,\dots,X_9)\), \(r=(X_{10},\dots,X_{14})\), the slope pairs \(m_g=(X_{15},X_{16})\) and \(m_d=(X_{17},X_{18})\), and the inverse witnesses \(u_g=X_{19}\), \(u_d=X_{20}\). Write \(x=x(p)\), \(y=y(p)\), \(x'=x(q)\), \(y'=y(q)\), \(\mathrm{both}=\bigwedge(\mathrm{fin}(p),\mathrm{fin}(q))\) and, for a slope pair \(m\), $\(\mathrm{out}(m)=\bigwedge\bigl(\mathrm{fin}(r),\ x(r)\doteq m^2-x-x',\ y(r)\doteq m\cdot(x-x_r)-y\bigr),\qquad x_r=m^2-x-x'.\)$ The formula is the disjunction of five branches, in this order: $\(\varphi_{\rm add}=\bigvee(\beta_1,\beta_2,\beta_3,\beta_4,\beta_5),\)$ $\(\beta_1=\bigwedge(\mathrm{isO}(p),\ \mathrm{eq}(q,r)),\qquad \beta_2=\bigwedge(\mathrm{fin}(p),\ \mathrm{isO}(q),\ \mathrm{eq}(p,r)),\)$ $\(\beta_3=\bigwedge(\mathrm{both},\ x\doteq x',\ y\doteq-y',\ \mathrm{isO}(r)),\)$ $\(\beta_4=\bigwedge\bigl(\mathrm{both},\ N(x'-x)\,u_g\doteq1,\ (x'-x)\cdot m_g\doteq y'-y,\ \mathrm{out}(m_g)\bigr),\)$ $\(\beta_5=\bigwedge\bigl(\mathrm{both},\ x\doteq x',\ y\doteq y',\ N(y)\,u_d\doteq1,\ (2y)\cdot m_d\doteq3x^2+A,\ \mathrm{out}(m_d)\bigr).\)$ Its polynomial is \([\![\mathtt{raw\_add}]\!]=\kappa(\varphi_{\rm add})^2\).
The branches cover both identities, opposite points, distinct abscissas and doubling with nonzero ordinate. The contract \(\mathrm{Add}_{\rm raw}(\iota(a),\iota(b),r)\iff r=\iota(a+b)\) is proved in the model chapter.
This is a definition (template index \(1\)).
noncomputable def rawAddTemplate : ExPoly :=
Build.template 15 (rawAddBuild (varPoint 0) (varPoint 5) (varPoint 10))
theorem rawAddTemplate_rel_iff (a : Fin 15 → ℚ) :
rawAddTemplate.Rel a ↔ ∃ y : Fin 6 → ℚ,
(rawAddFormula (varPoint 0) (varPoint 5) (varPoint 10) (varPair 15) (varPair 17) 19
20).Holds (assign 15 6 a y)
structure ExPoly where
/-- The parameter count `p`; the parameters are `X_0, …, X_{p-1}`. -/
params : ℕ
/-- The witness count `m`; the witnesses are `X_p, …, X_{p+m-1}`. -/
witnesses : ℕ
/-- The polynomial. -/
poly : Poly
ZInQKernel/Syntax/Language/Basic.lean:172
noncomputable def Build.template (p : ℕ) (b : Build Formula) : ExPoly :=
⟨p, (b ⟨p, []⟩).2.next - p,
(Formula.and ((b ⟨p, []⟩).2.globals.map globalEq ++ [(b ⟨p, []⟩).1])).compile⟩
ZInQKernel/Syntax/Language/Build.lean:108
noncomputable def rawAddBuild (p q r : Code) : Build Formula := do
let mg ← Build.freshPair
let md ← Build.freshPair
let ug ← Build.freshIdx
let ud ← Build.freshIdx
pure (rawAddFormula p q r mg md ug ud)
ZInQKernel/Syntax/Templates/Member.lean:93
noncomputable def varPoint (k : ℕ) : Code := fun i => X (k + i)
ZInQKernel/Syntax/Templates/Scope.lean:466
noncomputable def rawAddTemplate : ExPoly :=
Build.template 15 (rawAddBuild (varPoint 0) (varPoint 5) (varPoint 10))
ZInQKernel/Syntax/Templates/Member.lean:101
noncomputable def rawAddFormula (p q r : Code) (mg md : Pair) (ug ud : ℕ) : Formula :=
let both : Formula := .and [fin p, fin q]
.or [.and [isO p, peq q r],
.and [fin p, isO q, peq p r],
.and [both, feq p.x q.x, feq p.y q.y.neg, isO r],
.and [both, nzFormula (q.x.sub p.x).norm ug, feq ((q.x.sub p.x).mul mg) (q.y.sub p.y),
addOut r p.x p.y q.x mg],
.and [both, feq p.x q.x, feq p.y q.y, nzFormula p.y.norm ud,
feq ((Pair.smul 2 p.y).mul md) ((Pair.smul 3 p.x.sq).add Pair.A), addOut r p.x p.y q.x md]]
ZInQKernel/Syntax/Templates/Member.lean:81
noncomputable def varPair (k : ℕ) : Pair := (X k, X (k + 1))
ZInQKernel/Syntax/Templates/Scope.lean:469
def assign (p m : ℕ) (a : Fin p → ℚ) (y : Fin m → ℚ) (i : ℕ) : ℚ :=
if h : i < p then a ⟨i, h⟩ else if h' : i - p < m then y ⟨i - p, h'⟩ else 0
ZInQKernel/Syntax/Language/Basic.lean:181
Uses 2 · Used by 9
The remaining templates (local parameter, inverse abscissa, logarithm, pole, the multiplication certificate, the guard, multiplication, natural codes and the value templates) and the ordered library are in their own section.
Recipes and the specified polynomial
Natural circuits are translated into model-evaluation recipes, five composition recipes assemble the root, and the witness counts are accounted for.
\(P_*\) is the polynomial of the root recipe integers. The recipes that use the compiler's natural
circuits, and \(P_*\) itself, are stated in
the chapter on the outer recipes and their translation
(the specified polynomial).
Inventory and correctness
| Template | Parameters | Witnesses | Correctness proved in |
|---|---|---|---|
| member | 5 | 7 | model chapter, membership (Section 3.1) |
| raw_add | 15 | 6 | model chapter, raw addition (Section 3.1) |
| raw_z | 7 | 1 | multiplication chapter (Section 6) |
| raw_inverse_x | 7 | 0 | multiplication chapter (Section 6) |
| log25 | 4 | 0 | multiplication chapter (Section 6) |
| pole | 1 | 11 | this chapter (pole-template semantics: the relation is \(\Phi\)); used with pole completeness |
| test_group | 44 | 162 | multiplication chapter (Section 6) |
| slope | 22 | 1,298 | multiplication chapter (Section 6) |
| height_certificate | 36 | 35,106 | multiplication chapter (Section 6) |
| multiply.scalar | 10 | 1 | this chapter (fixed-scalar semantics) |
| multiply.guard | 15 | 1 | this chapter (guard semantics) |
| multiply | 15 | 35,134 | multiplication chapter, input M |
| natural | 5 | 140,604 | this chapter (natural-code semantics, Section 3.1), from M and raw addition |
| value.signed_encode | 10 | 140,654 | assembly chapter (Sections 10-11) |
| value.abs | 2 | 4 | this chapter (absolute value by four squares, template corollary) |
| value.close_coordinates | 16 | 53 | assembly chapter (Section 11) |
| value.test | 11 | 35,282 | assembly chapter (Section 11) |
| value.exceptions | 6 | 406 | assembly chapter (Section 11) |
| scalar.integer_constant_0..4 | 10 | 1 | this chapter (fixed-scalar semantics) |
| Recipe | Kind | Parameters | Witnesses | Correctness proved in |
|---|---|---|---|---|
| power_value | model evaluation | 20 | 17,786,698 | compiler chapter, rational translation |
| precision | model evaluation | 25 | 292,889,492,836 | compiler chapter, rational translation |
| close | sum of squares | 11 | 292,890,196,199 | assembly chapter |
| main | sum of squares | 6 | 292,890,231,486 | assembly chapter |
| value_union | product | 6 | 292,890,231,892 | assembly chapter |
| value | sum of squares | 6 | 292,890,231,899 | assembly chapter, ordinary-value relation |
| integers | sum of squares | 1 | 292,890,231,904 | this chapter (zero projection) and assembly |
Cross-check against the saved specification
The manuscript ships its specification as a saved expression with the same 23 templates and seven recipes. It is not an input to the proof; an external comparison checks that the construction of this chapter reproduces it:
- the fixed-constant expressions are compared as expression trees, and the two decimal literals with the primorial values;
- each template is compared by parameter count, variable count and witness blocks exactly, and by its polynomial through a randomized identity test: both node lists are evaluated modulo a large prime at random points, with each constructor node replaced by a random function of its index expression and argument values, shared by both sides;
- the recipes are compared record by record: generator indices, source variable rows, constant definitions, operations, root equality, composition calls and fresh ranges.
The comparison uses a small sample of points per template and never expands a constructor.
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.