Mathlib.Data.Nat.BitIndices
16 declarations and 2 deprecated aliases. Mathlib docs · Source
def Nat.bitIndices E1 #
ℕ → List ℕ
The function which maps each natural number ∑ i ∈ s, 2 ^ i to the list of
elements of s in increasing order.
theorem Nat.bitIndices_zero E0 #
Nat.bitIndices 0 = []
theorem Nat.bitIndices_one E0 #
Nat.bitIndices 1 = [0]
theorem Nat.bitIndices_bit_true E1 #
∀ (n : ℕ), (Nat.bit true n).bitIndices = 0 :: List.map (fun x ↦ x + 1) n.bitIndices
theorem Nat.bitIndices_bit_false E1 #
∀ (n : ℕ), (Nat.bit false n).bitIndices = List.map (fun x ↦ x + 1) n.bitIndices
theorem Nat.bitIndices_two_mul_add_one E0 #
∀ (n : ℕ), (2 * n + 1).bitIndices = 0 :: List.map (fun x ↦ x + 1) n.bitIndices
theorem Nat.bitIndices_two_mul E0 #
∀ (n : ℕ), (2 * n).bitIndices = List.map (fun x ↦ x + 1) n.bitIndices
theorem Nat.bitIndices_sorted E0 #
∀ {n : ℕ}, n.bitIndices.SortedLT
theorem Nat.bitIndices_nodup E0 #
∀ {n : ℕ}, n.bitIndices.Nodup
theorem Nat.bitIndices_two_pow_mul E0 #
∀ (k n : ℕ), (2 ^ k * n).bitIndices = List.map (fun x ↦ x + k) n.bitIndices
theorem Nat.bitIndices_two_pow E0 #
∀ (k : ℕ), (2 ^ k).bitIndices = [k]
theorem Nat.sum_map_two_pow_bitIndices E0 #
∀ (n : ℕ), (List.map (fun i ↦ 2 ^ i) n.bitIndices).sum = n
theorem Nat.mem_bitIndices E0 #
∀ {i n : ℕ}, i ∈ n.bitIndices ↔ n.testBit i = true
theorem Nat.bitIndices_sum_map_two_pow E1 #
∀ {L : List ℕ}, L.SortedLT → (List.map (fun i ↦ 2 ^ i) L).sum.bitIndices = L
Together with Nat.sum_map_bitIndices_two_pow, this implies a bijection between ℕ and Finset ℕ.
See Finset.equivBitIndices for this bijection.
theorem Nat.two_pow_le_of_mem_bitIndices E1 #
∀ {a n : ℕ}, a ∈ n.bitIndices → 2 ^ a ≤ n
theorem Nat.notMem_bitIndices_self E1 #
∀ (n : ℕ), n ∉ n.bitIndices
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Nat.bitIndices_twoPowsum | Nat.bitIndices_sum_map_two_pow | 2026-05-15 |
Nat.twoPowSum_bitIndices | Nat.sum_map_two_pow_bitIndices | 2026-05-15 |