Additional properties of binary recursion on nat
#
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
This file documents additional properties of binary recursion,
which allows us to more easily work with operations which do depend
on the number of leading zeros in the binary representation of n
.
For example, we can more easily work with nat.bits
and nat.size
.
See also: nat.bitwise
, nat.pow
(for various lemmas about size
and shiftl
/shiftr
),
and nat.digits
.
bodd_div2
and bodd
#
theorem
nat.bit_cases_on_injective
{C : ℕ → Sort u} :
function.injective (λ (H : Π (b : bool) (n : ℕ), C (nat.bit b n)) (n : ℕ), n.bit_cases_on H)
theorem
nat.binary_rec_eq'
{C : ℕ → Sort u_1}
{z : C 0}
{f : Π (b : bool) (n : ℕ), C n → C (nat.bit b n)}
(b : bool)
(n : ℕ)
(h : f bool.ff 0 z = z ∨ (n = 0 → b = bool.tt)) :
nat.binary_rec z f (nat.bit b n) = f b n (nat.binary_rec z f n)
The same as binary_rec_eq, but that one unfortunately requires f
to be the identity when
appending ff
to 0
. Here, we allow you to explicitly say that that case is not happening, i.e.
supplying n = 0 → b = tt
.