Documentation

Init.Data.Nat.Power2

theorem Nat.nextPowerOfTwo_dec {n power : Nat} (h₁ : power > 0) (h₂ : power < n) :
n - power * 2 < n - power

Returns the least power of two that's greater than or equal to n.

Examples:

Equations
    Instances For
      @[irreducible]
      def Nat.nextPowerOfTwo.go (n power : Nat) (h : power > 0) :
      Equations
        Instances For

          A natural number n is a power of two if there exists some k : Nat such that n = 2 ^ k.

          Equations
            Instances For
              @[reducible, inline, deprecated Nat.isPowerOfTwo_one (since := "2025-03-18")]
              Equations
                Instances For
                  @[reducible, inline, deprecated Nat.isPowerOfTwo_mul_two_of_isPowerOfTwo (since := "2025-04-04")]
                  Equations
                    Instances For
                      theorem Nat.pos_of_isPowerOfTwo {n : Nat} (h : n.isPowerOfTwo) :
                      n > 0
                      @[irreducible]
                      theorem Nat.isPowerOfTwo_nextPowerOfTwo.isPowerOfTwo_go (n power : Nat) (h₁ : power > 0) (h₂ : power.isPowerOfTwo) :