HvdH machine lemma expNegFix_bnds (`expNegFix`, `expNeg`, `expPos` as register programs)
ProvedNLogN.expNegFix_bndsThe following holds (Lean statement, in the scope of module NLogN.HNumExp2):
theorem NLogN.expNegFix_bnds (n M : ℕ) (X : ℤ) :
zsz (M : ℤ) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (n : ℤ) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((n : ℤ) + 1) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((M : ℤ) + -((n : ℤ) + 1)) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz X ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (-X / log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (-X / log2Bits M * log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (X + -X / log2Bits M * log2Bits M) ≤ 3 * M + 14 ∧
zsz ((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)) + 1) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)).toNat + 3 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (expBits M (X + -X / log2Bits M * log2Bits M) 0).1 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (expBits M (X + -X / log2Bits M * log2Bits M) 0).2 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((expBits M (X + -X / log2Bits M * log2Bits M) 0).1 + 2 ^ ((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)).toNat) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat + 1
Context. The lemma belongs to the part expNegFix, expNeg, expPos as register programs: expNegFixP: inputs n on 10, M on 11, X on 12; result pushed on 13.
Uses (with pushes popped) registers 3 … 9 and the scratch registers of log2P
(0, 1, 2, 40 … 47) and expP (30 … 39).
Formalization Note. This is a lemma of the Lean development NLogN, a multitape-Turing-machine implementation of the Harvey–van der Hoeven integer multiplication algorithm, used in the proof of NLogN.FIN.theorem_1_1_nlogn : IntMul.MulTimeBound fun n => n * Real.log n. All names refer to the definition bundles IntMul_HvdH_M_Defs1–IntMul_HvdH_M_Defs8 (namespace NLogN), built on the platform model Def_IntMul_MultitapeModel and the published reference Def_IntMul_HvdH_MachineRef. The machine layer: IState HS is a state of 64 item stacks; RM programs have a semantics p.run s, a definedness predicate p.ok M s and a cost p.cost M s relative to a multiplication spec M : MulSpec; zsz z is the bit length of .
-- Harvey–van der Hoeven multitape-TM development (NLogN), generated by skeleton subtraction. import Definitions.Def_IntMul_HvdH_M_Defs8 set_option autoImplicit false set_option relaxedAutoImplicit false set_option maxHeartbeats 1000000 set_option linter.unusedSimpArgs false open NLogN open IntMul RS IntMul.HvdH set_option maxHeartbeats 1000000
theorem NLogN.expNegFix_bnds (n M : ℕ) (X : ℤ) :
zsz (M : ℤ) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (n : ℤ) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((n : ℤ) + 1) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((M : ℤ) + -((n : ℤ) + 1)) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz X ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (-X / log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (-X / log2Bits M * log2Bits M) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (X + -X / log2Bits M * log2Bits M) ≤ 3 * M + 14 ∧
zsz ((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)) + 1) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)).toNat + 3 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (expBits M (X + -X / log2Bits M * log2Bits M) 0).1 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz (expBits M (X + -X / log2Bits M * log2Bits M) 0).2 ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat ∧
zsz ((expBits M (X + -X / log2Bits M * log2Bits M) 0).1 + 2 ^ ((((M : ℤ) + -((n : ℤ) + 1)).toNat : ℤ) + ((-X / log2Bits M).toNat : ℤ)).toNat) ≤ expNegB n M (zsz X) (-X / log2Bits M).toNat + 1 := by sorry