Skip to content

Commit

Permalink
Feat: Port/data.vector.basic (#1633)
Browse files Browse the repository at this point in the history
Port of data.vector.basic

Does a realignment of `Vector` functions to mirror the `List` equivalents, particularly for `nth` which has been replaced by `get`
  • Loading branch information
arienmalec committed Jan 19, 2023
1 parent 438cdc8 commit d933809
Show file tree
Hide file tree
Showing 3 changed files with 755 additions and 3 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Expand Up @@ -463,6 +463,7 @@ import Mathlib.Data.UInt
import Mathlib.Data.ULift
import Mathlib.Data.UnionFind
import Mathlib.Data.Vector
import Mathlib.Data.Vector.Basic
import Mathlib.Data.Zmod.AdHocDefs
import Mathlib.Deprecated.Group
import Mathlib.Deprecated.Ring
Expand Down
7 changes: 4 additions & 3 deletions Mathlib/Data/Vector.lean
Expand Up @@ -90,10 +90,11 @@ def toList (v : Vector α n) : List α :=
v.1
#align vector.to_list Vector.toList

-- porting notes: align to `List` API
/-- nth element of a vector, indexed by a `Fin` type. -/
def nth : ∀ _ : Vector α n, Fin n → α
def get : ∀ _ : Vector α n, Fin n → α
| ⟨l, h⟩, i => l.nthLe i.1 (by rw [h] ; exact i.2)
#align vector.nth Vector.nth
#align vector.nth Vector.get

/-- Appending a vector to another. -/
def append {n m : Nat} : Vector α n → Vector α m → Vector α (n + m)
Expand Down Expand Up @@ -217,7 +218,7 @@ theorem toList_mk (v : List α) (P : List.length v = n) : toList (Subtype.mk v P
#align vector.to_list_mk Vector.toList_mk

/-- A nil vector maps to a nil list. -/
@[simp]
@[simp, nolint simpNF] -- Porting note: simp can prove this in the future
theorem toList_nil : toList nil = @List.nil α :=
rfl
#align vector.to_list_nil Vector.toList_nil
Expand Down

0 comments on commit d933809

Please sign in to comment.