Preliminaries #
noncomputable def
Nat.div2Induction
{motive : Nat → Sort u}
(n : Nat)
(ind : (n : Nat) → (n > 0 → motive (n / 2)) → motive n)
:
motive n
An induction principal that works on division by two.
Equations
- Nat.div2Induction n ind = Nat.strongRecOn n fun (n : Nat) (hyp : (m : Nat) → m < n → motive m) => ind n fun (n_pos : n > 0) => if n_eq : n = 0 then ⋯.elim else hyp (n / 2) ⋯
Instances For
testBit #
Depending on use cases either testBit_add_one
or testBit_div_two
may be more useful as a simp
lemma, so neither is a global simp
lemma.
theorem
Nat.eq_of_testBit_eq
{x : Nat}
{y : Nat}
(pred : ∀ (i : Nat), x.testBit i = y.testBit i)
:
x = y
eq_of_testBit_eq
allows proving two natural numbers are equal
if their bits are all equal.
testBit 1 i
is true iff the index i
equals 0.
bitwise #
bitwise #
and #
Equations
Equations
Equations
@[reducible, inline, deprecated Nat.and_pow_two_sub_one_eq_mod]
Instances For
@[reducible, inline, deprecated Nat.and_pow_two_sub_one_of_lt_two_pow]
Instances For
lor #
Equations
Equations
Equations
instance
Nat.instLawfulCommIdentityHOrOfNat :
Std.LawfulCommIdentity (fun (x1 x2 : Nat) => x1 ||| x2) 0
Equations
xor #
Equations
Equations
instance
Nat.instLawfulCommIdentityHXorOfNat :
Std.LawfulCommIdentity (fun (x1 x2 : Nat) => x1 ^^^ x2) 0