Moving a list of Gaussian integers to the output stack
ProvedNLogN.FW.mvPairs_specLet be a list of pairs of integers stored on stack KO, registers NN and KR holding and , and suppose all coordinates, and have bit length and . Then the loop mvPairs moves (reversed) onto OUT within cost .
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.mvPairs_spec (M : MulSpec) (N e W : ℕ) (s : IState HS) (Z : List (ℤ × ℤ)) (RK LN LR : List Item)
(hZl : Z.length = N * 2 ^ e) (hK : s.G KO = gints Z ++ RK) (hN : s.G NN = .int (N : ℤ) :: LN)
(hR : s.G KR = .int ((2 ^ e : ℕ) : ℤ) :: LR)
(hZW : ∀ p ∈ Z, zsz p.1 ≤ W ∧ zsz p.2 ≤ W) (hNW : zsz ((N * 2 ^ e : ℕ) : ℤ) ≤ W)
(hNW1 : zsz (N : ℤ) ≤ W) (heW : e + 1 ≤ W) :
Spec M mvPairs s ((s.upd KO RK).upd OUT (gints Z.reverse ++ s.G OUT))
(8000 * (W + 2) + N * 2 ^ e * (40000 * (W + 2)) + 32) := by sorry