Encoding blocks of Gaussian integers into the Fermat ring
ProvedNLogN.FW.encL_specLet be a list of Gaussian integers with coordinates of absolute value (), stored on stack GU, and let the registers hold , , , and . For bounds with and , , the program encL consumes and pushes on XD the list of residues encRes P r blk (Kronecker packing of each block of consecutive entries, real parts in the low half and imaginary parts times , reduced modulo ) for the blocks of , within cost encCost N r P Q W.
Formalization Note. The machine layer: IState HS is a state with stacks of items (Item = integer or mark), an input position and an output; RM programs (straight-line register code RS, loops rep, conditionals, calls of the multiplication procedure through a MulSpec giving its domain and cost) have a functional semantics p.run s, a definedness predicate p.ok M s and a cost p.cost M s; Spec M p s s' c abbreviates p.ok M s ∧ p.run s = s' ∧ p.cost M s ≤ c. ints L / gints U push an integer list / a list of pairs as items (head = top); zsz z is the bit length of . MulBnd M m Φ says the multiplication procedure accepts all pairs of integers of bit length at cost . Register names (GU, CR, KB, XN, …) are fixed stack indices.
-- Harvey–van der Hoeven multitape-TM development (NLogN), generated by skeleton subtraction. import Definitions.Def_IntMul_HvdH_M_Defs4 set_option autoImplicit false set_option relaxedAutoImplicit false set_option maxHeartbeats 1000000 set_option linter.unusedSimpArgs false set_option linter.unusedVariables false open NLogN open NLogN.FW open IntMul IntMul.HvdH NLogN
theorem NLogN.FW.encL_spec (M : MulSpec) (s : IState HS) (P r N W : ℕ) (U : List (ℤ × ℤ))
(RU LR LM LW LF LN : List Item) (hU : s.G GU = gints U ++ RU) (hUl : U.length = N * r)
(hb : ∀ z ∈ U, |z.1| < 2 ^ P ∧ |z.2| < 2 ^ P) (hP : 1 ≤ P) (hr : 1 ≤ r)
(hR : s.G CR = .int (2 ^ P) :: LR) (hM : s.G CM = .int (r : ℤ) :: LM)
(hW : s.G RW = .int (2 ^ (2 * r * P)) :: LW) (hF : s.G FR = .int (2 ^ (4 * r * P) + 1) :: LF)
(hN : s.G NN = .int (N : ℤ) :: LN)
(Q : ℕ) (hPQ : P ≤ Q) (hrQ : zsz (r : ℤ) ≤ Q) (hFW : 4 * r * P + 1 ≤ W) (hNW : zsz (N : ℤ) ≤ W) :
Spec M encL s ((s.upd GU RU).upd XD
(ints ((Ref.chunkL r U).map (encRes P r)) ++ s.G XD)) (encCost N r P Q W) := by sorry