Properties of the binary representation of integers #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
@[simp, norm_cast]
@[simp, norm_cast]
theorem
num.of_nat'_bit
(b : bool)
(n : ℕ) :
num.of_nat' (nat.bit b n) = cond b num.bit1 num.bit0 (num.of_nat' n)
@[simp]
@[simp, norm_cast]
@[protected, instance]
Equations
- num.add_monoid = {add := has_add.add num.has_add, add_assoc := num.add_monoid._proof_1, zero := 0, zero_add := num.zero_add, add_zero := num.add_zero, nsmul := nsmul_rec (add_zero_class.to_has_add num), nsmul_zero' := num.add_monoid._proof_2, nsmul_succ' := num.add_monoid._proof_3}
@[protected, instance]
Equations
- num.add_monoid_with_one = {nat_cast := num.of_nat', add := add_monoid.add num.add_monoid, add_assoc := _, zero := add_monoid.zero num.add_monoid, zero_add := _, add_zero := _, nsmul := add_monoid.nsmul num.add_monoid, nsmul_zero' := _, nsmul_succ' := _, one := 1, nat_cast_zero := num.of_nat'_zero, nat_cast_succ := num.add_monoid_with_one._proof_1}
@[protected, instance]
Equations
- num.comm_semiring = {add := has_add.add num.has_add, add_assoc := _, zero := 0, zero_add := _, add_zero := _, nsmul := add_monoid.nsmul num.add_monoid, nsmul_zero' := _, nsmul_succ' := _, add_comm := num.comm_semiring._proof_1, mul := has_mul.mul num.has_mul, left_distrib := num.comm_semiring._proof_2, right_distrib := num.comm_semiring._proof_3, zero_mul := num.comm_semiring._proof_4, mul_zero := num.comm_semiring._proof_5, mul_assoc := num.comm_semiring._proof_6, one := 1, one_mul := num.comm_semiring._proof_7, mul_one := num.comm_semiring._proof_8, nat_cast := add_monoid_with_one.nat_cast num.add_monoid_with_one, nat_cast_zero := _, nat_cast_succ := _, npow := npow_rec {mul := has_mul.mul num.has_mul}, npow_zero' := num.comm_semiring._proof_9, npow_succ' := num.comm_semiring._proof_10, mul_comm := num.comm_semiring._proof_11}
@[protected, instance]
Equations
- num.ordered_cancel_add_comm_monoid = {add := comm_semiring.add num.comm_semiring, add_assoc := _, zero := comm_semiring.zero num.comm_semiring, zero_add := _, add_zero := _, nsmul := comm_semiring.nsmul num.comm_semiring, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, le := has_le.le num.has_le, lt := has_lt.lt num.has_lt, le_refl := num.ordered_cancel_add_comm_monoid._proof_1, le_trans := num.ordered_cancel_add_comm_monoid._proof_2, lt_iff_le_not_le := num.ordered_cancel_add_comm_monoid._proof_3, le_antisymm := num.ordered_cancel_add_comm_monoid._proof_4, add_le_add_left := num.ordered_cancel_add_comm_monoid._proof_5, le_of_add_le_add_left := num.ordered_cancel_add_comm_monoid._proof_6}
@[protected, instance]
Equations
- num.linear_ordered_semiring = {add := comm_semiring.add num.comm_semiring, add_assoc := _, zero := comm_semiring.zero num.comm_semiring, zero_add := _, add_zero := _, nsmul := comm_semiring.nsmul num.comm_semiring, nsmul_zero' := _, nsmul_succ' := _, add_comm := _, mul := comm_semiring.mul num.comm_semiring, left_distrib := _, right_distrib := _, zero_mul := _, mul_zero := _, mul_assoc := _, one := comm_semiring.one num.comm_semiring, one_mul := _, mul_one := _, nat_cast := comm_semiring.nat_cast num.comm_semiring, nat_cast_zero := _, nat_cast_succ := _, npow := comm_semiring.npow num.comm_semiring, npow_zero' := _, npow_succ' := _, le := ordered_cancel_add_comm_monoid.le num.ordered_cancel_add_comm_monoid, lt := ordered_cancel_add_comm_monoid.lt num.ordered_cancel_add_comm_monoid, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := _, le_of_add_le_add_left := _, exists_pair_ne := num.linear_ordered_semiring._proof_1, zero_le_one := num.linear_ordered_semiring._proof_2, mul_lt_mul_of_pos_left := num.linear_ordered_semiring._proof_3, mul_lt_mul_of_pos_right := num.linear_ordered_semiring._proof_4, le_total := num.linear_ordered_semiring._proof_5, decidable_le := num.decidable_le, decidable_eq := num.decidable_eq, decidable_lt := num.decidable_lt, max := linear_ordered_add_comm_monoid.max._default ordered_cancel_add_comm_monoid.le ordered_cancel_add_comm_monoid.lt ordered_cancel_add_comm_monoid.le_refl ordered_cancel_add_comm_monoid.le_trans ordered_cancel_add_comm_monoid.lt_iff_le_not_le ordered_cancel_add_comm_monoid.le_antisymm num.decidable_le, max_def := num.linear_ordered_semiring._proof_6, min := linear_ordered_add_comm_monoid.min._default ordered_cancel_add_comm_monoid.le ordered_cancel_add_comm_monoid.lt ordered_cancel_add_comm_monoid.le_refl ordered_cancel_add_comm_monoid.le_trans ordered_cancel_add_comm_monoid.lt_iff_le_not_le ordered_cancel_add_comm_monoid.le_antisymm num.decidable_le, min_def := num.linear_ordered_semiring._proof_7}
@[simp, norm_cast]
@[simp, norm_cast]
@[protected, instance]
Equations
- pos_num.add_comm_semigroup = {add := has_add.add pos_num.has_add, add_assoc := pos_num.add_comm_semigroup._proof_1, add_comm := pos_num.add_comm_semigroup._proof_2}
@[protected, instance]
Equations
- pos_num.comm_monoid = {mul := has_mul.mul pos_num.has_mul, mul_assoc := pos_num.comm_monoid._proof_1, one := 1, one_mul := pos_num.comm_monoid._proof_2, mul_one := pos_num.comm_monoid._proof_3, npow := npow_rec {mul := has_mul.mul pos_num.has_mul}, npow_zero' := pos_num.comm_monoid._proof_4, npow_succ' := pos_num.comm_monoid._proof_5, mul_comm := pos_num.comm_monoid._proof_6}
@[protected, instance]
Equations
- pos_num.distrib = {mul := has_mul.mul pos_num.has_mul, add := has_add.add pos_num.has_add, left_distrib := pos_num.distrib._proof_1, right_distrib := pos_num.distrib._proof_2}
@[protected, instance]
Equations
- pos_num.linear_order = {le := has_le.le pos_num.has_le, lt := has_lt.lt pos_num.has_lt, le_refl := pos_num.linear_order._proof_1, le_trans := pos_num.linear_order._proof_2, lt_iff_le_not_le := pos_num.linear_order._proof_3, le_antisymm := pos_num.linear_order._proof_4, le_total := pos_num.linear_order._proof_5, decidable_le := λ (a b : pos_num), pos_num.decidable_le a b, decidable_eq := λ (a b : pos_num), pos_num.decidable_eq a b, decidable_lt := λ (a b : pos_num), pos_num.decidable_lt a b, max := max_default (λ (a b : pos_num), pos_num.decidable_le a b), max_def := pos_num.linear_order._proof_10, min := min_default (λ (a b : pos_num), pos_num.decidable_le a b), min_def := pos_num.linear_order._proof_11}
@[simp, norm_cast]
@[simp, norm_cast]
@[simp]
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
theorem
num.bitwise_to_nat
{f : num → num → num}
{g : bool → bool → bool}
(p : pos_num → pos_num → num)
(gff : g bool.ff bool.ff = bool.ff)
(f00 : f 0 0 = 0)
(f0n : ∀ (n : pos_num), f 0 (num.pos n) = cond (g bool.ff bool.tt) (num.pos n) 0)
(fn0 : ∀ (n : pos_num), f (num.pos n) 0 = cond (g bool.tt bool.ff) (num.pos n) 0)
(fnn : ∀ (m n : pos_num), f (num.pos m) (num.pos n) = p m n)
(p11 : p 1 1 = cond (g bool.tt bool.tt) 1 0)
(p1b : ∀ (b : bool) (n : pos_num), p 1 (pos_num.bit b n) = num.bit (g bool.tt b) (cond (g bool.ff bool.tt) (num.pos n) 0))
(pb1 : ∀ (a : bool) (m : pos_num), p (pos_num.bit a m) 1 = num.bit (g a bool.tt) (cond (g bool.tt bool.ff) (num.pos m) 0))
(pbb : ∀ (a b : bool) (m n : pos_num), p (pos_num.bit a m) (pos_num.bit b n) = num.bit (g a b) (p m n))
(m n : num) :
↑(f m n) = nat.bitwise g ↑m ↑n
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp]
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[protected, instance]
Equations
- znum.linear_order = {le := has_le.le znum.has_le, lt := has_lt.lt znum.has_lt, le_refl := znum.linear_order._proof_1, le_trans := znum.linear_order._proof_2, lt_iff_le_not_le := znum.linear_order._proof_3, le_antisymm := znum.linear_order._proof_4, le_total := znum.linear_order._proof_5, decidable_le := znum.decidable_le, decidable_eq := znum.decidable_eq, decidable_lt := znum.decidable_lt, max := max_default (λ (a b : znum), znum.decidable_le a b), max_def := znum.linear_order._proof_10, min := min_default (λ (a b : znum), znum.decidable_le a b), min_def := znum.linear_order._proof_11}
@[protected, instance]
Equations
- znum.add_comm_group = {add := has_add.add znum.has_add, add_assoc := znum.add_comm_group._proof_1, zero := 0, zero_add := znum.zero_add, add_zero := znum.add_zero, nsmul := add_group.nsmul._default 0 has_add.add znum.zero_add znum.add_zero, nsmul_zero' := znum.add_comm_group._proof_2, nsmul_succ' := znum.add_comm_group._proof_3, neg := has_neg.neg znum.has_neg, sub := add_group.sub._default has_add.add znum.add_comm_group._proof_4 0 znum.zero_add znum.add_zero (add_group.nsmul._default 0 has_add.add znum.zero_add znum.add_zero) znum.add_comm_group._proof_5 znum.add_comm_group._proof_6 has_neg.neg, sub_eq_add_neg := znum.add_comm_group._proof_7, zsmul := add_group.zsmul._default has_add.add znum.add_comm_group._proof_8 0 znum.zero_add znum.add_zero (add_group.nsmul._default 0 has_add.add znum.zero_add znum.add_zero) znum.add_comm_group._proof_9 znum.add_comm_group._proof_10 has_neg.neg, zsmul_zero' := znum.add_comm_group._proof_11, zsmul_succ' := znum.add_comm_group._proof_12, zsmul_neg' := znum.add_comm_group._proof_13, add_left_neg := znum.add_comm_group._proof_14, add_comm := znum.add_comm_group._proof_15}
@[protected, instance]
Equations
- znum.add_monoid_with_one = {nat_cast := λ (n : ℕ), znum.of_int' ↑n, add := add_comm_group.add znum.add_comm_group, add_assoc := _, zero := add_comm_group.zero znum.add_comm_group, zero_add := _, add_zero := _, nsmul := add_comm_group.nsmul znum.add_comm_group, nsmul_zero' := _, nsmul_succ' := _, one := 1, nat_cast_zero := znum.add_monoid_with_one._proof_1, nat_cast_succ := znum.add_monoid_with_one._proof_2}
@[protected, instance]
Equations
- znum.linear_ordered_comm_ring = {add := add_comm_group.add znum.add_comm_group, add_assoc := _, zero := add_comm_group.zero znum.add_comm_group, zero_add := _, add_zero := _, nsmul := add_comm_group.nsmul znum.add_comm_group, nsmul_zero' := _, nsmul_succ' := _, neg := add_comm_group.neg znum.add_comm_group, sub := add_comm_group.sub znum.add_comm_group, sub_eq_add_neg := _, zsmul := add_comm_group.zsmul znum.add_comm_group, zsmul_zero' := _, zsmul_succ' := _, zsmul_neg' := _, add_left_neg := _, add_comm := _, int_cast := linear_ordered_ring.int_cast._default add_monoid_with_one.nat_cast add_comm_group.add add_comm_group.add_assoc add_comm_group.zero add_comm_group.zero_add add_comm_group.add_zero add_comm_group.nsmul add_comm_group.nsmul_zero' add_comm_group.nsmul_succ' 1 add_monoid_with_one.nat_cast_zero add_monoid_with_one.nat_cast_succ add_comm_group.neg add_comm_group.sub add_comm_group.sub_eq_add_neg add_comm_group.zsmul add_comm_group.zsmul_zero' add_comm_group.zsmul_succ' add_comm_group.zsmul_neg' add_comm_group.add_left_neg, nat_cast := add_monoid_with_one.nat_cast znum.add_monoid_with_one, one := 1, nat_cast_zero := _, nat_cast_succ := _, int_cast_of_nat := znum.linear_ordered_comm_ring._proof_1, int_cast_neg_succ_of_nat := znum.linear_ordered_comm_ring._proof_2, mul := has_mul.mul znum.has_mul, mul_assoc := znum.linear_ordered_comm_ring._proof_3, one_mul := znum.linear_ordered_comm_ring._proof_4, mul_one := znum.linear_ordered_comm_ring._proof_5, npow := linear_ordered_ring.npow._default 1 has_mul.mul znum.linear_ordered_comm_ring._proof_6 znum.linear_ordered_comm_ring._proof_7, npow_zero' := znum.linear_ordered_comm_ring._proof_8, npow_succ' := znum.linear_ordered_comm_ring._proof_9, left_distrib := znum.linear_ordered_comm_ring._proof_10, right_distrib := znum.linear_ordered_comm_ring._proof_11, le := linear_order.le znum.linear_order, lt := linear_order.lt znum.linear_order, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, add_le_add_left := znum.linear_ordered_comm_ring._proof_12, exists_pair_ne := znum.linear_ordered_comm_ring._proof_13, zero_le_one := znum.linear_ordered_comm_ring._proof_14, mul_pos := znum.linear_ordered_comm_ring._proof_15, le_total := _, decidable_le := linear_order.decidable_le znum.linear_order, decidable_eq := linear_order.decidable_eq znum.linear_order, decidable_lt := linear_order.decidable_lt znum.linear_order, max := linear_order.max znum.linear_order, max_def := _, min := linear_order.min znum.linear_order, min_def := _, mul_comm := znum.linear_ordered_comm_ring._proof_16}
@[simp, norm_cast]
@[simp, norm_cast]
@[protected, instance]
Equations
- num.decidable_dvd a b = decidable_of_iff' (b % a = 0) num.dvd_iff_mod_eq_zero
@[protected, instance]
Equations
- pos_num.decidable_dvd a b = num.decidable_dvd (num.pos a) (num.pos b)
@[protected, instance]
Equations
@[protected, instance]
Equations
- int.snum_coe = {coe := int.of_snum}