Documentation

Mathlib.Data.Num.Lemmas

Properties of the binary representation of integers #

@[simp]
theorem PosNum.cast_one {α : Type u_1} [One α] [Add α] :
1 = 1
@[simp]
theorem PosNum.cast_one' {α : Type u_1} [One α] [Add α] :
one = 1
@[simp]
theorem PosNum.cast_bit0 {α : Type u_1} [One α] [Add α] (n : PosNum) :
n.bit0 = n + n
@[simp]
theorem PosNum.cast_bit1 {α : Type u_1} [One α] [Add α] (n : PosNum) :
n.bit1 = n + n + 1
@[simp]
theorem PosNum.cast_to_nat {α : Type u_1} [AddMonoidWithOne α] (n : PosNum) :
n = n
theorem PosNum.to_nat_to_int (n : PosNum) :
n = n
@[simp]
theorem PosNum.cast_to_int {α : Type u_1} [AddGroupWithOne α] (n : PosNum) :
n = n
theorem PosNum.succ_to_nat (n : PosNum) :
n.succ = n + 1
theorem PosNum.add_to_nat (m n : PosNum) :
↑(m + n) = m + n
theorem PosNum.add_succ (m n : PosNum) :
m + n.succ = (m + n).succ
theorem PosNum.mul_to_nat (m n : PosNum) :
↑(m * n) = m * n
theorem PosNum.cmp_to_nat_lemma {m n : PosNum} :
m < nm.bit1 < n.bit0
theorem PosNum.cmp_swap (m n : PosNum) :
(m.cmp n).swap = n.cmp m
theorem PosNum.cmp_to_nat (m n : PosNum) :
Ordering.casesOn (m.cmp n) (m < n) (m = n) (n < m)
theorem PosNum.lt_to_nat {m n : PosNum} :
m < n m < n
theorem PosNum.le_to_nat {m n : PosNum} :
m n m n
theorem Num.add_zero (n : Num) :
n + 0 = n
theorem Num.zero_add (n : Num) :
0 + n = n
theorem Num.add_one (n : Num) :
n + 1 = n.succ
theorem Num.add_succ (m n : Num) :
m + n.succ = (m + n).succ
theorem Num.bit1_of_bit1 (n : Num) :
n + n + 1 = n.bit1
theorem Num.ofNat'_bit (b : Bool) (n : ) :
ofNat' (Nat.bit b n) = (bif b then Num.bit1 else Num.bit0) (ofNat' n)
@[simp]
theorem Num.add_ofNat' (m n : ) :
ofNat' (m + n) = ofNat' m + ofNat' n
@[simp]
theorem Num.cast_zero {α : Type u_1} [Zero α] [One α] [Add α] :
0 = 0
@[simp]
theorem Num.cast_zero' {α : Type u_1} [Zero α] [One α] [Add α] :
zero = 0
@[simp]
theorem Num.cast_one {α : Type u_1} [Zero α] [One α] [Add α] :
1 = 1
@[simp]
theorem Num.cast_pos {α : Type u_1} [Zero α] [One α] [Add α] (n : PosNum) :
(pos n) = n
theorem Num.succ'_to_nat (n : Num) :
n.succ' = n + 1
theorem Num.succ_to_nat (n : Num) :
n.succ = n + 1
@[simp]
theorem Num.cast_to_nat {α : Type u_1} [AddMonoidWithOne α] (n : Num) :
n = n
theorem Num.add_to_nat (m n : Num) :
↑(m + n) = m + n
theorem Num.mul_to_nat (m n : Num) :
↑(m * n) = m * n
theorem Num.cmp_to_nat (m n : Num) :
Ordering.casesOn (m.cmp n) (m < n) (m = n) (n < m)
theorem Num.lt_to_nat {m n : Num} :
m < n m < n
theorem Num.le_to_nat {m n : Num} :
m n m n
@[simp]
theorem Num.of_to_nat' (n : Num) :
ofNat' n = n
theorem Num.to_nat_inj {m n : Num} :
m = n m = n

This tactic tries to turn an (in)equality about Nums to one about Nats by rewriting.

example (n : Num) (m : Num) : n ≤ n + m := by
  transfer_rw
  exact Nat.le_add_right _ _
Equations
    Instances For

      This tactic tries to prove (in)equalities about Nums by transferring them to the Nat world and then trying to call simp.

      example (n : Num) (m : Num) : n ≤ n + m := by transfer
      
      Equations
        Instances For
          theorem Num.add_of_nat (m n : ) :
          ↑(m + n) = m + n
          theorem Num.to_nat_to_int (n : Num) :
          n = n
          @[simp]
          theorem Num.cast_to_int {α : Type u_1} [AddGroupWithOne α] (n : Num) :
          n = n
          theorem Num.to_of_nat (n : ) :
          n = n
          @[simp]
          theorem Num.of_natCast {α : Type u_1} [AddMonoidWithOne α] (n : ) :
          n = n
          theorem Num.of_nat_inj {m n : } :
          m = n m = n
          @[simp]
          theorem Num.of_to_nat (n : Num) :
          n = n
          theorem Num.dvd_to_nat (m n : Num) :
          m n m n
          @[simp]
          theorem PosNum.of_to_nat (n : PosNum) :
          n = Num.pos n
          theorem PosNum.to_nat_inj {m n : PosNum} :
          m = n m = n
          theorem PosNum.dvd_to_nat {m n : PosNum} :
          m n m n

          This tactic tries to turn an (in)equality about PosNums to one about Nats by rewriting.

          example (n : PosNum) (m : PosNum) : n ≤ n + m := by
            transfer_rw
            exact Nat.le_add_right _ _
          
          Equations
            Instances For

              This tactic tries to prove (in)equalities about PosNums by transferring them to the Nat world and then trying to call simp.

              example (n : PosNum) (m : PosNum) : n ≤ n + m := by transfer
              
              Equations
                Instances For
                  @[simp]
                  theorem PosNum.cast_to_num (n : PosNum) :
                  n = Num.pos n
                  @[simp]
                  theorem PosNum.bit_to_nat (b : Bool) (n : PosNum) :
                  (bit b n) = Nat.bit b n
                  @[simp]
                  theorem PosNum.cast_add {α : Type u_1} [AddMonoidWithOne α] (m n : PosNum) :
                  ↑(m + n) = m + n
                  @[simp]
                  theorem PosNum.cast_succ {α : Type u_1} [AddMonoidWithOne α] (n : PosNum) :
                  n.succ = n + 1
                  @[simp]
                  theorem PosNum.cast_inj {α : Type u_1} [AddMonoidWithOne α] [CharZero α] {m n : PosNum} :
                  m = n m = n
                  @[simp]
                  theorem PosNum.one_le_cast {α : Type u_1} [Semiring α] [PartialOrder α] [IsStrictOrderedRing α] (n : PosNum) :
                  1 n
                  @[simp]
                  theorem PosNum.cast_pos {α : Type u_1} [Semiring α] [PartialOrder α] [IsStrictOrderedRing α] (n : PosNum) :
                  0 < n
                  @[simp]
                  theorem PosNum.cast_mul {α : Type u_1} [NonAssocSemiring α] (m n : PosNum) :
                  ↑(m * n) = m * n
                  @[simp]
                  theorem PosNum.cmp_eq (m n : PosNum) :
                  @[simp]
                  theorem PosNum.cast_lt {α : Type u_1} [Semiring α] [PartialOrder α] [IsStrictOrderedRing α] {m n : PosNum} :
                  m < n m < n
                  @[simp]
                  theorem PosNum.cast_le {α : Type u_1} [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] {m n : PosNum} :
                  m n m n
                  theorem Num.bit_to_nat (b : Bool) (n : Num) :
                  (bit b n) = Nat.bit b n
                  theorem Num.cast_succ' {α : Type u_1} [AddMonoidWithOne α] (n : Num) :
                  n.succ' = n + 1
                  theorem Num.cast_succ {α : Type u_1} [AddMonoidWithOne α] (n : Num) :
                  n.succ = n + 1
                  @[simp]
                  theorem Num.cast_add {α : Type u_1} [AddMonoidWithOne α] (m n : Num) :
                  ↑(m + n) = m + n
                  @[simp]
                  theorem Num.cast_bit0 {α : Type u_1} [NonAssocSemiring α] (n : Num) :
                  n.bit0 = 2 * n
                  @[simp]
                  theorem Num.cast_bit1 {α : Type u_1} [NonAssocSemiring α] (n : Num) :
                  n.bit1 = 2 * n + 1
                  @[simp]
                  theorem Num.cast_mul {α : Type u_1} [NonAssocSemiring α] (m n : Num) :
                  ↑(m * n) = m * n
                  theorem Num.size_to_nat (n : Num) :
                  n.size = (↑n).size
                  @[simp]
                  theorem Num.ofNat'_eq (n : ) :
                  ofNat' n = n
                  @[simp]
                  theorem Num.cast_toZNum {α : Type u_1} [Zero α] [One α] [Add α] [Neg α] (n : Num) :
                  n.toZNum = n
                  @[simp]
                  theorem Num.cast_toZNumNeg {α : Type u_1} [SubtractionMonoid α] [One α] (n : Num) :
                  n.toZNumNeg = -n
                  @[simp]
                  theorem Num.add_toZNum (m n : Num) :
                  (m + n).toZNum = m.toZNum + n.toZNum
                  theorem PosNum.pred_to_nat {n : PosNum} (h : 1 < n) :
                  n.pred = (↑n).pred
                  theorem Num.pred_to_nat (n : Num) :
                  n.pred = (↑n).pred
                  theorem Num.cmp_swap (m n : Num) :
                  (m.cmp n).swap = n.cmp m
                  @[simp]
                  theorem Num.cast_lt {α : Type u_1} [Semiring α] [PartialOrder α] [IsStrictOrderedRing α] {m n : Num} :
                  m < n m < n
                  @[simp]
                  theorem Num.cast_le {α : Type u_1} [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] {m n : Num} :
                  m n m n
                  @[simp]
                  theorem Num.cast_inj {α : Type u_1} [Semiring α] [PartialOrder α] [IsStrictOrderedRing α] {m n : Num} :
                  m = n m = n
                  theorem Num.castNum_eq_bitwise {f : NumNumNum} {g : BoolBoolBool} (p : PosNumPosNumNum) (gff : g false false = false) (f00 : f 0 0 = 0) (f0n : ∀ (n : PosNum), f 0 (pos n) = bif g false true then pos n else 0) (fn0 : ∀ (n : PosNum), f (pos n) 0 = bif g true false then pos n else 0) (fnn : ∀ (m n : PosNum), f (pos m) (pos n) = p m n) (p11 : p 1 1 = bif g true true then 1 else 0) (p1b : ∀ (b : Bool) (n : PosNum), p 1 (PosNum.bit b n) = bit (g true b) (bif g false true then pos n else 0)) (pb1 : ∀ (a : Bool) (m : PosNum), p (PosNum.bit a m) 1 = bit (g a true) (bif g true false then pos m else 0)) (pbb : ∀ (a b : Bool) (m n : PosNum), p (PosNum.bit a m) (PosNum.bit b n) = bit (g a b) (p m n)) (m n : Num) :
                  (f m n) = Nat.bitwise g m n
                  @[simp]
                  theorem Num.castNum_or (m n : Num) :
                  ↑(m ||| n) = m ||| n
                  @[simp]
                  theorem Num.castNum_and (m n : Num) :
                  ↑(m &&& n) = m &&& n
                  @[simp]
                  theorem Num.castNum_ldiff (m n : Num) :
                  (m.ldiff n) = (↑m).ldiff n
                  @[simp]
                  theorem Num.castNum_xor (m n : Num) :
                  ↑(m ^^^ n) = m ^^^ n
                  @[simp]
                  theorem Num.castNum_shiftLeft (m : Num) (n : ) :
                  ↑(m <<< n) = m <<< n
                  @[simp]
                  theorem Num.castNum_shiftRight (m : Num) (n : ) :
                  ↑(m >>> n) = m >>> n
                  @[simp]
                  theorem Num.castNum_testBit (m : Num) (n : ) :
                  m.testBit n = (↑m).testBit n

                  Cast a SNum to the corresponding integer.

                  Equations
                    Instances For
                      instance SNum.lt :
                      Equations
                        instance SNum.le :
                        Equations