Documentation

LeanPool.OrderMaintenance.ArrayLemmas

Total array views #

Generic total-map facts depend only on the state-level array operations. Both functional correctness and RAM encoding reuse them without importing one another.

Arrays as total maps #

@[simp]
theorem OrderMaintenance.Proof.Array.getX_modify {α : Type} [Inhabited α] (a : Array α) (i j : Nat) (f : α → α) :
(a.modify i f).getX j = if i = j ∧ i < a.size then f (a.getX j) else a.getX j
theorem OrderMaintenance.Proof.Array.size_modify' {α : Type} (a : Array α) (i : Nat) (f : α → α) :
(a.modify i f).size = a.size
@[simp]
theorem OrderMaintenance.Proof.Array.getX_push {α : Type} [Inhabited α] (a : Array α) (v : α) (j : Nat) :
(a.push v).getX j = if j = a.size then v else a.getX j
theorem OrderMaintenance.Proof.Array.getX_set! {α : Type} [Inhabited α] (a : Array α) (i j : Nat) (v : α) :
(a.set! i v).getX j = if i = j ∧ i < a.size then v else a.getX j
@[simp]
theorem OrderMaintenance.Proof.Array.getX_setIfInBounds {α : Type} [Inhabited α] (a : Array α) (i j : Nat) (v : α) :
(a.setIfInBounds i v).getX j = if i = j ∧ i < a.size then v else a.getX j
theorem OrderMaintenance.Proof.Array.size_set!' {α : Type} (a : Array α) (i : Nat) (v : α) :
(a.set! i v).size = a.size
@[simp]
theorem OrderMaintenance.Proof.Array.getX_ite {α : Type} [Inhabited α] {c : Prop} [Decidable c] (a b : Array α) (i : Nat) :
(if c then a else b).getX i = if c then a.getX i else b.getX i
@[simp]
theorem OrderMaintenance.Proof.Array.size_ite {α : Type} {c : Prop} [Decidable c] (a b : Array α) :
(if c then a else b).size = if c then a.size else b.size
theorem OrderMaintenance.Proof.Array.getX_ge {α : Type} [Inhabited α] (a : Array α) {j : Nat} (h : a.size ≤ j) :
theorem OrderMaintenance.Proof.Array.getX_setX {α : Type} [Inhabited α] (a : Array α) (i j : Nat) (v : α) :
(a.setX i v).getX j = if j = i then v else a.getX j
theorem OrderMaintenance.Proof.Array.size_setX {α : Type} [Inhabited α] (a : Array α) (i : Nat) (v : α) :
(a.setX i v).size = if i < a.size then a.size else i + 1

Updating a total array grows it exactly far enough to contain the updated index.

theorem OrderMaintenance.Proof.Top.getX_push' {α : Type} [Inhabited α] (a : Array α) (x : α) (i : Nat) :
(a.push x).getX i = if i = a.size then x else a.getX i
theorem OrderMaintenance.Proof.Top.size_setX' {α : Type} [Inhabited α] (a : Array α) (i : Nat) (v : α) :
(a.setX i v).size = max a.size (i + 1)
theorem OrderMaintenance.Proof.Top.getX_setX' {α : Type} [Inhabited α] (a : Array α) (i : Nat) (v : α) (j : Nat) :
(a.setX i v).getX j = if j = i then v else a.getX j
theorem OrderMaintenance.Proof.Top.getX_modify' {α : Type} [Inhabited α] (a : Array α) (f : α → α) (i j : Nat) :
(a.modify i f).getX j = if j = i ∧ i < a.size then f (a.getX j) else a.getX j