Documentation

ScalarArray.Int32.Lemmas

Lemmas about Int32Array #

Lemmas about arrays and slices, stated in terms of the model Array Int32 and List Int32.

Arrays #

@[simp]
theorem ScalarArray.Int32Array.size_uset (a : Int32Array) (i : USize) (v : Int32) (h : i.toNat < a.size) :
(a.uset i v h).size = a.size
@[simp]
theorem ScalarArray.Int32Array.size_set (a : Int32Array) (i : Nat) (v : Int32) (h : i < a.size) :
(a.set i v h).size = a.size
@[simp]
@[simp]
theorem ScalarArray.Int32Array.getElem_mk (a : Array Int32) (i : Nat) (h : i < (mk a).size) :
(mk a)[i] = a[i]
theorem ScalarArray.Int32Array.ext_getElem {a b : Int32Array} (h₁ : a.size = b.size) (h₂ : ∀ (i : Nat) (hi₁ : i < a.size) (hi₂ : i < b.size), a[i] = b[i]) :
a = b
@[simp]
theorem ScalarArray.Int32Array.toArray_uset (a : Int32Array) (i : USize) (v : Int32) (h : i.toNat < a.size) :
(a.uset i v h).toArray = a.toArray.set i.toNat v ⋯
@[simp]
theorem ScalarArray.Int32Array.toArray_set (a : Int32Array) (i : Nat) (v : Int32) (h : i < a.size) :
(a.set i v h).toArray = a.toArray.set i v ⋯
@[simp]
theorem ScalarArray.Int32Array.toArray_extract (a : Int32Array) (start stop : Nat) :
(a.extract start stop).toArray = a.toArray.extract start stop
@[simp]
theorem ScalarArray.Int32Array.size_extract (a : Int32Array) (start stop : Nat) :
(a.extract start stop).size = min stop a.size - start
@[simp]
theorem ScalarArray.Int32Array.size_ofFn {n : Nat} (f : Fin n → Int32) :
(ofFn f).size = n
@[simp]
theorem ScalarArray.Int32Array.getElem_set (a : Int32Array) (i : Nat) (v : Int32) (h : i < a.size) (j : Nat) (hj : j < (a.set i v h).size) :
(a.set i v h)[j] = if i = j then v else a[j]
@[simp]
theorem ScalarArray.Int32Array.getElem_push (a : Int32Array) (v : Int32) (i : Nat) (h : i < (a.push v).size) :
(a.push v)[i] = if h' : i < a.size then a[i] else v
@[simp]
theorem ScalarArray.Int32Array.getElem_pop (a : Int32Array) (i : Nat) (h : i < a.pop.size) :
a.pop[i] = a[i]
@[simp]
theorem ScalarArray.Int32Array.getElem_append (a b : Int32Array) (i : Nat) (h : i < (a ++ b).size) :
(a ++ b)[i] = if h' : i < a.size then a[i] else b[i - a.size]
@[simp]
theorem ScalarArray.Int32Array.getElem_extract (a : Int32Array) (start stop i : Nat) (h : i < (a.extract start stop).size) :
(a.extract start stop)[i] = a[start + i]
@[simp]
theorem ScalarArray.Int32Array.getElem_replicate (n : Nat) (v : Int32) (i : Nat) (h : i < (replicate n v).size) :
(replicate n v)[i] = v
@[simp]
theorem ScalarArray.Int32Array.getElem_ofFn {n : Nat} (f : Fin n → Int32) (i : Nat) (h : i < (ofFn f).size) :
(ofFn f)[i] = f ⟨i, ⋯⟩
theorem ScalarArray.Int32Array.foldl_eq_foldl_toArray {β : Type v} (f : β → Int32 → β) (init : β) (a : Int32Array) :
foldl f init a = Array.foldl f init a.toArray
theorem ScalarArray.Int32Array.foldr_eq_foldr_toArray {β : Type v} (f : Int32 → β → β) (init : β) (a : Int32Array) :
foldr f init a = Array.foldr f init a.toArray
@[simp]
@[simp]
theorem ScalarArray.Int32Array.size_set! (a : Int32Array) (i : Nat) (v : Int32) :
(a.set! i v).size = a.size
@[simp]
theorem ScalarArray.Int32Array.getElem_ofList (l : List Int32) (i : Nat) (h : i < (ofList l).size) :
(ofList l)[i] = l[i]
@[simp]
theorem ScalarArray.Int32Array.getElem_append_left {a b : Int32Array} {i : Nat} (h : i < a.size) :
(a ++ b)[i] = a[i]
theorem ScalarArray.Int32Array.getElem_append_right {a b : Int32Array} {i : Nat} (h : a.size ≤ i) (h' : i < (a ++ b).size) :
(a ++ b)[i] = b[i - a.size]
theorem ScalarArray.Int32Array.extract_extract (a : Int32Array) (i j k l : Nat) :
(a.extract i j).extract k l = a.extract (i + k) (min (i + l) j)
@[simp]
theorem ScalarArray.Int32Array.toArray_copySlice (src : Int32Array) (srcOff : Nat) (dest : Int32Array) (destOff len : Nat) (exact : Bool) :
(src.copySlice srcOff dest destOff len exact).toArray = dest.toArray.extract 0 destOff ++ src.toArray.extract srcOff (srcOff + len) ++ dest.toArray.extract (destOff + min len (src.size - srcOff)) dest.size
theorem ScalarArray.Int32Array.copySlice_eq_append (src : Int32Array) (srcOff : Nat) (dest : Int32Array) (destOff len : Nat) (exact : Bool) :
src.copySlice srcOff dest destOff len exact = dest.extract 0 destOff ++ src.extract srcOff (srcOff + len) ++ dest.extract (destOff + min len (src.size - srcOff)) dest.size

Lists #

theorem ScalarArray.Int32Array.ext_getElem? {a b : Int32Array} (h : ∀ (i : Nat), a[i]? = b[i]?) :
a = b
@[simp]
theorem ScalarArray.Int32Array.toList_set (a : Int32Array) (i : Nat) (v : Int32) (h : i < a.size) :
(a.set i v h).toList = a.toList.set i v
@[simp]
theorem ScalarArray.Int32Array.toList_set! (a : Int32Array) (i : Nat) (v : Int32) :
(a.set! i v).toList = a.toList.set i v
@[simp]
theorem ScalarArray.Int32Array.toList_extract (a : Int32Array) (start stop : Nat) :
(a.extract start stop).toList = a.toList.extract start stop
@[simp]
theorem ScalarArray.Int32Array.toList_uset (a : Int32Array) (i : USize) (v : Int32) (h : i.toNat < a.size) :
(a.uset i v h).toList = a.toList.set i.toNat v
@[simp]
theorem ScalarArray.Int32Array.toList_copySlice (src : Int32Array) (srcOff : Nat) (dest : Int32Array) (destOff len : Nat) (exact : Bool) :
(src.copySlice srcOff dest destOff len exact).toList = dest.toList.extract 0 destOff ++ src.toList.extract srcOff (srcOff + len) ++ dest.toList.extract (destOff + min len (src.size - srcOff)) dest.size

Accessors #

@[simp]
theorem ScalarArray.Int32Array.get_eq_getElem (a : Int32Array) (i : Nat) (h : i < a.size) :
a.get i h = a[i]
@[simp]
@[simp]
theorem ScalarArray.Int32Array.getD_eq_getD_getElem? (a : Int32Array) (i : Nat) (v₀ : Int32) :
a.getD i v₀ = a[i]?.getD v₀

Last element #

@[simp]
theorem ScalarArray.Int32Array.back_push (a : Int32Array) (v : Int32) (h : 0 < (a.push v).size) :
(a.push v).back h = v

Writes #

@[simp]
theorem ScalarArray.Int32Array.getElem_uset (a : Int32Array) (i : USize) (v : Int32) (h : i.toNat < a.size) (j : Nat) (hj : j < (a.uset i v h).size) :
(a.uset i v h)[j] = if i.toNat = j then v else a[j]
@[simp]
theorem ScalarArray.Int32Array.getElem_set! (a : Int32Array) (i : Nat) (v : Int32) (j : Nat) (hj : j < (a.set! i v).size) :
(a.set! i v)[j] = if i = j then v else a[j]
@[simp]
theorem ScalarArray.Int32Array.getElem?_set! (a : Int32Array) (i : Nat) (v : Int32) (j : Nat) :
(a.set! i v)[j]? = if i = j then if i < a.size then some v else none else a[j]?
@[simp]
theorem ScalarArray.Int32Array.size_copySlice (src : Int32Array) (srcOff : Nat) (dest : Int32Array) (destOff len : Nat) (exact : Bool) :
(src.copySlice srcOff dest destOff len exact).size = max dest.size (min destOff dest.size + min len (src.size - srcOff))
theorem ScalarArray.Int32Array.getElem_copySlice (src : Int32Array) (srcOff : Nat) (dest : Int32Array) (destOff len : Nat) (exact : Bool) (i : Nat) (h : i < (src.copySlice srcOff dest destOff len exact).size) :
(src.copySlice srcOff dest destOff len exact)[i] = if h₁ : i < min destOff dest.size then dest[i] else if h₂ : i - min destOff dest.size < min len (src.size - srcOff) then src[srcOff + (i - min destOff dest.size)] else dest[i]

Machine-word indices #

usize is the size when the size fits in a USize, which holds for every array in memory. Loops over USize indices take this as a hypothesis, since the model Array has no bound on its size.

The guard i < a.usize of a loop over USize indices bounds the index.

Folds and queries #

@[simp]
theorem ScalarArray.Int32Array.foldl_toList {β : Type v} (f : β → Int32 → β) (init : β) (a : Int32Array) :
List.foldl f init a.toList = foldl f init a
@[simp]
theorem ScalarArray.Int32Array.foldr_toList {β : Type v} (f : Int32 → β → β) (init : β) (a : Int32Array) :
List.foldr f init a.toList = foldr f init a
@[simp]
theorem ScalarArray.Int32Array.forIn_toList {β : Type v} {m : Type v → Type w} [Monad m] [LawfulMonad m] (a : Int32Array) (init : β) (f : Int32 → β → m (ForInStep β)) :
ForIn.forIn a.toList init f = ForIn.forIn a init f
theorem ScalarArray.Int32Array.findIdx?_eq (a : Int32Array) (p : Int32 → Bool) (start : Nat) :
a.findIdx? p start = Option.map (fun (x : Nat) => x + start) (List.findIdx? p (List.drop start a.toList))
@[simp]
@[simp]
theorem ScalarArray.Int32Array.foldlM_toList {β : Type v} {m : Type v → Type w} [Monad m] (f : β → Int32 → m β) (init : β) (a : Int32Array) :
List.foldlM f init a.toList = foldlM f init a
@[simp]
theorem ScalarArray.Int32Array.foldrM_toList {β : Type v} {m : Type v → Type w} [Monad m] (f : Int32 → β → m β) (init : β) (a : Int32Array) :
List.foldrM f init a.toList = foldrM f init a
@[simp]
theorem ScalarArray.Int32Array.forM_eq_forM {m : Type v → Type w} [Monad m] (f : Int32 → m PUnit) (a : Int32Array) :
forM f a = ForM.forM a f
@[simp]
theorem ScalarArray.Int32Array.forM_toList {m : Type v → Type w} [Monad m] (f : Int32 → m PUnit) (a : Int32Array) :

Membership #

@[simp]
theorem ScalarArray.Int32Array.mem_mk {x : Int32} {xs : Array Int32} :
x ∈ mk xs ↔ x ∈ xs
@[simp]
theorem ScalarArray.Int32Array.mem_push {x v : Int32} {a : Int32Array} :
x ∈ a.push v ↔ x ∈ a ∨ x = v
@[simp]
theorem ScalarArray.Int32Array.mem_append {x : Int32} {a b : Int32Array} :
x ∈ a ++ b ↔ x ∈ a ∨ x ∈ b

Collecting iterators #

Slices #

@[simp]
theorem ScalarArray.Int32Array.copy_toSlice (a : Int32Array) (start stop : Nat) :
(a.toSlice start stop).copy = a.extract start stop

Copying the slice from start to stop is the same as extracting those elements.

@[simp]
theorem ScalarArray.Int32Array.array_toSlice (a : Int32Array) (start stop : Nat) :
(a.toSlice start stop).array = a
@[simp]
theorem ScalarArray.Int32Array.start_toSlice (a : Int32Array) (start stop : Nat) :
(a.toSlice start stop).start = min start (min stop a.size)
@[simp]
theorem ScalarArray.Int32Array.stop_toSlice (a : Int32Array) (start stop : Nat) :
(a.toSlice start stop).stop = min stop a.size
@[simp]
theorem ScalarArray.Int32Array.size_toSlice (a : Int32Array) (start stop : Nat) :
Std.Slice.size (a.toSlice start stop) = min stop a.size - start
@[simp]
theorem ScalarArray.Int32Array.getElem_toSlice (a : Int32Array) (start stop i : Nat) (h : i < Std.Slice.size (a.toSlice start stop)) :
(a.toSlice start stop)[i] = a[start + i]
@[simp]
theorem ScalarArray.Int32Array.Slice.size_slice (s : Int32Array.Slice) (start stop : Nat) :
Std.Slice.size (s.slice start stop) = min stop (Std.Slice.size s) - start
@[simp]
theorem ScalarArray.Int32Array.Slice.getElem_slice (s : Int32Array.Slice) (start stop i : Nat) (h : i < Std.Slice.size (s.slice start stop)) :
(s.slice start stop)[i] = s[start + i]
@[simp]
theorem ScalarArray.Int32Array.Slice.copy_slice (s : Int32Array.Slice) (start stop : Nat) :
(s.slice start stop).copy = s.copy.extract start stop
theorem ScalarArray.Int32Array.Slice.getD_eq (s : Int32Array.Slice) (i : Nat) (v₀ : Int32) :
s.getD i v₀ = if h : i < Std.Slice.size s then s[i] else v₀
theorem ScalarArray.Int32Array.Slice.foldr_eq_foldr_toList_copy {β : Type v} (f : Int32 → β → β) (init : β) (s : Int32Array.Slice) :
foldr f init s = List.foldr f init s.copy.toList

Folding over a slice is folding over the list of its elements.

Slices as copies #

@[simp]
theorem ScalarArray.Int32Array.Slice.foldl_eq_foldl_copy {β : Type v} (f : β → Int32 → β) (init : β) (s : Int32Array.Slice) :
Std.Slice.foldl f init s = foldl f init s.copy
@[simp]
theorem ScalarArray.Int32Array.Slice.foldlM_eq_foldlM_copy {β : Type v} {m : Type v → Type w} [Monad m] [LawfulMonad m] (f : β → Int32 → m β) (init : β) (s : Int32Array.Slice) :
Std.Slice.foldlM f init s = foldlM f init s.copy
@[simp]
theorem ScalarArray.Int32Array.Slice.forIn_eq_forIn_copy {β : Type v} {m : Type v → Type w} [Monad m] [LawfulMonad m] (s : Int32Array.Slice) (init : β) (f : Int32 → β → m (ForInStep β)) :
ForIn.forIn s init f = ForIn.forIn s.copy init f
@[simp]
theorem ScalarArray.Int32Array.Slice.foldr_eq_foldr_copy {β : Type v} (f : Int32 → β → β) (init : β) (s : Int32Array.Slice) :
foldr f init s = Int32Array.foldr f init s.copy
@[simp]
theorem ScalarArray.Int32Array.Slice.foldrM_eq_foldrM_copy {β : Type v} {m : Type v → Type w} [Monad m] [LawfulMonad m] (f : Int32 → β → m β) (init : β) (s : Int32Array.Slice) :
foldrM f init s = Int32Array.foldrM f init s.copy

Membership in slices #

Slice equality #