Documentation

Projects.Util.BitVec

def BitVec.ofBit (w : ) (b : Bit) :
Equations
Instances For
    def BitVec.lowestBit {w : } (x : BitVec w) :
    Equations
    Instances For
      def BitVec.ofBits (w : ) (bs : List Bit) :
      Equations
      Instances For
        def BitVec.toBits {w : } (x : BitVec w) :
        Equations
        Instances For
          @[simp]
          theorem BitVec.ofNatLT_eq_ofNatLT_iff {w n m : } {hn : n < 2 ^ w} {hm : m < 2 ^ w} :
          n#'hn = m#'hm n = m
          @[simp]
          @[simp]
          @[simp]
          @[simp]
          theorem BitVec.ofBits_nil {w : } :
          ofBits w [] = 0#w
          @[simp]
          theorem BitVec.ofBit_zero {w : } :
          ofBit w 0 = 0
          @[simp]
          theorem BitVec.ofBit_one {w : } :
          ofBit w 1 = 1
          @[simp]
          theorem BitVec.toBits_cons {w : } {x : BitVec w} {b : Bool} :
          theorem BitVec.shiftLeft_one_eq_mul_two {w : } {x : BitVec w} :
          x <<< 1 = x * 2
          theorem BitVec.mul_two_or_one_eq {w : } {x : BitVec w} :
          x * 2 ||| 1 = x * 2 + 1
          theorem BitVec.foldr_eq_add_ofBits {w : } {bs : List Bit} {z : BitVec w} :
          List.foldr (fun (bit : Bit) (x : BitVec w) => x <<< 1 ||| ofBit w bit) z bs = z <<< bs.length + ofBits w bs
          theorem BitVec.ofBits_snoc_eq_add_ofBits {w : } {bs : List Bit} {b : Bit} :
          ofBits w (bs ++ [b]) = ofBit w b <<< bs.length + ofBits w bs
          @[simp]
          theorem BitVec.getElem_zero_ofBit {w : } {b : Bit} {h : 0 < w} :
          (ofBit w b)[0] = b.toBool
          @[simp]
          theorem BitVec.getElem_succ_ofBit {w i : } {b : Bit} {h : i + 1 < w} :
          (ofBit w b)[i + 1] = false
          @[simp]
          theorem BitVec.getElem_ofBits {w : } {bs : List Bit} {i : } {h : i < w} :
          (ofBits w bs)[i] = bs[i]!.toBool
          theorem BitVec.foldr_eq_or_ofBits {w : } {bs : List Bit} {z : BitVec w} :
          List.foldr (fun (bit : Bit) (x : BitVec w) => x <<< 1 ||| ofBit w bit) z bs = z <<< bs.length ||| ofBits w bs
          theorem BitVec.ofBits_snoc_eq_or_ofBits {w : } {bs : List Bit} {b : Bit} :
          ofBits w (bs ++ [b]) = ofBit w b <<< bs.length ||| ofBits w bs
          @[simp]
          theorem BitVec.length_toBits {w : } {x : BitVec w} :
          theorem BitVec.odd_shiftRight_toNat_iff {w : } {x : BitVec w} {i : } :
          Odd (x.toNat >>> i) ∃ (h : i < w), x[i] = true
          theorem BitVec.lowestBit_shiftRight {w : } {x : BitVec w} {i : } :
          (x >>> i).lowestBit = if h : i < w then Bit.ofBool x[i] else 0
          theorem BitVec.toBits_eq_map_getElem {w : } {x : BitVec w} :
          x.toBits = List.map (fun (x_1 : { x : // x List.range w }) => match x_1 with | i, h => Bit.ofBool x[i]) (List.range w).attach
          @[simp]
          theorem BitVec.getElem_cons_last {w : } {x : BitVec w} {b : Bool} {h : w < w + 1} :
          (cons b x)[w] = b
          @[simp]
          theorem BitVec.ofBits_toBits {w : } {x : BitVec w} :
          @[simp]
          theorem BitVec.toBits_eq_iff {w : } {x y : BitVec w} :
          x.toBits = y.toBits x = y
          @[simp]
          theorem BitVec.w_zero_eq {x : BitVec 0} :
          x = 0#0
          theorem BitVec.toBits_ofBits {w : } {bs : List Bit} :
          theorem BitVec.toBits_ofBits_of_length_eq {w : } {bs : List Bit} (h : bs.length = w) :
          (ofBits w bs).toBits = bs
          theorem BitVec.toBits_ofBits_of_length_le {w : } {bs : List Bit} (h : bs.length w) :
          (ofBits w bs).toBits = bs ++ List.replicate (w - bs.length) 0
          theorem BitVec.toBits_ofBits_of_le_length {w : } {bs : List Bit} (h : w bs.length) :
          (ofBits w bs).toBits = List.take w bs
          @[simp]
          theorem BitVec.toBits_eq_nil_iff {w : } {x : BitVec w} :
          x.toBits = [] w = 0
          @[simp]
          theorem BitVec.ofBits_singleton {w : } {b : Bit} :
          ofBits w [b] = ofBit w b
          @[instance_reducible]
          Equations
          @[simp]
          theorem BitVec.ofBits_snoc {w : } {bs : List Bit} {b : Bit} :
          ofBits w (bs ++ [b]) = ofBits w bs ||| ofBit w b <<< bs.length
          @[simp]
          theorem BitVec.ofNat_eq_ofNat_iff {w n k : } :
          BitVec.ofNat w n = BitVec.ofNat w k w = 0 n % 2 ^ w = k % 2 ^ w
          @[simp]
          theorem BitVec.ofNat_eq_one_iff {w n : } :
          BitVec.ofNat w n = 1#w w = 0 n % 2 ^ w = 1
          theorem BitVec.ext_iff {w : } {x y : BitVec w} :
          x = y x.toNat = y.toNat
          @[simp]
          theorem BitVec.one_shiftLeft_eq_zero_iff {w n : } :
          1#w <<< n = 0#w w = 0 w n
          @[simp]
          theorem BitVec.one_shiftLeft_eq_one_iff {w n : } :
          1#w <<< n = 1#w w = 0 n = 0
          @[simp]
          theorem BitVec.le_size_pow {w : } {x : BitVec w} :
          x BitVec.ofNat w (2 ^ w - 1)
          @[simp]
          theorem BitVec.toNat_lt_size_pow {w : } {x : BitVec w} :
          x.toNat < 2 ^ w
          @[simp]
          theorem BitVec.toNat_ofBits_lt_pow {w : } {bs : List Bit} :
          (ofBits w bs).toNat < 2 ^ bs.length
          theorem BitVec.or_shiftLeft_eq_add {w : } {x y : BitVec w} {n : } (h : x.toNat < 2 ^ n) :
          x ||| y <<< n = x + y <<< n
          @[simp]
          theorem BitVec.ofBits_append_eq_or {w : } {bs₁ bs₂ : List Bit} :
          ofBits w (bs₁ ++ bs₂) = ofBits w bs₁ ||| ofBits w bs₂ <<< bs₁.length
          theorem BitVec.ofBits_append_eq_add {w : } {bs₁ bs₂ : List Bit} :
          ofBits w (bs₁ ++ bs₂) = ofBits w bs₁ + ofBits w bs₂ <<< bs₁.length
          @[simp]
          theorem BitVec.toNat_le_size_pow {w : } {x : BitVec w} :
          x.toNat 2 ^ w
          theorem BitVec.toNat_ofBit {w : } {b : Bit} :
          (ofBit w b).toNat = if w 0 b = 1 then 1 else 0