mapFinIdx #
theorem
Array.mapFinIdx_induction.go
{α : Type u_1}
{β : Type u_2}
(as : Array α)
(f : Fin as.size → α → β)
(motive : Nat → Prop)
(p : Fin as.size → β → Prop)
(hs : ∀ (i : Fin as.size), motive ↑i → p i (f i as[i]) ∧ motive (↑i + 1))
{bs : Array β}
{i j : Nat}
{h : i + j = as.size}
(h₁ : j = bs.size)
(h₂ : ∀ (i : Nat) (h : i < as.size) (h' : i < bs.size), p ⟨i, h⟩ bs[i])
(hm : motive j)
:
let arr := Array.mapFinIdxM.map as f i j h bs;
motive as.size ∧ ∃ (eq : arr.size = as.size), ∀ (i_1 : Nat) (h : i_1 < as.size), p ⟨i_1, h⟩ arr[i_1]
@[simp]
mapIdx #
theorem
Array.mapIdx_induction
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
(motive : Nat → Prop)
(h0 : motive 0)
(p : Fin as.size → β → Prop)
(hs : ∀ (i : Fin as.size), motive ↑i → p i (f (↑i) as[i]) ∧ motive (↑i + 1))
:
motive as.size ∧ ∃ (eq : (Array.mapIdx f as).size = as.size), ∀ (i : Nat) (h : i < as.size), p ⟨i, h⟩ (Array.mapIdx f as)[i]
theorem
Array.mapIdx_spec
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
(p : Fin as.size → β → Prop)
(hs : ∀ (i : Fin as.size), p i (f (↑i) as[i]))
:
∃ (eq : (Array.mapIdx f as).size = as.size), ∀ (i : Nat) (h : i < as.size), p ⟨i, h⟩ (Array.mapIdx f as)[i]
@[simp]
theorem
Array.size_mapIdx
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
:
(Array.mapIdx f as).size = as.size
@[simp]
theorem
Array.getElem_mapIdx
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
(i : Nat)
(h : i < (Array.mapIdx f as).size)
:
(Array.mapIdx f as)[i] = f i as[i]
@[simp]
theorem
Array.getElem?_mapIdx
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
(i : Nat)
:
(Array.mapIdx f as)[i]? = Option.map (f i) as[i]?
@[simp]
theorem
Array.toList_mapIdx
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(as : Array α)
:
(Array.mapIdx f as).toList = List.mapIdx (fun (i : Nat) (a : α) => f i a) as.toList
@[simp]
theorem
List.mapIdx_toArray
{α : Type u_1}
{β : Type u_2}
(f : Nat → α → β)
(l : List α)
:
Array.mapIdx f l.toArray = (List.mapIdx f l).toArray