Formulas, gadgets and witness scope
Templates are generated from formulas: equality is a difference, conjunction a sum of squares, disjunction a product, and rational constants are fresh variables tied by global equations. The node encoding of a constructed template denotes the compiled formula, and every construction keeps its private blocks apart.
DefinitionFormulas and their polynomial compilation#✓
Formulas. A formula over \(\mathbb Z[X_i:i\in\mathbb N]\) is built from atoms \(a\doteq b\) (\(a,b\) polynomials), \(\langle f\rangle\) (\(f\) a polynomial) and call atoms \(\langle\tau[g;w]\rangle\) (\(\tau\) an existential polynomial with \(p\) parameters and \(m\) witnesses, \(g\) a \(p\)-tuple of polynomials, \(w\in\mathbb N\) the witness start) by the connectives \(\bigwedge(\varphi_1,\dots,\varphi_k)\) and \(\bigvee(\varphi_1,\dots,\varphi_k)\), \(k\ge0\). A formula holds at \(x:\mathbb N\to\mathbb Q\) when its atoms are read as \(a(x)=b(x)\), \(f(x)=0\) and \(\tau[g;w](x)=0\) and the connectives as conjunction and disjunction (the empty conjunction is true, the empty disjunction false). Its compilation \(\kappa\) is $\(\kappa(a\doteq b)=a-b,\quad \kappa(\langle f\rangle)=f,\quad \kappa(\langle\tau[g;w]\rangle)=\tau[g;w],\quad \kappa\Bigl(\bigwedge_i\varphi_i\Bigr)=\sum_i\kappa(\varphi_i)^2,\quad \kappa\Bigl(\bigvee_i\varphi_i\Bigr)=\prod_i\kappa(\varphi_i),\)$ with empty sum \(0\) and empty product \(1\). A conjunction nested inside a conjunction is squared twice; no flattening takes place. The call atom \(\langle\tau[g;w]\rangle\) owns the block \([w,w+m)\).
Template constructions. A construction of a template with \(p\) parameters keeps a counter \(c\), initially \(p\), and a list of global equations, initially empty; the parameters are \(X_0,\dots,X_{p-1}\). It may:
- take a fresh variable \(X_c\) and increase \(c\) by one;
- call an existential polynomial \(\tau\) with \(m\) witnesses on parameter polynomials \(g\): this takes the block \(X_c,\dots,X_{c+m-1}\), increases \(c\) by \(m\) and yields the call atom \(\langle\tau[g;c]\rangle\) (a block of length zero takes no variable);
- request a rational constant \(u/q\) (the pair \((u,q)\) normalized only by the sign of \(q\)): an integer constant (\(q=1\)) is the polynomial \(u\); otherwise the first request takes a fresh variable \(X_c\) and records the global equation \(q\,X_c\doteq u\), and later requests of the same normalized pair return the same variable.
If the construction ends with formula \(\varphi\), recorded global equations \(E_1,\dots,E_r\) (in order of creation) and counter \(v\), the template has \(p\) parameters, \(v-p\) witnesses and polynomial $\(\kappa\bigl(\textstyle\bigwedge(E_1,\dots,E_r,\varphi)\bigr)=\sum_{i=1}^r\kappa(E_i)^2+\kappa(\varphi)^2 .\)$ In particular a template without rational constants has polynomial \(\kappa(\varphi)^2\).
Gadgets. \(\mathrm{NZ}(a)\) takes a fresh \(w\) and is the atom \(a\cdot w\doteq1\). \(\mathrm{POS}(a)\) takes fresh \(z_1,z_2,z_3,z_4\) and is the atom \(a\,(z_1^2+z_2^2+z_3^2+z_4^2)\doteq1\).
This is a definition. Every later template article describes its construction by listing its variables in allocation order and its formula; the order of the constructor's steps is the order in which the allocations occur.
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
noncomputable def compile : Formula → Poly
| .eq a b => a - b
| .atom f => f
| .call τ g w => τ.call g w
| .and fs => (fs.map fun φ => φ.compile ^ 2).sum
| .or fs => (fs.map fun φ => φ.compile).prod
def Holds (x : ℕ → ℚ) : Formula → Prop
| .eq a b => ev x a = ev x b
| .atom f => ev x f = 0
| .call τ g w => ev x (τ.call g w) = 0
| .and fs => ∀ φ, (_ : φ ∈ fs) → Holds x φ
| .or fs => ∃ φ, ∃ (_ : φ ∈ fs), Holds x φ
decreasing_by all_goals (have := List.sizeOf_lt_of_mem ‹_ ∈ fs›; simp; omega)
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
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
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
Uses 1 · Used by 28
TheoremTemplate construction from formulas#✓
Call a construction allocating if, run from any counter and list of global equations, it never decreases the counter and only appends global equations \(q\,X_c\doteq u\) whose variables \(c\) are newly allocated (at least the initial and below the final counter), in increasing order. Every fresh variable, call, rational constant and gadget is allocating, and so is every construction composed of them.
Let an allocating construction with \(p\) parameters end with formula \(\varphi\), global equations \(E_1,\dots,E_r\) and counter \(v\), and let \(\tau\) be its template. Then \(\tau\) has parameter count \(p\) and variable count \(v\), $\([\![\tau]\!]=\kappa\bigl(\textstyle\bigwedge(E_1,\dots,E_r,\varphi)\bigr),\)$ the variables \(c_1<\dots<c_r\) of \(E_1,\dots,E_r\) lie in \([p,v)\), and if every variable of \(\kappa(\varphi)\) has index below \(v\), so has every variable of \([\![\tau]\!]\).
Proof sketch. The polynomial and the counts are the definition of the template. Allocation is closed under sequencing: the counter of the second step starts where the first ended, so the equations appended by the first step lie below every equation appended by the second. A fresh variable or call only advances the counter; a rational constant either returns a constant or a recorded variable, or records the equation for the variable \(X_c\) it allocates. Run from \((p,[\,])\) this gives the ranges of the constant variables, and the polynomial of \(E_i\) has the single variable \(c_i<v\).
def Allocates {α : Type} (b : Build α) : Prop :=
∀ s : BuildState, s.next ≤ (b s).2.next ∧ ∃ l : List (ℕ × ℤ × ℤ),
(b s).2.globals = s.globals ++ l ∧ (l.map Prod.fst).Pairwise (· < ·) ∧
∀ e ∈ l, s.next ≤ e.1 ∧ e.1 < (b s).2.next
theorem bind {b : Build α} {f : α → Build β} (hb : Allocates b) (hf : ∀ a, Allocates (f a)) :
Allocates (b >>= f)
theorem Build.template_construction (p : ℕ) {b : Build Formula} (hb : b.Allocates) :
(Build.template p b).params = p ∧
(Build.template p b).varCount = (b ⟨p, []⟩).2.next ∧
(Build.template p b).poly = (Build.fullFormula p b).compile ∧
((b ⟨p, []⟩).2.globals.map Prod.fst).Pairwise (· < ·) ∧
(∀ e ∈ (b ⟨p, []⟩).2.globals, p ≤ e.1 ∧ e.1 < (b ⟨p, []⟩).2.next) ∧
(VarsLT (b ⟨p, []⟩).1.compile (b ⟨p, []⟩).2.next → (Build.template p b).WF)
def Build (α : Type) : Type := BuildState → α × BuildState
ZInQKernel/Syntax/Language/Build.lean:34
structure BuildState where
/-- The next free variable. -/
next : ℕ
/-- The global equations of the rational constants. -/
globals : List (ℕ × ℤ × ℤ)
ZInQKernel/Syntax/Language/Build.lean:27
def Allocates {α : Type} (b : Build α) : Prop :=
∀ s : BuildState, s.next ≤ (b s).2.next ∧ ∃ l : List (ℕ × ℤ × ℤ),
(b s).2.globals = s.globals ++ l ∧ (l.map Prod.fst).Pairwise (· < ·) ∧
∀ e ∈ l, s.next ≤ e.1 ∧ e.1 < (b s).2.next
ZInQKernel/Syntax/Builder/Construction.lean:35
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
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 Build.fullFormula (p : ℕ) (b : Build Formula) : Formula :=
.and ((b ⟨p, []⟩).2.globals.map globalEq ++ [(b ⟨p, []⟩).1])
ZInQKernel/Syntax/Templates/Scope.lean:645
def VarsLT (f : Poly) (n : ℕ) : Prop := VarsIn f (· < n)
ZInQKernel/Syntax/Language/Basic.lean:125
Uses 2 · Used by 10 · Informal links 1
DefinitionSemantics of templates and recipes#✓
Polynomials live in \(\mathbb Z[X_i : i\in\mathbb N]\) and every variable ranges over \(\mathbb Q\). A rational assignment is a map \(x:\mathbb N\to\mathbb Q\), and \(f(x)\) is the value of \(f\) at it.
Scalar nodes. A node list \(n_0,\dots,n_{k-1}\) is a finite list in which every node refers only to earlier nodes. A node is one of:
- \(\mathrm{const}\ c\) with \(c\in\mathbb Z\);
- \(\mathrm{var}\ i\) with \(i\in\mathbb N\) a local variable;
- \(\mathrm{add}\ j\ j'\) or \(\mathrm{mul}\ j\ j'\) with \(j,j'\) earlier nodes;
- \(\mathrm{call}\ \tau\ (a_0,\dots,a_{p-1})\ w\): a call of an earlier template \(\tau\) with \(p\) parameters, parameter nodes \(a_i\) and witness start \(w\in\mathbb N\);
- \(\mathrm{fixed}\ e\) with \(e\) a fixed integer expression;
- \(\mathrm{psi}\ e\ (a_0,a_1,a_2,a_3)\ c\) with \(e\) a fixed integer expression and \(c\in\{0,1\}\);
- \(\mathrm{guard}\ e\ (a_1,\dots,a_{15})\) with \(e\) a fixed integer expression and fifteen coordinate nodes in point-major order.
Templates. A template \(\tau=(p,v,n_0,\dots,n_{k-1},\mathrm{root})\) has parameter count \(p\le v\) and variable count \(v\); its local variables \(0,\dots,p-1\) are parameters and \(p,\dots,v-1\) are its \(m=v-p\) witnesses. Node values are polynomials: \([\![\mathrm{const}\ c]\!]=c\), \([\![\mathrm{var}\ i]\!]=X_i\), \([\![\mathrm{add}\ j\ j']\!]=[\![n_j]\!]+[\![n_{j'}]\!]\), \([\![\mathrm{mul}\ j\ j']\!]=[\![n_j]\!][\![n_{j'}]\!]\), \([\![\mathrm{fixed}\ e]\!]\) is the constant \(\mathrm{val}(e)\), \([\![\mathrm{psi}\ e\ a\ c]\!]=\Psi_{\mathrm{val}(e),c}([\![n_{a_0}]\!],\dots,[\![n_{a_3}]\!])\), \([\![\mathrm{guard}\ e\ a]\!]=G_{\mathrm{val}(e)}([\![n_{a_1}]\!],\dots,[\![n_{a_{15}}]\!])\) and \([\![\mathrm{call}\ \tau'\ a\ w]\!]=\tau'[[\![n_{a_0}]\!],\dots,[\![n_{a_{p'-1}}]\!];w]\). The polynomial of \(\tau\) is \([\![\tau]\!]=[\![n_{\mathrm{root}}]\!]\).
Calls. For a template or recipe \(\tau\) with \(p\) parameters, polynomials \(g_0,\dots,g_{p-1}\) and \(w\in\mathbb N\), the call \(\tau[g_0,\dots,g_{p-1};w]\) is the image of \([\![\tau]\!]\) under the ring homomorphism with \(X_i\mapsto g_i\) for \(i<p\) and \(X_i\mapsto X_{w+i-p}\) for \(i\ge p\). Thus witness \(p+j\) of the callee becomes the caller's variable \(X_{w+j}\).
Relations. For \(a\in\mathbb Q^p\), \(\mathrm{Rel}_\tau(a)\) holds when there are \(y_0,\dots,y_{m-1}\in\mathbb Q\) with \([\![\tau]\!]\,(a_0,\dots,a_{p-1},y_0,\dots,y_{m-1})=0\) (variables of index at least \(v\) set to \(0\)).
Recipes. A recipe \(\rho\) has parameter count \(p\), variable count \(v\) and a list of constraint polynomials \(c_1,\dots,c_k\); its polynomial is \([\![\rho]\!]=\sum_i c_i^2\) for a sum-of-squares recipe or a model-evaluation recipe and \([\![\rho]\!]=\prod_i c_i\) for a product recipe (empty sum \(0\), empty product \(1\)). Calls and relations of recipes are as for templates.
- A composition recipe lists calls \((\kappa_i,(j_{i,0},\dots,j_{i,p_i-1}),w_i)\), where \(\kappa_i\) is a template or an earlier recipe with \(p_i\) parameters; its constraints are \(c_i=\kappa_i[X_{j_{i,0}},\dots,X_{j_{i,p_i-1}};w_i]\). It also records ranges of fresh variables, which add no constraint.
- A model-evaluation recipe records generator indices \(g_0,g_1,g_2\), source variable rows \((r,s)\) with a point reference \(r\) and a natural start \(s\) or none, constant definitions \((\sigma,r,s)\) with a scalar template \(\sigma\), operations \((0,a,b,o,s)\), \((1,a,b,o,s)\) and \((2,a,b,c,o,s)\), and a root equality \((r,r')\), together with operation templates \(\nu\) (natural), \(\alpha\) (raw addition), \(\mu\) (multiplication) and possibly a power recipe \(\pi\). Writing \(\mathrm{ref}(r)\) for the five polynomials of a point reference and juxtaposing references for the concatenated coordinate lists, its constraints are, in this order: the three generator constraints \(8X_{g_0}-1641\), \(4X_{g_1}+15465\), \(32X_{g_2}-87483\); \(\nu[\mathrm{ref}(r);s]\) for each row with a natural start \(s\); \(\sigma[\mathrm{ref}(-2)\,\mathrm{ref}(r);s]\) for each constant definition; \(\alpha[\mathrm{ref}(a)\,\mathrm{ref}(b)\,\mathrm{ref}(o);s]\), \(\mu[\mathrm{ref}(a)\,\mathrm{ref}(b)\,\mathrm{ref}(o);s]\) and \(\pi[\mathrm{ref}(a)\,\mathrm{ref}(b)\,\mathrm{ref}(c)\,\mathrm{ref}(o);s]\) for the operations of kinds \(0\), \(1\) and \(2\); and the five differences \(\mathrm{ref}(r)_i-\mathrm{ref}(r')_i\).
The order of summands does not change the polynomial; the order listed follows the specification's description of model recipes. Source node numbers, source-node point lists, names, metadata and provenance strings carry no constraints.
This is a definition. The denotation of a node list is computed by one pass in stored order, keeping the polynomial of every node; a call refers to an earlier template, so the library is denoted in its stored order. The values \(\mathrm{val}(e)\), \(\Psi_{n,c}\) and \(G_T\) are used only as symbols in all later reasoning; in particular \(\mathrm{val}(e)\) is never evaluated for the astronomical constants.
noncomputable def Template.denote (I : Constructors E) (lib : List ExPoly) (t : Template E) :
ExPoly :=
⟨t.parameterCount, t.variableCount - t.parameterCount,
getPoly (denoteNodes I lib t.nodes) t.root⟩
noncomputable def Recipe.denote (templates recipes : List ExPoly) (ρ : Recipe) : ExPoly :=
⟨ρ.parameterCount, ρ.variableCount - ρ.parameterCount, ρ.poly templates recipes⟩
def Rel (τ : ExPoly) (a : Fin τ.params → ℚ) : Prop :=
∃ y : Fin τ.witnesses → ℚ, ev (assign τ.params τ.witnesses a y) τ.poly = 0
structure Constructors (E : Type) where
/-- The value `val(e)` of a fixed integer expression. -/
val : E → ℤ
/-- The component polynomial `Ψ_{n,c}` in the four variables `x₀, x₁, y₀, y₁`. -/
psi : ℤ → Fin 2 → MvPolynomial (Fin 4) ℤ
/-- The guard polynomial `G_T` in fifteen variables (point-major order). -/
guard : ℤ → MvPolynomial (Fin 15) ℤ
ZInQKernel/Syntax/Language/Nodes.lean:29
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
structure Template (E : Type) where
/-- The parameter count `p`. -/
parameterCount : ℕ
/-- The variable count `v ≥ p`. -/
variableCount : ℕ
/-- The node list. -/
nodes : List (Node E)
/-- The root node. -/
root : ℕ
ZInQKernel/Syntax/Language/Nodes.lean:57
noncomputable def getPoly (vals : List Poly) (j : ℕ) : Poly := vals.getD j 0
ZInQKernel/Syntax/Language/Nodes.lean:71
noncomputable def denoteNodes (I : Constructors E) (lib : List ExPoly) (nodes : List (Node E)) :
List Poly :=
nodes.foldl (fun vals n => vals ++ [n.denote I lib vals]) []
ZInQKernel/Syntax/Language/Nodes.lean:96
inductive Recipe
/-- A composition recipe. -/
| composition (r : CompositionRecipe)
/-- A model-evaluation recipe. -/
| model (r : ModelRecipe)
ZInQKernel/Syntax/Language/Nodes.lean:231
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
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 4 · Used by 21
TheoremSums of squares and products over the rationals#✓
For every formula \(\varphi\) and every \(x:\mathbb N\to\mathbb Q\), $\(\kappa(\varphi)(x)=0\iff\varphi\text{ holds at }x .\)$ In particular, for polynomials \(f_1,\dots,f_k\), \(\sum_i f_i(x)^2=0\iff f_1(x)=\dots=f_k(x)=0\) and \(\prod_i f_i(x)=0\iff f_i(x)=0\) for some \(i\).
Proof sketch. Induction on \(\varphi\). For an atom, \(\kappa(a\doteq b)(x)=a(x)-b(x)\). For a conjunction, each square is a nonnegative rational, so a finite sum of squares vanishes exactly when every square vanishes, and \(t^2=0\iff t=0\); the empty sum is \(0\) and the empty conjunction is true. For a disjunction, \(\mathbb Q\) has no zero divisors, so a finite product vanishes exactly when a factor does; the empty product is \(1\ne0\) and the empty disjunction is false.
theorem ev_compile_eq_zero_iff (φ : Formula) (x : ℕ → ℚ) : ev x φ.compile = 0 ↔ φ.Holds x
theorem ev_sum_sq_eq_zero_iff (x : ℕ → ℚ) (l : List Poly) :
ev x (l.map (· ^ 2)).sum = 0 ↔ ∀ f ∈ l, ev x f = 0
theorem ev_prod_eq_zero_iff (x : ℕ → ℚ) (l : List Poly) :
ev x l.prod = 0 ↔ ∃ f ∈ l, ev x f = 0
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
Uses 1 · Used by 16
DefinitionThe absolute-value template#✓
The template \(\mathtt{value.abs}\) has \(2\) parameters and \(4\) witnesses (\(6\) variables): \(x=X_0\), \(a=X_1\) and \(z_1,\dots,z_4=X_2,\dots,X_5\). Its formula is \(\bigwedge(a\doteq z_1^2+z_2^2+z_3^2+z_4^2,\ a^2\doteq x^2)\) and its polynomial is $\([\![\mathtt{value.abs}]\!]=\bigl((a-z_1^2-z_2^2-z_3^2-z_4^2)^2+(a^2-x^2)^2\bigr)^2 .\)$ By the absolute-value statement, \(\mathrm{Rel}_{\mathtt{value.abs}}(x,a)\iff a=|x|\).
This is a definition (template index \(14\)).
noncomputable def absTemplate : ExPoly := Build.template 2 (absBuild (X 0) (X 1))
theorem absTemplate_rel_iff (v : Fin 2 → ℚ) : absTemplate.Rel v ↔ v 1 = |v 0|
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 absBuild (x a : Poly) : Build Formula := do
let z1 ← Build.fresh
let z2 ← Build.fresh
let z3 ← Build.fresh
let z4 ← Build.fresh
pure (.and [.eq a (z1 ^ 2 + z2 ^ 2 + z3 ^ 2 + z4 ^ 2), .eq (a ^ 2) (x ^ 2)])
ZInQKernel/Syntax/Templates/Value.lean:22
noncomputable def absTemplate : ExPoly := Build.template 2 (absBuild (X 0) (X 1))
ZInQKernel/Syntax/Templates/Value.lean:30
Uses 1 · Used by 4
A call evaluates its callee at the parameter values and its private block. Disjoint private blocks can be moved to the front, and the block of an inactive branch may take any values.
TheoremEvaluation of a template call#✓
Let \(\tau\) be a template or recipe with \(p\) parameters, \(v\) variables and \(m=v-p\) witnesses, all of whose variables have index below \(v\). Let \(g_0,\dots,g_{p-1}\) be polynomials, \(w\in\mathbb N\) and \(x:\mathbb N\to\mathbb Q\). Then $\(\tau[g;w]\,(x)=[\![\tau]\!]\,(g_0(x),\dots,g_{p-1}(x),x_w,x_{w+1},\dots,x_{w+m-1}).\)$ Consequently, if none of the variables \(X_w,\dots,X_{w+m-1}\) occurs in any \(g_i\), then for every assignment \(x\) of the remaining variables $\(\bigl(\exists\,y_0,\dots,y_{m-1}\in\mathbb Q:\ \tau[g;w]\,(x[X_{w+j}\mapsto y_j])=0\bigr) \iff\mathrm{Rel}_\tau(g_0(x),\dots,g_{p-1}(x)).\)$
Proof sketch. Evaluation commutes with the substitution homomorphism: the value of \(\tau[g;w]\) at \(x\) is the value of \([\![\tau]\!]\) at the assignment \(i\mapsto g_i(x)\) for \(i<p\) and \(i\mapsto x_{w+i-p}\) for \(i\ge p\), and only \(i<v\) matters. If the block variables do not occur in the \(g_i\), changing \(x\) on the block leaves every \(g_i(x)\) unchanged, and the block values range over all of \(\mathbb Q^m\); this is the existential statement.
theorem ev_callPoly (P : Poly) (p w : ℕ) (g : Fin p → Poly) (x : ℕ → ℚ) :
ev x (callPoly P p w g) =
ev (fun i => if h : i < p then ev x (g ⟨i, h⟩) else x (w + (i - p))) P
theorem ExPoly.exists_blockUpdate_call_iff {τ : ExPoly} (hτ : τ.WF) (g : Fin τ.params → Poly)
(w : ℕ) (hg : ∀ k, ∀ i ∈ (g k).vars, i < w ∨ w + τ.witnesses ≤ i) (x : ℕ → ℚ) :
(∃ y : Fin τ.witnesses → ℚ, ev (blockUpdate x w τ.witnesses y) (τ.call g w) = 0) ↔
τ.Rel fun k => ev x (g k)
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
noncomputable def callPoly (P : Poly) (p w : ℕ) (g : Fin p → Poly) : Poly :=
bind₁ (callSubst p w g) P
ZInQKernel/Syntax/Language/Basic.lean:214
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
def blockUpdate (x : ℕ → ℚ) (w m : ℕ) (y : Fin m → ℚ) (i : ℕ) : ℚ :=
if h : w ≤ i ∧ i - w < m then y ⟨i - w, h.2⟩ else x i
ZInQKernel/Syntax/Language/Basic.lean:246
Uses 1 · Used by 8
TheoremPrivate witness blocks#✓
Let \(\varphi\) be a formula whose atoms of the form \(\langle\cdot\rangle\) are calls \(\langle\tau_i[g_i;w_i]\rangle\), \(i=1,\dots,k\), where \(\tau_i\) has \(p_i\) parameters, \(v_i\) variables, \(m_i=v_i-p_i\) witnesses and all its variables below \(v_i\). Put \(B_i=\{w_i,\dots,w_i+m_i-1\}\) and assume:
- the blocks \(B_1,\dots,B_k\) are pairwise disjoint;
- no variable of any \(B_i\) occurs in any parameter polynomial \(g_j\) or in any atom \(a\doteq b\) of \(\varphi\).
Let \(\varphi^\ast(x)\) be the statement obtained from \(\varphi\) by replacing each call atom by \(\mathrm{Rel}_{\tau_i}(g_i(x))\) and each atom \(a\doteq b\) by \(a(x)=b(x)\). Then for every \(x:\mathbb N\to\mathbb Q\), $\(\bigl(\exists\,y:\textstyle\bigcup_iB_i\to\mathbb Q,\ \ \kappa(\varphi)(x[y])=0\bigr)\iff\varphi^\ast(x),\)$ where \(x[y]\) agrees with \(y\) on \(\bigcup_iB_i\) and with \(x\) elsewhere; both sides depend only on \(x\) outside the blocks. In particular a conjunction of calls with disjoint blocks has a rational zero exactly when every callee relation holds, a product of calls has one exactly when some callee relation holds, and the block of an inactive factor may be given arbitrary values (for instance all zero). Variables occurring in no atom and no block may likewise take arbitrary values.
Proof sketch. By the compilation theorem the left side says that \(\varphi\) holds at \(x[y]\) for some \(y\). Induct on \(\varphi\), proving the statement for every \(x\). For an atom \(a\doteq b\) the value does not depend on \(y\). For a call atom this is the evaluation of a call. For a conjunction \(\bigwedge\varphi_j\) the blocks used by different conjuncts are disjoint, so witnesses \(y_j\) for the conjuncts glue to one \(y\) that restricts to each \(y_j\) on its own blocks; conversely a common \(y\) restricts to witnesses for each conjunct. For a disjunction, a witness for the true disjunct extends by arbitrary values (the rational domain is nonempty) to the blocks of the other disjuncts. Fixed equations inside an active callee are part of that callee's relation and are not discarded.
theorem exists_blocks_iff (φ : Formula) (hwf : ∀ τ ∈ φ.callees, τ.WF)
(hdisj : φ.blocks.Pairwise BlockDisjoint)
(hfree : ∀ f ∈ φ.freePolys, ∀ i ∈ f.vars, ¬ InBlocks φ.blocks i) (x : ℕ → ℚ) :
(∃ y : ℕ → ℚ, (∀ i, ¬ InBlocks φ.blocks i → y i = x i) ∧ ev y φ.compile = 0) ↔ φ.Lift x
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
def BlockDisjoint (b b' : ℕ × ℕ) : Prop := ∀ i, InBlock b i → ¬ InBlock b' i
ZInQKernel/Syntax/Language/Lifting.lean:24
def InBlocks (l : List (ℕ × ℕ)) (i : ℕ) : Prop := ∃ b ∈ l, InBlock b i
ZInQKernel/Syntax/Language/Lifting.lean:21
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
Uses 4 · Used by 10 · Informal links 1
Rational constants are fresh variables with global equations, which stay active outside every internal disjunction. Strict positivity and absolute value are expressed with four squares.
TheoremRational constants by global equations#✓
Let a template be constructed with formula \(\varphi\) and rational constants \(u_1/q_1,\dots,u_r/q_r\) (\(q_i\ge2\)) held in variables \(X_{c_1},\dots,X_{c_r}\), so that its polynomial is \(\kappa(\bigwedge(q_1X_{c_1}\doteq u_1,\dots,q_rX_{c_r}\doteq u_r,\varphi))\). Then for every \(x:\mathbb N\to\mathbb Q\) this polynomial vanishes at \(x\) exactly when \(x_{c_i}=u_i/q_i\) for every \(i\) and \(\varphi\) holds at \(x\). The equations are conjuncts of the whole template, outside every disjunction of \(\varphi\), so they constrain every branch.
For the cached coordinates of the generator, the three equations $\(8g_0=1641,\qquad 4g_1=-15465,\qquad 32g_2=87483\)$ hold exactly when \((g_0,g_1,g_2)=(1641/8,\,-15465/4,\,87483/32)\), and then \((0,g_0,-145,g_1,g_2)\) has \(x\)-coordinate \(1641/8-145s=(1641-1160s)/8\) and \(y\)-coordinate \(-15465/4+(87483/32)s=(-123720+87483s)/32\), the coordinates of \(P_0\).
Proof sketch. By the compilation theorem the polynomial vanishes exactly when every conjunct holds; \(q_ix_{c_i}=u_i\) with \(q_i\ne0\) means \(x_{c_i}=u_i/q_i\). The generator values are the arithmetic \(1641/8-145s=(1641-1160s)/8\) and \(-15465/4=-123720/32\).
theorem ev_globals_eq_zero_iff (eqs : List (ℕ × ℤ × ℤ)) (hq : ∀ e ∈ eqs, e.2.2 ≠ 0)
(φ : Formula) (x : ℕ → ℚ) :
ev x (Formula.and (eqs.map globalEq ++ [φ])).compile = 0 ↔
(∀ e ∈ eqs, x e.1 = e.2.1 / e.2.2) ∧ φ.Holds x
theorem generator_values (g0 g1 g2 : ℚ) :
(8 * g0 = 1641 ∧ 4 * g1 = -15465 ∧ 32 * g2 = 87483) ↔
(g0 = 1641 / 8 ∧ g1 = -15465 / 4 ∧ g2 = 87483 / 32)
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
noncomputable def globalEq (e : ℕ × ℤ × ℤ) : Formula := .eq (C e.2.2 * X e.1) (C e.2.1)
ZInQKernel/Syntax/Language/Build.lean:105
Uses 2 · Used by 3
TheoremStrict positivity by four squares#✓
For every \(s\in\mathbb Q\), $\(s>0\iff\exists\,z_1,z_2,z_3,z_4\in\mathbb Q,\quad s\,(z_1^2+z_2^2+z_3^2+z_4^2)=1 .\)$ Hence the gadget \(\mathrm{POS}(a)\) is satisfiable by a choice of its four fresh variables exactly when \(a>0\).
Proof sketch. If \(s>0\) write \(1/s=a/b\) with integers \(a,b>0\). By Lagrange's four-square theorem \(ab=n_1^2+n_2^2+n_3^2+n_4^2\) with \(n_i\in\mathbb Z\); put \(z_i=n_i/b\), so that \(\sum z_i^2=ab/b^2=1/s\). Conversely a sum of squares is nonnegative, so \(s\sum z_i^2=1\) forces \(\sum z_i^2>0\) and then \(s=1/\sum z_i^2>0\).
theorem pos_iff_four_squares (s : ℚ) :
0 < s ↔ ∃ z : Fin 4 → ℚ, s * (z 0 ^ 2 + z 1 ^ 2 + z 2 ^ 2 + z 3 ^ 2) = 1
theorem exists_blockUpdate_posFormula_iff (x : ℕ → ℚ) (a : Poly) {c : ℕ}
(hc : ∀ i ∈ a.vars, i < c ∨ c + 4 ≤ i) :
(∃ z : Fin 4 → ℚ, (posFormula a c).Holds (blockUpdate x c 4 z)) ↔ 0 < ev x a
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
noncomputable def posFormula (a : Poly) (c : ℕ) : Formula :=
.eq (a * (X c ^ 2 + X (c + 1) ^ 2 + X (c + 2) ^ 2 + X (c + 3) ^ 2)) 1
ZInQKernel/Syntax/Language/Build.lean:254
def blockUpdate (x : ℕ → ℚ) (w m : ℕ) (y : Fin m → ℚ) (i : ℕ) : ℚ :=
if h : w ≤ i ∧ i - w < m then y ⟨i - w, h.2⟩ else x i
ZInQKernel/Syntax/Language/Basic.lean:246
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
Uses 1 · Used by 1
TheoremAbsolute value by four squares#✓
For all \(a,x\in\mathbb Q\), $\(a=|x|\iff\exists\,z_1,z_2,z_3,z_4\in\mathbb Q,\quad a=z_1^2+z_2^2+z_3^2+z_4^2\ \text{ and }\ a^2=x^2 .\)$ Consequently, for the absolute-value template, \(\mathrm{Rel}_{\mathtt{value.abs}}(x,a)\iff a=|x|\) for all \(x,a\in\mathbb Q\).
Proof sketch. If \(a\) is a sum of squares then \(a\ge0\), and \(a^2=x^2\) gives \(a=\pm x\), hence \(a=|x|\). Conversely write \(|x|=u/v\) with \(u\ge0\), \(v>0\) integers; by Lagrange's theorem \(uv=\sum_i n_i^2\), so \(|x|=\sum_i(n_i/v)^2\), and \(|x|^2=x^2\). The manuscript states the equivalence without proof; the converse direction is the step supplied here. For the template, its polynomial is \(\kappa(\varphi)^2\) for the conjunction \(\varphi\) of the two equations, which by the compilation theorem vanishes at \((x,a,z_1,\dots,z_4)\) exactly when both equations hold; the four witnesses are the \(z_i\).
theorem eq_abs_iff_four_squares (a x : ℚ) :
a = |x| ↔ ∃ z : Fin 4 → ℚ, a = z 0 ^ 2 + z 1 ^ 2 + z 2 ^ 2 + z 3 ^ 2 ∧ a ^ 2 = x ^ 2
theorem absTemplate_rel_iff (v : Fin 2 → ℚ) : absTemplate.Rel v ↔ v 1 = |v 0|
noncomputable def absTemplate : ExPoly := Build.template 2 (absBuild (X 0) (X 1))
ZInQKernel/Syntax/Templates/Value.lean:30
Uses 4 · Used by 1
Elements of \(K_0\) are pairs of rationals and points of \(E\) are five-coordinate codes; the shared pair and point formulas are fixed once.
DefinitionQuadratic-field pairs and point-code formulas#✓
These are the formula-level abbreviations shared by the templates. Throughout, \(K_0=\mathbb Q(s)\) with \(s^2=2\).
Pairs. A pair is \(u=(u_0,u_1)\) of polynomials, standing for \(u_0+u_1s\). Define \(u+u'=(u_0+u_0',u_1+u_1')\), \(-u=(-u_0,-u_1)\), \(u-u'=u+(-u')\), \(k\,u=(ku_0,ku_1)\) for an integer or polynomial \(k\), $\(u\cdot u'=(u_0u_0'+2u_1u_1',\ u_0u_1'+u_1u_0'),\)$ \(u^2=u\cdot u\), \(u^{n}\) by repeated squaring, the conjugate \(\bar u=(u_0,-u_1)\) and the norm \(N(u)=u_0^2-2u_1^2\). Integer pairs are written \((a,b)\); \(1=(1,0)\). The curve coefficient is \(A=(-11243,7950)\), that is \(A=-d^2\) for \(d=75-53s\), and \(\delta=(11243,-7950)=d^2\).
Pair formulas. \(u\doteq u'\) is \(\bigwedge(u_0\doteq u_0',u_1\doteq u_1')\). \(\mathrm{NZ}_K(u)\) is \(\mathrm{NZ}(N(u))\) (one fresh variable). \(\mathrm{Div}(n,d)\) takes a fresh pair \(q\), then forms \(\bigwedge(\mathrm{NZ}_K(d),\ d\cdot q\doteq n)\); its value is \(q\).
Point codes. A point code is \(p=(p_0,\dots,p_4)\), with \(x(p)=(p_1,p_2)\) and \(y(p)=(p_3,p_4)\); a fresh point takes five fresh variables. Define \(O=(1,0,0,0,0)\), \(\mathrm{neg}(p)=(p_0,p_1,p_2,-p_3,-p_4)\), \(\mathrm{eq}(p,p')=\bigwedge_{i=0}^4(p_i\doteq p_i')\), \(\mathrm{isO}(p)=\mathrm{eq}(p,O)\), \(\mathrm{fin}(p)\) the atom \(p_0\doteq0\), and the curve atom pair \(\mathrm{curve}(X,Y)\): \(Y^2\doteq X^2\cdot X+A\cdot X\). The generator point of a template is \(G=(0,c_1,-145,c_2,c_3)\) with \(c_1,c_2,c_3\) the rational constants \(1641/8\), \(-15465/4\), \(87483/32\), requested in this order.
Local parameter and inverse abscissa. For a point \(p\) and a pair \(\zeta\), $\(Z(p,\zeta)=\bigvee\Bigl(\bigwedge(\mathrm{isO}(p),\ \zeta\doteq(0,0)),\ \ \bigwedge(\mathrm{fin}(p),\ \mathrm{NZ}_K(y(p)),\ y(p)\cdot\zeta\doteq-x(p))\Bigr)\)$ (one fresh variable) expresses \(\zeta=z(p)=-x/y\), with \(z(O)=0\). For a pair \(v\), $\(I\!X(p,v)=\bigvee\Bigl(\bigwedge(\mathrm{isO}(p),\ v\doteq(0,0)),\ \ \bigwedge(\mathrm{fin}(p),\ x(p)\cdot v\doteq(1,0))\Bigr)\)$ expresses \(v=1/x\), with value \(0\) at the identity.
This is a definition. In each template these abbreviations allocate their fresh variables at the moment they are formed, in the order written.
abbrev Pair : Type := Poly × Poly
noncomputable def Build.fdiv (n d : Pair) : Build (Pair × Formula) := do
let q0 ← Build.fresh
let q1 ← Build.fresh
let f ← Build.fnz d
pure ((q0, q1), .and [f, feq (d.mul (q0, q1)) n])
noncomputable def Build.zGadget (p : Code) (ζ : Pair) : Build Formula := do
let f ← Build.fnz p.y
pure (.or [.and [isO p, feq ζ Pair.zero], .and [fin p, f, feq (p.y.mul ζ) p.x.neg]])
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
abbrev Pair : Type := Poly × Poly
ZInQKernel/Syntax/Language/Pairs.lean:20
def Build (α : Type) : Type := BuildState → α × BuildState
ZInQKernel/Syntax/Language/Build.lean:34
inductive Formula
/-- The atom `a ≐ b`. -/
| eq (a b : Poly)
/-- The atom `⟨f⟩`, read as `f = 0`. -/
| atom (f : Poly)
/-- The call atom `⟨τ[g; w]⟩`. -/
| call (τ : ExPoly) (g : Fin τ.params → Poly) (w : ℕ)
/-- The conjunction `⋀ (φ_1, …, φ_k)`. -/
| and (fs : List Formula)
/-- The disjunction `⋁ (φ_1, …, φ_k)`. -/
| or (fs : List Formula)
ZInQKernel/Syntax/Language/Formula.lean:23
noncomputable def fresh : Build Poly := fun s => (X s.next, { s with next := s.next + 1 })
ZInQKernel/Syntax/Language/Build.lean:52
noncomputable def Build.fnz (u : Pair) : Build Formula := Build.nz u.norm
ZInQKernel/Syntax/Language/Pairs.lean:84
noncomputable def feq (u v : Pair) : Formula := .and [.eq u.1 v.1, .eq u.2 v.2]
ZInQKernel/Syntax/Language/Pairs.lean:81
abbrev Code : Type := Fin 5 → Poly
ZInQKernel/Syntax/Language/Pairs.lean:98
noncomputable def isO (p : Code) : Formula := peq p Code.O
ZInQKernel/Syntax/Language/Pairs.lean:116
noncomputable def zero : Pair := ofInt 0 0
ZInQKernel/Syntax/Language/Pairs.lean:49
noncomputable def fin (p : Code) : Formula := .eq (p 0) 0
ZInQKernel/Syntax/Language/Pairs.lean:119
Uses 1 · Used by 14
Model-evaluation recipes refer to points by references; the references \(-1,-2,-3\) are the codes of \(O\), \(P_0\) and \(-P_0\) once the generator constraints hold.
DefinitionPoint references#✓
In a model-evaluation recipe with generator variable indices \(g_0,g_1,g_2\), a point reference \(r\in\mathbb Z\) with \(r\ge-3\) stands for five polynomials: $\(\mathrm{ref}(r)=\begin{cases} (X_r,X_{r+1},X_{r+2},X_{r+3},X_{r+4}),& r\ge0,\\ (1,0,0,0,0),& r=-1,\\ (0,X_{g_0},-145,X_{g_1},X_{g_2}),& r=-2,\\ (0,X_{g_0},-145,-X_{g_1},-X_{g_2}),& r=-3. \end{cases}\)$ The generator constraints of the recipe are the three polynomials $\(8X_{g_0}-1641,\qquad 4X_{g_1}+15465,\qquad 32X_{g_2}-87483 .\)$ Every model-evaluation recipe conjoins them.
This is a definition.
noncomputable def pointRef (g : Fin 3 → ℕ) : ℤ → Fin 5 → Poly
| .ofNat r => fun i => X (r + i)
| .negSucc 0 => ![1, 0, 0, 0, 0]
| .negSucc 1 => ![0, X (g 0), -145, X (g 1), X (g 2)]
| .negSucc 2 => ![0, X (g 0), -145, -X (g 1), -X (g 2)]
| .negSucc (_ + 3) => fun _ => 0
noncomputable def generatorConstraints (g : Fin 3 → ℕ) : List Poly :=
[8 * X (g 0) - 1641, 4 * X (g 1) + 15465, 32 * X (g 2) - 87483]
abbrev Poly : Type := MvPolynomial ℕ ℤ
ZInQKernel/Syntax/Language/Basic.lean:25
TheoremValues of the point references#✓
Let \(x:\mathbb N\to\mathbb Q\) satisfy the three generator constraints of a model-evaluation recipe, \(8x_{g_0}=1641\), \(4x_{g_1}=-15465\) and \(32x_{g_2}=87483\). Then $\(\mathrm{ref}(-1)(x)=\iota(0),\qquad\mathrm{ref}(-2)(x)=\iota(1),\qquad\mathrm{ref}(-3)(x)=\iota(-1),\)$ that is, the codes of \(O\), \(P_0\) and \(-P_0\). Explicitly \(\iota(1)=(0,\ 1641/8,\ -145,\ -15465/4,\ 87483/32)\) and \(\iota(-1)=(0,\ 1641/8,\ -145,\ 15465/4,\ -87483/32)\).
Proof sketch. The constraints give \(x_{g_0}=1641/8\), \(x_{g_1}=-15465/4\), \(x_{g_2}=87483/32\). The code of \(P_0=((1641-1160s)/8,(-123720+87483s)/32)\) is \((0,1641/8,-145,-15465/4,87483/32)\) because \(1160/8=145\) and \(123720/32=15465/4\); the code of \(-P_0=(x,-y)\) negates the last two coordinates; the identity has code \((1,0,0,0,0)\).
theorem pointRef_eval_generator (g : Fin 3 → ℕ) (x : ℕ → ℚ)
(h : ∀ c ∈ generatorConstraints g, ev x c = 0) :
evCode x (pointRef g (-1)) = ![1, 0, 0, 0, 0] ∧ evCode x (pointRef g (-2)) = codeP0 ∧
evCode x (pointRef g (-3)) = codeNegP0
theorem generatorConstraints_eq_zero_iff (g : Fin 3 → ℕ) (x : ℕ → ℚ) :
(∀ c ∈ generatorConstraints g, ev x c = 0) ↔
x (g 0) = 1641 / 8 ∧ x (g 1) = -15465 / 4 ∧ x (g 2) = 87483 / 32
noncomputable def generatorConstraints (g : Fin 3 → ℕ) : List Poly :=
[8 * X (g 0) - 1641, 4 * X (g 1) + 15465, 32 * X (g 2) - 87483]
ZInQKernel/Syntax/Language/PointRef.lean:43
noncomputable def ev (x : ℕ → ℚ) : Poly →+* ℚ := eval₂Hom (Int.castRingHom ℚ) x
ZInQKernel/Syntax/Language/Basic.lean:30
noncomputable def evCode (x : ℕ → ℚ) (p : Fin 5 → Poly) : Fin 5 → ℚ := fun i => ev x (p i)
ZInQKernel/Syntax/Language/PointRef.lean:47
noncomputable def pointRef (g : Fin 3 → ℕ) : ℤ → Fin 5 → Poly
| .ofNat r => fun i => X (r + i)
| .negSucc 0 => ![1, 0, 0, 0, 0]
| .negSucc 1 => ![0, X (g 0), -145, X (g 1), X (g 2)]
| .negSucc 2 => ![0, X (g 0), -145, -X (g 1), -X (g 2)]
| .negSucc (_ + 3) => fun _ => 0
ZInQKernel/Syntax/Language/PointRef.lean:21
def codeP0 : Fin 5 → ℚ := ![0, 1641 / 8, -145, -15465 / 4, 87483 / 32]
ZInQKernel/Syntax/Language/PointRef.lean:50
def codeNegP0 : Fin 5 → ℚ := ![0, 1641 / 8, -145, 15465 / 4, -87483 / 32]
ZInQKernel/Syntax/Language/PointRef.lean:53
Uses 2 · Used by 3
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.