Documentation

Init.Data.Nat.Log2

theorem Nat.log2_terminates (n : Nat) :
n 2n / 2 < n
@[extern lean_nat_log2]
def Nat.log2 (n : Nat) :

Computes ⌊max 0 (log₂ n)⌋.

log2 0 = log2 1 = 0, log2 2 = 1, ..., log2 (2^i) = i, etc.

Equations
Instances For