Iterated Base-2 Logarithms (Nat.iterLog, Nat.iterClog, and Nat.iterClogBeta) #
CslibFrontier/Foundations/Data/Nat/LogStar.lean defines the tower of twos Nat.twoTower and its
ceiling-logarithm inverse Nat.logStar (the least k with (Nat.clog 2)^[k] n ≤ 1, equivalently
n ≤ Nat.twoTower k). This module supplies:
- the iterated base-2 floor logarithm
Nat.iterLog k n = (Nat.log 2)^[k] nand its exact stopping countNat.floorLogStar n = Nat.logStar (n + 1) - 1(the leastksuch thatNat.iterLog k n ≤ 1, equivalentlyn < Nat.twoTower (k + 1)); - the iterated base-2 ceiling logarithm
Nat.iterClog k n = (Nat.clog 2)^[k] n, its Galois adjoint iterated base-2 exponential towerNat.iterPow2 k x = (2 ^ ·)^[k] x, and the generalized stopping indexNat.iterClogBeta t n(the leastk ≥ 1withNat.iterClog k n ≤ max 1 t, equivalentlyn ≤ Nat.iterPow2 k (max 1 t)).
Naming the floor stopping count Nat.floorLogStar avoids collision with the ceiling convention
Nat.logStar (whose values differ at n = 3 and n = 5, …, 15), while defining it in terms of
Nat.logStar avoids duplicating structural fuel recursion and provides exact floor-logarithm
recurrence laws (floorLogStar_of_gt_one : 1 < n → floorLogStar n = floorLogStar (Nat.log 2 n) + 1
and lt_floorLogStar_iff : k < floorLogStar n ↔ 1 < iterLog k n).
Main definitions #
Nat.iterLog: iterated base-2 floor logarithm⌊log₂^(k) n⌋.Nat.floorLogStar: base-2 floor iterated logarithmNat.logStar (n + 1) - 1, the leastkwithiterLog k n ≤ 1.Nat.iterClog: iterated base-2 ceiling logarithm⌈log₂^(k) n⌉.Nat.iterPow2: iterated base-2 exponential tower(2 ^ ·)^[k] x.Nat.iterClogBeta: generalized stopping index, the leastk ≥ 1withiterClog k n ≤ max 1 t.
Main results #
Nat.iterLog_eq_iterate,Nat.iterLog_succ_apply,Nat.iterLog_add: iteration laws.Nat.iterLog_mono,Nat.iterLog_anti_left: monotonicity innand antitonicity ink.Nat.iterLog_le_one_iff_lt_twoTower:iterLog k n ≤ 1 ↔ n < twoTower (k + 1).Nat.floorLogStar_of_le_one,Nat.floorLogStar_of_gt_one: base andNat.log 2step equations.Nat.iterLog_floorLogStar_le_one,Nat.lt_floorLogStar_iff,Nat.floorLogStar_le_iff: exact threshold characterizationsk < floorLogStar n ↔ 1 < iterLog k nandfloorLogStar n ≤ k ↔ iterLog k n ≤ 1.Nat.floorLogStar_mono,Nat.floorLogStar_le_logStar,Nat.logStar_le_floorLogStar_add_one: monotonicity and comparison within1of ceilingNat.logStar.Nat.sub_le_iterLog_of_lt_floorLogStar,Nat.four_le_floorLogStar_two_pow,Nat.six_mul_iterLog_two_two_pow_le: remaining-step lower bound and dyadic threshold bounds for32 ≤ m.Nat.max_iterLog_two_max_four,Nat.max_iterLog_two_eq,Nat.iterLog_two_max_four_le_clog,Nat.clog_clog_max_four_le_two_mul_iterLog: positivity, clamping identity, and ceiling comparison atk = 2.Nat.iterClog_le_iff_le_iterPow2,Nat.iterClog_mono,Nat.iterClog_anti_left,Nat.iterLog_le_iterClog,Nat.iterClog_le_iterLog_add_one: Galois correspondence, monotonicity, and floor/ceiling comparisons foriterCloganditerPow2.Nat.iterClogBeta_le_iff,Nat.iterClogBeta_le_iff_le_iterPow2,Nat.iterClogBeta_mono_right,Nat.iterClogBeta_anti_left,Nat.iterClogBeta_of_le_one: threshold characterization, monotonicity, andlogStarspecialization foriterClogBeta.Nat.iterClogBeta_lt_of_two_pow_le,Nat.iterClogBeta_div_lt_of_mul_le,Nat.mul_iterClogBeta_le_of_div_le,Nat.mul_iterClogBeta_div_le_iterLog: strict phase-rank drop andk-parameterized multiplicative bounds fort = 2 * m / n.
References #
Base-2 floor iterated logarithm: the least k : ℕ such that iterLog k n ≤ 1,
expressed via logStar (n + 1) - 1 so it shares logStar's structural kernel reduction.
Threshold characterization: floorLogStar n ≤ k iff iterLog k n ≤ 1.
Strict threshold characterization: k < floorLogStar n iff 1 < iterLog k n.
After floorLogStar n iterations, iterLog reaches at most 1.
Base equation: floorLogStar n = 0 for n ≤ 1.
Step equation: for 1 < n, floorLogStar n = floorLogStar (Nat.log 2 n) + 1.
Floor floorLogStar never exceeds ceiling logStar.
Ceiling logStar exceeds floor floorLogStar by at most 1.
If d < floorLogStar n and r ≤ d, at least d + 1 - r remains in iterLog (r + 1) n.
For 32 ≤ m, 2 ^ m requires at least 4 floor-logarithm steps to reach ≤ 1.
Iterated base-2 ceiling logarithm and exponential tower #
Zero-iteration ceiling logarithm is the identity.
Iterated ceiling logarithm of 0 is 0.
Zero-iteration exponential tower is the identity.
iterPow2 k is strictly monotone in its second argument.
Generalized iterated-logarithm stopping index (iterClogBeta) #
Bounded upward search helper for iterClogBeta: iterClogBetaAux t n fuel k scans upward
from k through k + fuel for the least m ≥ k satisfying iterClog m n ≤ max 1 t. When
fuel = 0, it returns k unconditionally even if max 1 t < iterClog k n; it is guaranteed to
return the least satisfying m ≥ k only under the precondition iterClog (k + fuel) n ≤ max 1 t,
and otherwise returns k + fuel.
iterClogBeta t n is always at least 1.
After iterClogBeta t n iterations, iterClog drops to at most max 1 t.
Tower characterization of iterClogBeta: n ≤ iterPow2 (iterClogBeta t n) (max 1 t).
Threshold characterization for 1 ≤ k: iterClogBeta t n ≤ k ↔ iterClog k n ≤ max 1 t.
Tower threshold characterization for 1 ≤ k:
iterClogBeta t n ≤ k ↔ n ≤ iterPow2 k (max 1 t).
Strict threshold characterization for 1 ≤ k:
k < iterClogBeta t n ↔ max 1 t < iterClog k n.
iterClogBeta t n = 1 iff n ≤ 2 ^ max 1 t.
When t ≤ 1, iterClogBeta t n equals max 1 (logStar n).
iterClogBeta t is monotone in its second argument.
iterClogBeta is antitone in its threshold parameter t.
iterClogBeta t n never exceeds max 1 (logStar n).
For 1 ≤ k, iterClogBeta t n ≤ k + iterClog k n.
Strictly shrinking step: if n₂ ≤ n₁, 2 ^ max 1 t₁ < n₁, and 2 ^ max 1 t₁ ≤ max 1 t₂,
then iterClogBeta t₂ n₂ < iterClogBeta t₁ n₁.
For fixed c, n ↦ iterClogBeta (c / n) n is monotone.
Two-parameter rank drop: if 1 ≤ n₂ ≤ n₁, 2 ^ (c / n₁) < n₁, and
n₂ * (2 ^ (c / n₁) + 1) ≤ c, then iterClogBeta (c / n₂) n₂ < iterClogBeta (c / n₁) n₁.
Multiplicative phase bound parameterized by k : ℕ whenever 2 * m / n ≤ max 1 t:
m * iterClogBeta t n ≤ (k + 1) * m + 2 * (k + 2) * n * max 1 (iterClog k n).
Multiplicative phase bound via iterLog k n for 1 ≤ k:
m * iterClogBeta (2 * m / n) n ≤ (k + 1) * m + 4 * (k + 2) * n * max 1 (iterLog k n).