Cost bound for the stack-machine transposition program
ProvedNLogN.transP_costLet be a list of rows, each of integers bounded by in bit length, stored flattened on stack 0, with , , and stacks 1,2,3 holding , , . Then the transposition program transP d costs at most .
Formalization Note. Bnd B r says every entry of has bit length . 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 open NLogN open IntMul RS set_option maxHeartbeats 1000000
theorem NLogN.transP_cost (d n m kb B : ℕ) (D : List (List ℤ)) (Rest : List Item) (s : IState HS)
(hD : D.length = n * m) (hDw : ∀ r ∈ D, r.length = d) (hN : n * m ≤ 2 ^ kb) (hm : 1 ≤ m)
(L1 L2 L3 : List Item) (h0 : s.G 0 = ints D.flatten ++ Rest) (h1 : s.G 1 = .int n :: L1)
(h2 : s.G 2 = .int m :: L2) (h3 : s.G 3 = .int kb :: L3) (hDB : ∀ r ∈ D, Bnd B r) :
(transP d).cost s ≤ 10 ^ 6 * (kb + 1) * (n * m + 1) * (d + 1) * (B + kb + d + 4) := by sorry