Documentation

CslibFrontier.Foundations.Analysis.SignedDigitStream.Reciprocal

Early-word reciprocal and normalized smooth estimators on signed-digit streams #

This module formalizes the reciprocal algorithm of [OpenAI2026LogSpace, Section 10.4, Lemma 10.5] together with the normalized stream decompositions of Cslib.polynomialTransition4, Cslib.polynomialSwitch4, Cslib.rationalRamp4Unit, and the clipped stochastic-atom reciprocal 1 / (2 * max (1 / 2) (min 1 q)).

Main definitions #

Main results #

References #

Early-word truncation cutoff k(t) = t / 2 + 7 for 1 / (64 * x) on [1 / 4, 1] [OpenAI2026LogSpace, Lemma 10.5].

theorem Cslib.SignedDigitStream.recipCutoff_clock_payment {t j : ℕ} (hj : j ≤ recipCutoff t) :
↑(recipCutoff t + 1) ≤ 22 + 2 * (↑t - ↑j)

Early-word clock payment [OpenAI2026LogSpace, (10.16)]: every query j ≤ recipCutoff t during formation of the (recipCutoff t + 1)-place integer prefix is paid for by 2 * (t - j) with constant additive slack.

theorem Cslib.SignedDigitStream.clock_succ_le_early_payment {t j : ℕ} (hj : j ≤ recipCutoff t) :
↑(t + 1) ≤ 15 + 2 * (↑t - ↑j)

Also t + 1 itself is bounded by 15 + 2 * (t - j) on every early-word query j ≤ recipCutoff t [OpenAI2026LogSpace, (10.16)].

Rational early prefix x^{[recipCutoff t]} formed from digits 0 .. recipCutoff t.

Normalized constant Taylor coefficient α = 1 / (64 * x^0) for 1 / (64 * x).

Normalized linear Taylor coefficient β = -1 / (64 * (x^0) ^ 2) for 1 / (64 * x).

Product stream representing recipBeta x t * (streamVal x - streamPrefix x (recipCutoff t)).

Half-sum stream representing (recipAlpha x t + recipBeta x t * e) / 2.

Scaled integer approximation to 1 / (64 * streamVal x) at clock t [OpenAI2026LogSpace, (10.15)].

Exact signed-digit stream representing 1 / (64 * streamVal x) for streamVal x ∈ [1 / 4, 1].

theorem Cslib.SignedDigitStream.recipPrefixRat_mem_Icc {x : ℕ → ℤ} (hx : IsSignedStream x) (hx_mem : streamVal x ∈ Set.Icc (1 / 4) 1) (t : ℕ) :
↑(recipPrefixRat x t) ∈ Set.Icc (3 / 16) (17 / 16)
theorem Cslib.SignedDigitStream.abs_recipAlpha_le_one {x : ℕ → ℤ} (hx : IsSignedStream x) (hx_mem : streamVal x ∈ Set.Icc (1 / 4) 1) (t : ℕ) :
theorem Cslib.SignedDigitStream.abs_recipBeta_le_one {x : ℕ → ℤ} (hx : IsSignedStream x) (hx_mem : streamVal x ∈ Set.Icc (1 / 4) 1) (t : ℕ) :
theorem Cslib.SignedDigitStream.streamVal_recipHalfStream {x : ℕ → ℤ} (hx : IsSignedStream x) (hx_mem : streamVal x ∈ Set.Icc (1 / 4) 1) (t : ℕ) :
streamVal (recipHalfStream x t) = (↑(recipAlpha x t) + ↑(recipBeta x t) * (streamVal x - ↑(recipPrefixRat x t))) / 2

Lemma 10.5 (early-word scaled reciprocal) [OpenAI2026LogSpace, Lemma 10.5]: for any signed-digit stream x with streamVal x ∈ [1 / 4, 1], recip64Approx x approximates 1 / (64 * streamVal x) within scaled error < 2.

Clamping q to [1 / 2, 1] always lands inside [1 / 4, 1], and shiftClipVal 5 recovers the exact clipped stochastic-atom inverse 1 / (2 * max (1 / 2) (min 1 q)) from 1 / (64 * c).

theorem Cslib.SignedDigitStream.shiftClipVal_clippedAtomInv (q : ℝ) :
shiftClipVal 5 (1 / (64 * max (1 / 2) (min 1 q))) = 1 / (2 * max (1 / 2) (min 1 q))
theorem Cslib.SignedDigitStream.polynomialTransition4_eq_shiftClip (t : ℝ) :
polynomialTransition4 t = shiftClipVal 7 (max 0 (min 1 t) ^ 4 * (((1 / 32 + 1 / 8 * (1 - max 0 (min 1 t))) / 2 + (5 / 16 * (1 - max 0 (min 1 t)) ^ 2 + 5 / 8 * (1 - max 0 (min 1 t)) ^ 3) / 2) / 2))

Normalized [-1, 1] stream decomposition of Cslib.polynomialTransition4 via pairAvg and shiftClipVal 7.

theorem Cslib.SignedDigitStream.rationalRamp4Unit_eq_poly_add_inv (t : ℝ) :
rationalRamp4Unit t = max 0 t - 3 + 6 * (1 / (1 + max 0 t)) - 4 * (1 / (1 + max 0 t)) ^ 2 + (1 / (1 + max 0 t)) ^ 3

Exact polynomial-plus-reciprocal decomposition of Cslib.rationalRamp4Unit.

noncomputable def Cslib.SignedDigitStream.dyadicSwitch (r : ℕ) (w : ℝ) :

Smooth dyadic transition polynomialSwitch4 (2 ^ r) (2 ^ (r + 1)) w.

noncomputable def Cslib.SignedDigitStream.dyadicWeight (m r : ℕ) (w : ℝ) :

Smooth dyadic partition-of-unity weight ω_{m, r}(w) across scales 0 ≤ r ≤ m.

theorem Cslib.SignedDigitStream.dyadicSwitch_eq_of_norm {m r : ℕ} {w : ℝ} (hr : r ≤ m) (hw0 : 0 ≤ w) :
dyadicSwitch r w = polynomialTransition4 (shiftClipVal 2 ((shiftClipVal (↑m - ↑r) (w / 2 ^ (m + 1)) + -1 / 2) / 2))

Division-free normalized evaluation of dyadicSwitch r w from wNorm = w / 2 ^ (m + 1) whenever 0 ≤ w and r ≤ m.

theorem Cslib.SignedDigitStream.sum_dyadicWeight (m : ℕ) (w : ℝ) :
∑ r ∈ Finset.range (m + 1), dyadicWeight m r w = 1
theorem Cslib.SignedDigitStream.scaled_mem_Icc_of_dyadicWeight_ne_zero {m r : ℕ} {w : ℝ} (hw : w ∈ Set.Icc 1 (2 ^ (m + 1))) (hne : dyadicWeight m r w ≠ 0) :
w / 2 ^ (r + 1) ∈ Set.Icc (1 / 4) 1

Whenever dyadicWeight m r w ≠ 0 on w ∈ [1, 2 ^ (m + 1)], the scaled argument w / 2 ^ (r + 1) automatically lies in [1 / 4, 1].

theorem Cslib.SignedDigitStream.inv_eq_sum_dyadicWeight {m : ℕ} {w : ℝ} (hw : w ∈ Set.Icc 1 (2 ^ (m + 1))) :
1 / w = ∑ r ∈ Finset.range (m + 1), dyadicWeight m r w * (1 / 2 ^ (r + 1) * (1 / max (1 / 4) (min 1 (w / 2 ^ (r + 1)))))

Smooth dyadic partition-of-unity reciprocal formula: for every w ∈ [1, 2 ^ (m + 1)], 1 / w equals a weighted sum of m + 1 reciprocals whose arguments are all clamped to the fixed interval [1 / 4, 1].