Documentation

Batteries.Data.ByteArray

theorem ByteArray.ext_iff {a : ByteArray} {b : ByteArray} :
a = b a.data = b.data
theorem ByteArray.ext {a : ByteArray} {b : ByteArray} :
a.data = b.dataa = b
theorem ByteArray.getElem_eq_data_getElem {i : Nat} (a : ByteArray) (h : i < a.size) :
a[i] = a.data[i]

uget/uset #

@[simp]
theorem ByteArray.uset_eq_set (a : ByteArray) {i : USize} (h : i.toNat < a.size) (v : UInt8) :
a.uset i v h = a.set i.toNat, h v

empty #

@[simp]
theorem ByteArray.data_mkEmpty (cap : Nat) :
(ByteArray.mkEmpty cap).data = #[]
@[deprecated ByteArray.data_mkEmpty]
theorem ByteArray.mkEmpty_data (cap : Nat) :
(ByteArray.mkEmpty cap).data = #[]

Alias of ByteArray.data_mkEmpty.

@[simp]
@[deprecated ByteArray.data_empty]

Alias of ByteArray.data_empty.

push #

@[simp]
theorem ByteArray.data_push (a : ByteArray) (b : UInt8) :
(a.push b).data = a.data.push b
@[deprecated ByteArray.data_push]
theorem ByteArray.push_data (a : ByteArray) (b : UInt8) :
(a.push b).data = a.data.push b

Alias of ByteArray.data_push.

@[simp]
theorem ByteArray.size_push (a : ByteArray) (b : UInt8) :
(a.push b).size = a.size + 1
@[simp]
theorem ByteArray.get_push_eq (a : ByteArray) (x : UInt8) :
(a.push x)[a.size] = x
theorem ByteArray.get_push_lt (a : ByteArray) (x : UInt8) (i : Nat) (h : i < a.size) :
(a.push x)[i] = a[i]

set #

@[simp]
theorem ByteArray.data_set (a : ByteArray) (i : Fin a.size) (v : UInt8) :
(a.set i v).data = a.data.set i v
@[deprecated ByteArray.data_set]
theorem ByteArray.set_data (a : ByteArray) (i : Fin a.size) (v : UInt8) :
(a.set i v).data = a.data.set i v

Alias of ByteArray.data_set.

@[simp]
theorem ByteArray.size_set (a : ByteArray) (i : Fin a.size) (v : UInt8) :
(a.set i v).size = a.size
@[simp]
theorem ByteArray.get_set_eq (a : ByteArray) (i : Fin a.size) (v : UInt8) :
(a.set i v)[i] = v
theorem ByteArray.get_set_ne {j : Nat} (a : ByteArray) (i : Fin a.size) (v : UInt8) (hj : j < a.size) (h : i j) :
(a.set i v)[j] = a[j]
theorem ByteArray.set_set (a : ByteArray) (i : Fin a.size) (v : UInt8) (v' : UInt8) :
(a.set i v).set i, v' = a.set i v'

copySlice #

@[simp]
theorem ByteArray.data_copySlice (a : ByteArray) (i : Nat) (b : ByteArray) (j : Nat) (len : Nat) (exact : Bool) :
(a.copySlice i b j len exact).data = b.data.extract 0 j ++ a.data.extract i (i + len) ++ b.data.extract (j + min len (a.data.size - i)) b.data.size
@[deprecated ByteArray.data_copySlice]
theorem ByteArray.copySlice_data (a : ByteArray) (i : Nat) (b : ByteArray) (j : Nat) (len : Nat) (exact : Bool) :
(a.copySlice i b j len exact).data = b.data.extract 0 j ++ a.data.extract i (i + len) ++ b.data.extract (j + min len (a.data.size - i)) b.data.size

Alias of ByteArray.data_copySlice.

append #

@[simp]
theorem ByteArray.append_eq (a : ByteArray) (b : ByteArray) :
a.append b = a ++ b
@[simp]
theorem ByteArray.data_append (a : ByteArray) (b : ByteArray) :
(a ++ b).data = a.data ++ b.data
@[deprecated ByteArray.data_append]
theorem ByteArray.append_data (a : ByteArray) (b : ByteArray) :
(a ++ b).data = a.data ++ b.data

Alias of ByteArray.data_append.

theorem ByteArray.size_append (a : ByteArray) (b : ByteArray) :
(a ++ b).size = a.size + b.size
theorem ByteArray.get_append_left {i : Nat} {a : ByteArray} {b : ByteArray} (hlt : i < a.size) (h : optParam (i < (a ++ b).size) ) :
(a ++ b)[i] = a[i]
theorem ByteArray.get_append_right {i : Nat} {a : ByteArray} {b : ByteArray} (hle : a.size i) (h : i < (a ++ b).size) (h' : optParam (i - a.size < b.size) ) :
(a ++ b)[i] = b[i - a.size]

extract #

@[simp]
theorem ByteArray.data_extract (a : ByteArray) (start : Nat) (stop : Nat) :
(a.extract start stop).data = a.data.extract start stop
@[deprecated ByteArray.data_extract]
theorem ByteArray.extract_data (a : ByteArray) (start : Nat) (stop : Nat) :
(a.extract start stop).data = a.data.extract start stop

Alias of ByteArray.data_extract.

@[simp]
theorem ByteArray.size_extract (a : ByteArray) (start : Nat) (stop : Nat) :
(a.extract start stop).size = min stop a.size - start
theorem ByteArray.get_extract_aux {i : Nat} {a : ByteArray} {start : Nat} {stop : Nat} (h : i < (a.extract start stop).size) :
start + i < a.size
@[simp]
theorem ByteArray.get_extract {i : Nat} {a : ByteArray} {start : Nat} {stop : Nat} (h : i < (a.extract start stop).size) :
(a.extract start stop)[i] = a[start + i]

ofFn #

def ByteArray.ofFn {n : Nat} (f : Fin nUInt8) :
  • ofFn f with f : Fin n → UInt8 returns the byte array whose ith element is f i. -
Equations
Instances For
    @[simp]
    theorem ByteArray.data_ofFn {n : Nat} (f : Fin nUInt8) :
    @[deprecated ByteArray.data_ofFn]
    theorem ByteArray.ofFn_data {n : Nat} (f : Fin nUInt8) :

    Alias of ByteArray.data_ofFn.

    @[simp]
    theorem ByteArray.size_ofFn {n : Nat} (f : Fin nUInt8) :
    (ByteArray.ofFn f).size = n
    @[simp]
    theorem ByteArray.get_ofFn {n : Nat} (f : Fin nUInt8) (i : Fin (ByteArray.ofFn f).size) :
    (ByteArray.ofFn f).get i = f (Fin.cast i)
    @[simp]
    theorem ByteArray.getElem_ofFn {n : Nat} (f : Fin nUInt8) (i : Nat) (h : i < (ByteArray.ofFn f).size) :
    (ByteArray.ofFn f)[i] = f i,

    map/mapM #

    @[inline]
    unsafe def ByteArray.mapMUnsafe {m : TypeType u_1} [Monad m] (a : ByteArray) (f : UInt8m UInt8) :

    Unsafe optimized implementation of mapM.

    This function is unsafe because it relies on the implementation limit that the size of an array is always less than USize.size.

    Instances For
      @[specialize #[]]
      unsafe def ByteArray.mapMUnsafe.loop {m : TypeType u_1} [Monad m] (f : UInt8m UInt8) (a : ByteArray) (k : USize) (s : USize) :

      Inner loop for mapMUnsafe.

      Instances For
        @[implemented_by ByteArray.mapMUnsafe]
        def ByteArray.mapM {m : TypeType u_1} [Monad m] (a : ByteArray) (f : UInt8m UInt8) :

        mapM f a applies the monadic function f to each element of the array.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[inline]

          map f a applies the function f to each element of the array.

          Equations
          • a.map f = a.mapM f
          Instances For