Translation to rational point codes
The natural precision polynomial speaks about natural numbers; the target polynomial has rational witnesses. This chapter translates every natural-number constraint into rational point-code constraints and proves that the translation is exact: natural variables become codes typed by the natural-code predicate, additions become raw additions, multiplications become multiplication templates, constants become fixed-scalar templates, power calls become calls of the power-value recipe, and the root becomes one equality of codes. This page follows Section 10.4; the interpreter, the lowering, the wrapper and the five-input specialization of Section 10.3 are in the natural chapter, whose equation (C.4) is the input here.
Throughout, \(\iota(n)\) is the code of \([n]P_0\), \(\mathrm{Rel}_\tau\) is the rational relation of a template or recipe, and the multiplication statement M is used in its all-input form: \(\mathrm{Rel}_{\mathtt{multiply}}(p,q,r)\) holds exactly when \(p=\iota(a)\), \(q=\iota(b)\) and \(r=\iota(ab)\) for some integers \(a,b\). The multiplication chapter proves M from the six-contact estimate, pole completeness and the twenty-two-prime pattern; the statements below assume M explicitly. The Mordell–Weil theorem, used through the generator certificate, is proved by the two-isogeny descent and is not a hypothesis.
The typing order and the natural predicate
The typing order does not depend on the natural predicate. Membership forces a canonical code in \(D=2E(K_0)\), raw addition on two canonical inputs forces their canonical sum, the fixed scalar templates give \([m]Q\) on \(D\), and inside \(\mathtt{multiply}\) the three root memberships are forced conjuncts of the height certificate, so every raw addition of the certificate receives canonical codes. Only once multiplication is typed on all rational inputs do the four square products and three additions of \(\mathtt{natural}\) make sense: its four untyped square roots are typed by the multiplication calls before their squares are added, and Lagrange's theorem gives exactly the codes of the natural numbers. This needs the completeness half of M. The outputs of these additions are canonical by the raw-addition contract, so no separate membership of the output is needed. The signed-encoding and exceptional templates of the assembly chapter start their addition chains at such a natural code, at the literal origin or at the fixed signed generator; the fixed generator equations are conjuncts outside the internal products of the templates that use them, and an inactive product branch is never assumed true.
TheoremLagrange's four-square theorem#✓
For every natural number \(n\) there are natural numbers \(a_0,a_1,a_2,a_3\) with $\(n=a_0^2+a_1^2+a_2^2+a_3^2 .\)$
Proof sketch. Classical. By Euler's four-square identity the set of sums of four integer squares is closed under multiplication, so it suffices to treat primes; \(2=1+1+0+0\). For an odd prime \(p\) the \((p+1)/2\) values \(x^2\) and the \((p+1)/2\) values \(-1-y^2\) modulo \(p\) cannot be pairwise distinct, so \(x^2+y^2+1\equiv0\pmod p\) for some \(x,y\); hence some multiple \(mp\) with \(1\le m<p\) is a sum of four squares, and the least such \(m\) is \(1\) by Euler's descent. Replacing each integer \(a_i\) by \(|a_i|\) gives natural numbers.
theorem four_squares (n : ℕ) : ∃ a₀ a₁ a₂ a₃ : ℕ, n = a₀ ^ 2 + a₁ ^ 2 + a₂ ^ 2 + a₃ ^ 2
Used by 1
Natural circuits and their translation
A natural circuit has explicit variables, constant, variable, addition and multiplication nodes, and call nodes that substitute the power template with a private block of seventy-nine natural witnesses. Its value at an integer assignment is computed node by node; a call contributes the value of the power template, which is not required to vanish.
DefinitionValues and polynomial of a natural circuit#✓
Let \(\mathcal N\) be a natural circuit with \(k\) inputs, in the format of the model-evaluation translation, and let \(\mathcal P\) be a natural circuit with \(3\) inputs and no call nodes (the power template). Write \(V_{\mathcal P}\) for the number of variables of \(\mathcal P\) (\(V_{\mathcal P}=82\) for the power template, so its call blocks have \(79\) variables).
Values of the power template. For \(y:\mathbb N\to\mathbb Z\) the value \(\mathrm{val}^{\mathcal P}_y(j)\) of node \(j\) of \(\mathcal P\) is defined in node order by \(\mathrm{val}(\mathrm{const}\ c)=c\), \(\mathrm{val}(\mathrm{var}\ i)=y_i\), \(\mathrm{val}(\mathrm{add}\ j\ j')=\mathrm{val}(j)+\mathrm{val}(j')\) and \(\mathrm{val}(\mathrm{mul}\ j\ j')=\mathrm{val}(j)\,\mathrm{val}(j')\). Put $\(T_{\mathcal P}(y_0,\dots,y_{V_{\mathcal P}-1})=\mathrm{val}^{\mathcal P}_y(\mathrm{root}_{\mathcal P}).\)$
Values of the circuit. For \(\theta:\mathbb N\to\mathbb Z\) the value \(\mathrm{val}_\theta(j)\) of node \(j\) of \(\mathcal N\) is defined in node order by the same four rules and, for a call node \(\mathrm{call}\ (a,b,c)\ w\), $\(\mathrm{val}_\theta(\mathrm{call}\ (a,b,c)\ w)=T_{\mathcal P}\bigl(\mathrm{val}_\theta(a),\mathrm{val}_\theta(b),\mathrm{val}_\theta(c),\theta_w,\theta_{w+1},\dots,\theta_{w+V_{\mathcal P}-4}\bigr).\)$ The value of the circuit is \(\mathcal N(\theta)=\mathrm{val}_\theta(\mathrm{root})\).
Polynomial. \([\![\mathcal N]\!]\) is the polynomial of the natural circuit defined in the natural chapter: the same recursion with polynomial operations, a call node denoting the substitution of the argument polynomials and the block variables \(X_{w+i}\) into the polynomial of \(\mathcal P\). Since evaluation commutes with substitution, \(\mathcal N(\theta)=[\![\mathcal N]\!](\theta)\) for every \(\theta\). For the natural precision circuit, \([\![\mathcal N]\!]\) is the natural precision polynomial \(C\) of equation (C.4); its variables are \(X_0,\dots,X_{1305810}\) and \(X_0,\dots,X_4\) are the inputs.
Admissible assignments. \(\theta\) is admissible for \(\mathcal N\) when \(\theta_v\in\mathbb N\) for every explicit variable \(v\) of kind witness and for every variable \(v\) of the block \([w,w+V_{\mathcal P}-3)\) of every call node. Inputs are not constrained by admissibility.
A call node contributes the value of the power template at its arguments and its block; it does not assert that this value vanishes. This is a definition.
def nodeVal (P N : NatCircuit) (θ : ℕ → ℤ) (j : ℕ) : ℤ := (nodeVals P N θ).getD j 0
def circuitValue (P N : NatCircuit) (θ : ℕ → ℤ) : ℤ := nodeVal P N θ N.root
def templateValue (P : NatCircuit) (y : ℕ → ℤ) : ℤ :=
(nodeValues (fun _ _ _ _ => 0) y P.nodes).getD P.root 0
structure NatCircuit where
/-- The number `k` of inputs. -/
inputCount : ℕ
/-- The explicit variables (index and kind), the inputs first. -/
explicitVars : List (ℕ × VarKind)
/-- The node list. -/
nodes : List NatNode
/-- The root node. -/
root : ℕ
/-- The variable count `V`. -/
varCount : ℕ
ZInQKernel/Compiler/Circuits/Circuit.lean:33
def nodeVals (P N : NatCircuit) (θ : ℕ → ℤ) : List ℤ := nodeValues (callValue P θ) θ N.nodes
ZInQKernel/Compiler/Translation/Values.lean:60
def nodeVal (P N : NatCircuit) (θ : ℕ → ℤ) (j : ℕ) : ℤ := (nodeVals P N θ).getD j 0
ZInQKernel/Compiler/Translation/Values.lean:63
def nodeValues (callVal : ℤ → ℤ → ℤ → ℕ → ℤ) (θ : ℕ → ℤ) (nodes : List NatNode) : List ℤ :=
nodes.foldl (fun vals n => vals ++ [nodeValue callVal θ vals n]) []
ZInQKernel/Compiler/Translation/Values.lean:43
Uses 2 · Used by 6
DefinitionWell-formed natural circuits#✓
A natural circuit \(\mathcal N\) with \(k\) inputs, explicit variables \((i_0,\kappa_0),(i_1,\kappa_1),\dots\), nodes \(n_0,\dots,n_{K-1}\), root \(\rho\) and (if it has call nodes) power template \(\mathcal P\) with \(V_{\mathcal P}\) variables is well-formed with bound \(V\) when:
- the explicit variable indices are pairwise distinct, the first \(k\) entries are the inputs with indices \(0,\dots,k-1\), and no later entry is an input;
- every argument of an \(\mathrm{add}\), \(\mathrm{mul}\) or \(\mathrm{call}\) node \(n_j\) is a node index below \(j\), and \(\rho<K\);
- every \(\mathrm{var}\ i\) node refers to an explicit variable \(i\);
- every \(\mathrm{const}\ c\) node with \(c\notin\{0,1,-1\}\) has \(c\ge2\);
- the blocks \([w,w+V_{\mathcal P}-3)\) of distinct call nodes are pairwise disjoint and disjoint from the set of explicit variable indices;
- every explicit variable index and every block variable is below \(V\);
- if \(\mathcal N\) has a call node, \(\mathcal P\) has \(3\) inputs, no call nodes, and is itself well-formed with bound \(V_{\mathcal P}\), its explicit variables being \(0,\dots,V_{\mathcal P}-1\).
Condition 3 says that the parent never reads a private coordinate of a call directly; condition 4 is what the fixed-scalar templates need, since a nontrivial constant \(c\) is produced as \([c]P_0\). Under conditions 2, 3, 5 and 7, \(\mathrm{val}_\theta(j)\) depends only on the values of \(\theta\) at the explicit variables and at the blocks of the call nodes among the ancestors of \(j\), and \([\![\mathcal N]\!]\) involves only variables below \(V\).
This is a definition (a decidable predicate on a finite circuit).
ZInQ.Translation.WellFormedCore · 26 lines
structure WellFormedCore (N : NatCircuit) (m V : ℕ) : Prop where
/-- The explicit variable indices are pairwise distinct. -/
vars_nodup : (N.explicitVars.map Prod.fst).Nodup
/-- The first `k` explicit variables are the inputs `0, …, k-1`. -/
inputs_first : N.explicitVars.take N.inputCount =
(List.range N.inputCount).map fun i => (i, VarKind.input)
/-- There are at least `k` explicit variables. -/
inputs_le : N.inputCount ≤ N.explicitVars.length
/-- No later explicit variable is an input. -/
later_witness : ∀ v ∈ N.explicitVars.drop N.inputCount, v.2 = VarKind.witness
/-- Every argument of a node is an earlier node. -/
args_lt : NodesWF N.nodes
/-- The root is a node. -/
root_lt : N.root < N.nodes.length
/-- Every variable node refers to an explicit variable. -/
var_explicit : ∀ i, NatNode.var i ∈ N.nodes → ∃ v ∈ N.explicitVars, v.1 = i
/-- Every nontrivial constant is at least `2`. -/
const_ge_two : ∀ c, NatNode.const c ∈ N.nodes → c ≠ 0 → c ≠ 1 → c ≠ -1 → 2 ≤ c
/-- The blocks of distinct call nodes are pairwise disjoint. -/
blocks_disjoint : N.blocks.Pairwise fun w w' => BlockDisjoint (w, m) (w', m)
/-- The blocks avoid the explicit variables. -/
blocks_explicit : ∀ w ∈ N.blocks, ∀ v ∈ N.explicitVars, ¬ InBlock (w, m) v.1
/-- The explicit variables are below `V`. -/
vars_lt : ∀ v ∈ N.explicitVars, v.1 < V
/-- The block variables are below `V`. -/
blocks_lt : ∀ w ∈ N.blocks, ∀ i, InBlock (w, m) i → i < V
structure WellFormed (P N : NatCircuit) (V : ℕ) : Prop where
/-- Conditions 1–6, with call blocks of length `V_𝒫 - 3`. -/
core : WellFormedCore N (P.varCount - 3) V
/-- Condition 7. -/
power : HasCall N → P.inputCount = 3 ∧ (∀ a b c w, NatNode.call a b c w ∉ P.nodes) ∧
WellFormedCore P 0 P.varCount ∧ P.explicitVars.map Prod.fst = List.range P.varCount
structure NatCircuit where
/-- The number `k` of inputs. -/
inputCount : ℕ
/-- The explicit variables (index and kind), the inputs first. -/
explicitVars : List (ℕ × VarKind)
/-- The node list. -/
nodes : List NatNode
/-- The root node. -/
root : ℕ
/-- The variable count `V`. -/
varCount : ℕ
ZInQKernel/Compiler/Circuits/Circuit.lean:33
inductive VarKind
| input
| witness
deriving DecidableEq, Repr
ZInQKernel/Compiler/Circuits/Construction.lean:52
def NodesWF (l : List NatNode) : Prop := ∀ j (hj : j < l.length), ∀ i ∈ l[j].children, i < j
ZInQKernel/Compiler/Circuits/Builder.lean:31
inductive NatNode
| const (c : ℤ)
| var (i : ℕ)
| add (j k : ℕ)
| mul (j k : ℕ)
| call (a b c w : ℕ)
deriving DecidableEq, Repr
ZInQKernel/Compiler/Circuits/Construction.lean:43
def BlockDisjoint (b b' : ℕ × ℕ) : Prop := ∀ i, InBlock b i → ¬ InBlock b' i
ZInQKernel/Syntax/Language/Lifting.lean:24
def InBlock (b : ℕ × ℕ) (i : ℕ) : Prop := b.1 ≤ i ∧ i < b.1 + b.2
ZInQKernel/Syntax/Language/Lifting.lean:18
structure WellFormedCore (N : NatCircuit) (m V : ℕ) : Prop where
/-- The explicit variable indices are pairwise distinct. -/
vars_nodup : (N.explicitVars.map Prod.fst).Nodup
/-- The first `k` explicit variables are the inputs `0, …, k-1`. -/
inputs_first : N.explicitVars.take N.inputCount =
(List.range N.inputCount).map fun i => (i, VarKind.input)
/-- There are at least `k` explicit variables. -/
inputs_le : N.inputCount ≤ N.explicitVars.length
/-- No later explicit variable is an input. -/
later_witness : ∀ v ∈ N.explicitVars.drop N.inputCount, v.2 = VarKind.witness
/-- Every argument of a node is an earlier node. -/
args_lt : NodesWF N.nodes
⋯
ZInQKernel/Compiler/Translation/WellFormed.lean:36
def HasCall (N : NatCircuit) : Prop := ∃ a b c w, NatNode.call a b c w ∈ N.nodes
ZInQKernel/Compiler/Translation/WellFormed.lean:64
A model-evaluation recipe is a sum of squares of calls with pairwise disjoint private blocks, so its rational relation unfolds into a conjunction of template relations on point references, together with the generator equations and the root equality.
TheoremRelational form of a model-evaluation recipe#✓
Let \(\rho\) be the model-evaluation recipe obtained by translating a natural circuit with \(k\) inputs that is well-formed with some bound, in value or zero mode, with or without natural constraints on the inputs and with an optional well-formed power recipe \(\pi\) (present when the circuit has call nodes), and let \(p\) be its parameter count (\(5k\) or \(5(k+1)\)). The table of nontrivial constants of the translation is a prefix of \((4,2,3,c_3,1399)\) that contains the constants of the circuit. Call the variables of \(\rho\) that are neither parameters nor in a private block of one of its calls its free witnesses: the generator variables \(g_0,g_1,g_2\), the fresh points of the explicit witness variables and the fresh points of the constant, addition, multiplication and call nodes. For \(a\in\mathbb Q^p\), \(\mathrm{Rel}_\rho(a)\) holds if and only if there is an assignment \(x:\mathbb N\to\mathbb Q\) with \(x_i=a_i\) for \(i<p\) such that:
- \(8x_{g_0}=1641\), \(4x_{g_1}=-15465\), \(32x_{g_2}=87483\);
- \(\mathrm{Rel}_{\mathtt{natural}}(\mathrm{ref}(r)(x))\) for every source-variable row \((i,r,s)\) with a natural start \(s\);
- \(\mathrm{Rel}_{S_h}(\mathrm{ref}(-2)(x),\mathrm{ref}(r)(x))\) for every constant definition \((S_h,r,s)\);
- \(\mathrm{Add}_{\rm raw}(\mathrm{ref}(a)(x),\mathrm{ref}(b)(x),\mathrm{ref}(o)(x))\), \(\mathrm{Rel}_{\mathtt{multiply}}(\mathrm{ref}(a)(x),\mathrm{ref}(b)(x),\mathrm{ref}(o)(x))\) and \(\mathrm{Rel}_\pi(\mathrm{ref}(a)(x),\mathrm{ref}(b)(x),\mathrm{ref}(c)(x),\mathrm{ref}(o)(x))\) for the operations \((0,a,b,o,s)\), \((1,a,b,o,s)\) and \((2,a,b,c,o,s)\) respectively;
- \(\mathrm{ref}(r)(x)=\mathrm{ref}(r')(x)\) for the root equality \((r,r')\).
Under condition 1, \(\mathrm{ref}(-1)(x)=\iota(0)\), \(\mathrm{ref}(-2)(x)=\iota(1)\) and \(\mathrm{ref}(-3)(x)=\iota(-1)\). Only the values of \(x\) at the parameters and the free witnesses matter.
Proof sketch. \([\![\rho]\!]\) is the sum of the squares of its constraint polynomials, so it vanishes at \(x\) exactly when every constraint does. By the witness-scope theorem the private blocks of the calls of \(\rho\) are pairwise disjoint, disjoint from the parameters and free witnesses, and no block variable occurs in a point reference or in another constraint. Hence the existential over the witnesses of \(\rho\) splits into an existential over the free witnesses and, for each call, one over its own block; by the evaluation of a call, the latter is the callee relation at the evaluated parameter points. The generator constraints and root differences contain no block variable. The values of the three negative references are the point-reference lemma.
theorem translate_rel_iff (hwf : WellFormed P N V) (hcons : consts <+: integerConstants c3)
(hcmem : ∀ c, NatNode.const c ∈ N.nodes → Nontrivial c → c ∈ consts)
(hpow : PowerSetup recipes power P N)
(a : Fin (translate consts N mode natIn power).parameterCount → ℚ) :
((Recipe.model (translate consts N mode natIn power)).denote
(templateLibrary I cstar ell T c3) recipes).Rel a ↔
∃ x : ℕ → ℚ, (∀ i (hi : i < (translate consts N mode natIn power).parameterCount),
x i = a ⟨i, hi⟩) ∧
ModelHolds (templateLibrary I cstar ell T c3) recipes (translate consts N mode natIn power) x
theorem modelRecipe_rel_iff (templates recipes : List ExPoly) (r : ModelRecipe)
(hsc : ScopedIn (r.formula templates recipes) r.parameterCount r.variableCount)
(a : Fin r.parameterCount → ℚ) :
((Recipe.model r).denote templates recipes).Rel a ↔
∃ x : ℕ → ℚ, (∀ i (hi : i < r.parameterCount), x i = a ⟨i, hi⟩) ∧
ModelHolds templates recipes r x
structure WellFormed (P N : NatCircuit) (V : ℕ) : Prop where
/-- Conditions 1–6, with call blocks of length `V_𝒫 - 3`. -/
core : WellFormedCore N (P.varCount - 3) V
/-- Condition 7. -/
power : HasCall N → P.inputCount = 3 ∧ (∀ a b c w, NatNode.call a b c w ∉ P.nodes) ∧
WellFormedCore P 0 P.varCount ∧ P.explicitVars.map Prod.fst = List.range P.varCount
ZInQKernel/Compiler/Translation/WellFormed.lean:67
def integerConstants (c3 : ℤ) : List ℤ := [4, 2, 3, c3, 1399]
ZInQKernel/Syntax/Templates/Library.lean:18
inductive NatNode
| const (c : ℤ)
| var (i : ℕ)
| add (j k : ℕ)
| mul (j k : ℕ)
| call (a b c w : ℕ)
deriving DecidableEq, Repr
ZInQKernel/Compiler/Circuits/Construction.lean:43
def Nontrivial (c : ℤ) : Prop := c ≠ 0 ∧ c ≠ 1 ∧ c ≠ -1
ZInQKernel/Compiler/Translation/Spec.lean:72
structure PowerSetup (recipes : List ExPoly) (power : Option (ℕ × ℕ)) (P N : NatCircuit) :
Prop where
wf : ∀ i w, power = some (i, w) → (getEx recipes i).WF
witnesses : ∀ i w, power = some (i, w) → (getEx recipes i).witnesses = w
present : HasCall N → power.isSome
spec : ∀ i w, power = some (i, w) → HasCall N → PowerValueSpec (getEx recipes i) P
ZInQKernel/Compiler/Translation/TranslateSemantics.lean:34
def translate (consts : List ℤ) (N : NatCircuit) (mode : OutputMode) (natInputs : Bool)
(power : Option (ℕ × ℕ)) : ModelRecipe :=
let p := trParams N.inputCount mode
let s := trState consts N mode natInputs power
{ parameterCount := p
variableCount := s.next
generator := ![p, p + 1, p + 2]
sources := s.sources
constants := s.constants
operations := s.operations
rootEq := (s.nodePts.getD N.root (-4),
match mode with
⋯
ZInQKernel/Syntax/Recipes/Translate.lean:152
inductive Recipe
/-- A composition recipe. -/
| composition (r : CompositionRecipe)
/-- A model-evaluation recipe. -/
| model (r : ModelRecipe)
ZInQKernel/Syntax/Language/Nodes.lean:231
noncomputable def templateLibrary (I : Constructors E) (cstar ell T c3 : ℤ) : List ExPoly :=
[memberTemplate, rawAddTemplate, rawZTemplate, rawInverseXTemplate, log25Template, poleTemplate,
testGroupTemplate, slopeTemplate, heightTemplate, scalarTemplate I cstar, guardTemplate I T,
multiplyTemplate I cstar ell T, naturalTemplate I cstar ell T,
signedEncodeTemplate I cstar ell T, absTemplate, closeTemplate,
valueTestTemplate I cstar ell T, exceptionsTemplate] ++
(integerConstants c3).map (scalarTemplate I)
ZInQKernel/Syntax/Templates/Library.lean:25
structure ModelHolds (templates recipes : List ExPoly) (r : ModelRecipe) (x : ℕ → ℚ) : Prop
extends ModelHoldsExceptRoot templates recipes r x where
/-- The root equality. -/
root : refVal r.generator x r.rootEq.1 = refVal r.generator x r.rootEq.2
ZInQKernel/Compiler/Translation/RecipeRelation.lean:112
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 ModelRecipe where
/-- The parameter count. -/
parameterCount : ℕ
/-- The variable count. -/
variableCount : ℕ
/-- The generator variable indices `g₀, g₁, g₂`. -/
generator : Fin 3 → ℕ
/-- Source variable rows `(r, s)`: a point reference and a natural start or none. -/
sources : List (ℤ × Option ℕ)
/-- Constant definitions `(σ, r, s)`: a scalar template, a point reference, a start. -/
constants : List (ℕ × ℤ × ℕ)
/-- The operations. -/
⋯
ZInQKernel/Syntax/Language/Nodes.lean:206
structure ScopedIn (φ : Formula) (p v : ℕ) : Prop where
/-- Callees well formed, blocks disjoint, free polynomials avoid the blocks. -/
scope : φ.Scoped
/-- The blocks lie above the parameters. -/
above : ∀ b ∈ φ.blocks, p ≤ b.1
/-- Every variable is below the variable count. -/
varsLT : VarsLT φ.compile v
/-- The parameters are among the variables. -/
le : p ≤ v
ZInQKernel/Compiler/Translation/RecipeRelation.lean:157
Uses 8 · Used by 3
Induction along the source DAG gives every node point the code of the node's signed integer value. Natural guards constrain only the explicit variables, never intermediate sums or products; raw addition always receives canonical codes; globally typed multiplication types the products; the generator equations and the scalar templates supply the constants. A power call contributes the code of the power template's value at some private natural witnesses. Conversely, a natural solution provides rational witnesses for every call.
- Every node point is the code of the node's value
- Natural solutions give rational witnesses
- Semantics of the model-evaluation translation
The power-value and precision recipes
The two translated circuits satisfy the scope conditions: no parent variable node reads a private coordinate, the private blocks are disjoint, and every nontrivial constant is at least two.
TheoremScope conditions of the natural precision circuit#✓
Let \(\mathcal N\) be the natural precision circuit (the circuit of the natural precision polynomial \(C\), obtained by specializing the universal halting circuit at the program literal \(c_3\)) and \(\mathcal P\) its power template. Then \(\mathcal P\) is well-formed with bound \(82\), with explicit variables exactly \(0,1,\dots,81\) in increasing order, \(0,1,2\) the inputs, so that its call blocks have \(79\) variables; and \(\mathcal N\) is well-formed with bound \(1305811\), its \(15845\) call nodes calling \(\mathcal P\). In particular no variable node of the parent reads a private coordinate of a power call.
Proof sketch. For \(\mathcal P\): the power template has \(3\) parameters and \(79\) witnesses on the variables \(0,\dots,81\), and by its node statistics it has no call nodes and nontrivial constants \(4,2,3\), all at least \(2\). For \(\mathcal N\): by its shape it has \(5\) inputs listed first among \(54056\) distinct explicit variables, \(15845\) calls with blocks of \(79\) variables, variable count \(1305811\), and nontrivial constants \(c_3,2,4,1399\), where \(c_3>1399\ge2\) by the size of the program literal; by the specialization statement it is well scoped, so the blocks are pairwise disjoint and disjoint from the explicit variables and every variable node refers to an explicit variable. The remaining conditions (every operand of an addition, multiplication or call node is an earlier node, and the root is a node) hold for the hash-consed node lists of both constructions and are a closed decidable check, or follow from the construction.
theorem precisionCircuit_wellFormed :
WellFormed powerTemplateCircuit precisionCircuit 1305811 ∧
precisionCircuit.blocks.length = 15845 ∧
WellFormed powerTemplateCircuit powerTemplateCircuit 82 ∧
powerTemplateCircuit.explicitVars.map Prod.fst = List.range 82
theorem powerTemplate_wellFormed :
WellFormed powerTemplateCircuit powerTemplateCircuit 82 ∧
powerTemplateCircuit.explicitVars.map Prod.fst = List.range 82 ∧
powerTemplateCircuit.inputCount = 3 ∧ powerTemplateCircuit.varCount = 82 ∧
(∀ a b c w, NatNode.call a b c w ∉ powerTemplateCircuit.nodes) ∧
WellFormedCore powerTemplateCircuit 0 powerTemplateCircuit.varCount
structure WellFormed (P N : NatCircuit) (V : ℕ) : Prop where
/-- Conditions 1–6, with call blocks of length `V_𝒫 - 3`. -/
core : WellFormedCore N (P.varCount - 3) V
/-- Condition 7. -/
power : HasCall N → P.inputCount = 3 ∧ (∀ a b c w, NatNode.call a b c w ∉ P.nodes) ∧
WellFormedCore P 0 P.varCount ∧ P.explicitVars.map Prod.fst = List.range P.varCount
ZInQKernel/Compiler/Translation/WellFormed.lean:67
def powerTemplateCircuit : NatCircuit := powerTemplateConstruction.toCircuit 3
ZInQKernel/Compiler/Circuits/PowerTemplate.lean:31
def precisionCircuit : NatCircuit := precisionCircuitOf c3
ZInQKernel/Compiler/Universal/WrapperCode.lean:42
inductive NatNode
| const (c : ℤ)
| var (i : ℕ)
| add (j k : ℕ)
| mul (j k : ℕ)
| call (a b c w : ℕ)
deriving DecidableEq, Repr
ZInQKernel/Compiler/Circuits/Construction.lean:43
structure WellFormedCore (N : NatCircuit) (m V : ℕ) : Prop where
/-- The explicit variable indices are pairwise distinct. -/
vars_nodup : (N.explicitVars.map Prod.fst).Nodup
/-- The first `k` explicit variables are the inputs `0, …, k-1`. -/
inputs_first : N.explicitVars.take N.inputCount =
(List.range N.inputCount).map fun i => (i, VarKind.input)
/-- There are at least `k` explicit variables. -/
inputs_le : N.inputCount ≤ N.explicitVars.length
/-- No later explicit variable is an input. -/
later_witness : ∀ v ∈ N.explicitVars.drop N.inputCount, v.2 = VarKind.witness
/-- Every argument of a node is an earlier node. -/
args_lt : NodesWF N.nodes
⋯
ZInQKernel/Compiler/Translation/WellFormed.lean:36
Uses 8 · Used by 2
The program literal \(c_3\) is a constant of the precision recipe. Its digits are never computed; the natural chapter bounds it by \(1399<c_3<2^{2^{24}}\) (size of the program literal), which gives the scope condition \(c_3\ge2\) here and the size chapter's literal bound.
The power-value recipe has three signed code inputs, seventy-nine private natural witnesses and an output code for the value of the power-template polynomial.
The precision parent has \(54056\) explicit variables and \(15845\) disjoint private blocks; replacing each block by its private power-value call preserves the existential assignment, and only the final root is equated to the identity. This is input C on the rational side.
With equation (C.4), the precision recipe therefore holds at codes \(\iota(c_0),\dots,\iota(c_4)\) exactly when the precision relation accepts \(c\); the assembly chapter's relation Close uses it in this form.
At each primitive formula, equality is a difference, conjunction a sum of squares and disjunction a product; the specification chapter proves that these compilations, including the globally conjoined fixed equations, give equality of polynomial values under substitution (Sums of squares and products over the rationals, Private witness blocks).
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.