Documentation

CslibFrontier.Foundations.Data.Array.SetGrow

Arrays as finite maps with defaults #

Compiled checkers keep finite maps from numbers to values in arrays indexed by the number, reading past the end as a default. Array.setGrow writes an entry, first padding the array with the default up to its index.

Main definitions #

Main results #

def Array.setGrow {α : Type u_1} (a : Array α) (i : ℕ) (d x : α) :

Write x at index i, first padding the array with d up to i if it is too short. A write just past the end is a plain push, which allocates no padding. Exposed, so that the kernel evaluates its callers.

theorem Array.getD_setGrow {α : Type u_1} (a : Array α) (i j : ℕ) (d x : α) :
(a.setGrow i d x).getD j d = if j = i then x else a.getD j d
theorem Array.getD_setIfInBounds_self {α : Type u_1} (a : Array α) (i j : ℕ) (d : α) :
(a.setIfInBounds i d).getD j d = if j = i then d else a.getD j d
theorem Array.size_le_size_setGrow {α : Type u_1} (a : Array α) (i : ℕ) (d x : α) :
a.size ≤ (a.setGrow i d x).size
theorem Array.lt_size_setGrow {α : Type u_1} (a : Array α) (i : ℕ) (d x : α) :
i < (a.setGrow i d x).size