Alternate definition of Vector
in terms of Fin2
#
This file provides a locale Vector3
which overrides the [a, b, c]
notation to create a Vector3
instead of a List
.
The ::
notation is also overloaded by this file to mean Vector3.cons
.
@[match_pattern]
The vector cons operation
Equations
- Vector3.cons a v i = Fin2.cases' a v i
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The vector cons operation
Equations
- Vector3.«term_::_» = Lean.ParserDescr.trailingNode `Vector3.term_::_ 1022 0 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " :: ") (Lean.ParserDescr.cat `term 0))
Instances For
@[simp]
theorem
Vector3.cons_fz
{α : Type u_1}
{n : ℕ}
(a : α)
(v : Vector3 α n)
:
Vector3.cons a v Fin2.fz = a
@[simp]
theorem
Vector3.cons_fs
{α : Type u_1}
{n : ℕ}
(a : α)
(v : Vector3 α n)
(i : Fin2 n)
:
Vector3.cons a v (Fin2.fs i) = v i
theorem
Vector3.cons_head_tail
{α : Type u_1}
{n : ℕ}
(v : Vector3 α (Nat.succ n))
:
Vector3.cons (Vector3.head v) (Vector3.tail v) = v
Eliminator for an empty vector.
Equations
- Vector3.nilElim H v = Eq.mpr (_ : C v = C []) H
Instances For
def
Vector3.consElim
{α : Type u_1}
{n : ℕ}
{C : Vector3 α (Nat.succ n) → Sort u}
(H : (a : α) → (t : Vector3 α n) → C (Vector3.cons a t))
(v : Vector3 α (Nat.succ n))
:
C v
Recursion principle for a nonempty vector.
Equations
- Vector3.consElim H v = Eq.mpr (_ : C v = C (Vector3.cons (Vector3.head v) (Vector3.tail v))) (H (Vector3.head v) (Vector3.tail v))
Instances For
@[simp]
theorem
Vector3.consElim_cons
{α : Type u_1}
{n : ℕ}
{C : Vector3 α (Nat.succ n) → Sort u_2}
{H : (a : α) → (t : Vector3 α n) → C (Vector3.cons a t)}
{a : α}
{t : Vector3 α n}
:
Vector3.consElim H (Vector3.cons a t) = H a t
def
Vector3.recOn
{α : Type u_1}
{C : {n : ℕ} → Vector3 α n → Sort u}
{n : ℕ}
(v : Vector3 α n)
(H0 : C [])
(Hs : {n : ℕ} → (a : α) → (w : Vector3 α n) → C w → C (Vector3.cons a w))
:
C v
Recursion principle with the vector as first argument.
Equations
- Vector3.recOn v_2 H0 Hs = Vector3.nilElim H0 v_2
- Vector3.recOn v_2 H0 Hs = Vector3.consElim (fun (a : α) (t : Vector3 α n_2) => Hs a t (Vector3.recOn t H0 fun {n : ℕ} => Hs)) v_2
Instances For
@[simp]
theorem
Vector3.recOn_nil
{α : Type u_1}
{C : {n : ℕ} → Vector3 α n → Sort u_2}
{H0 : C []}
{Hs : {n : ℕ} → (a : α) → (w : Vector3 α n) → C w → C (Vector3.cons a w)}
:
Vector3.recOn [] H0 Hs = H0
@[simp]
theorem
Vector3.recOn_cons
{α : Type u_1}
{C : {n : ℕ} → Vector3 α n → Sort u_2}
{H0 : C []}
{Hs : {n : ℕ} → (a : α) → (w : Vector3 α n) → C w → C (Vector3.cons a w)}
{n : ℕ}
{a : α}
{v : Vector3 α n}
:
Vector3.recOn (Vector3.cons a v) H0 Hs = Hs a v (Vector3.recOn v H0 Hs)
Append two vectors
Equations
- Vector3.append v w = Vector3.recOn v w fun {n_1 : ℕ} (a : α) (x : Vector3 α n_1) (IH : Vector3 α (n + n_1)) => Vector3.cons a IH
Instances For
@[simp]
@[simp]
theorem
Vector3.append_cons
{α : Type u_1}
{m : ℕ}
{n : ℕ}
(a : α)
(v : Vector3 α m)
(w : Vector3 α n)
:
Vector3.append (Vector3.cons a v) w = Vector3.cons a (Vector3.append v w)
Insert a
into v
at index i
.
Equations
- Vector3.insert a v i j = Vector3.cons a v (Fin2.insertPerm i j)
Instances For
@[simp]
theorem
Vector3.insert_fz
{α : Type u_1}
{n : ℕ}
(a : α)
(v : Vector3 α n)
:
Vector3.insert a v Fin2.fz = Vector3.cons a v
@[simp]
theorem
Vector3.insert_fs
{α : Type u_1}
{n : ℕ}
(a : α)
(b : α)
(v : Vector3 α n)
(i : Fin2 (Nat.succ n))
:
Vector3.insert a (Vector3.cons b v) (Fin2.fs i) = Vector3.cons b (Vector3.insert a v i)
theorem
Vector3.append_insert
{α : Type u_1}
{m : ℕ}
{n : ℕ}
(a : α)
(t : Vector3 α m)
(v : Vector3 α n)
(i : Fin2 (Nat.succ n))
(e : Nat.succ n + m = Nat.succ (n + m))
:
Vector3.insert a (Vector3.append t v) (Eq.recOn e (Fin2.add i m)) = Eq.recOn e (Vector3.append t (Vector3.insert a v i))
VectorAllP p v
is equivalent to ∀ i, p (v i)
, but unfolds directly to a conjunction,
i.e. VectorAllP p [0, 1, 2] = p 0 ∧ p 1 ∧ p 2
.
Equations
- VectorAllP p v = Vector3.recOn v True fun {n : ℕ} (a : α) (v : Vector3 α n) (IH : Prop) => Vector3.recOn v (p a) fun {n : ℕ} (x : α) (x : Vector3 α n) (x : Prop) => p a ∧ IH
Instances For
@[simp]
@[simp]
theorem
vectorAllP_cons
{α : Type u_1}
{n : ℕ}
(p : α → Prop)
(x : α)
(v : Vector3 α n)
:
VectorAllP p (Vector3.cons x v) ↔ p x ∧ VectorAllP p v
theorem
vectorAllP_iff_forall
{α : Type u_1}
{n : ℕ}
(p : α → Prop)
(v : Vector3 α n)
:
VectorAllP p v ↔ ∀ (i : Fin2 n), p (v i)
theorem
VectorAllP.imp
{α : Type u_1}
{n : ℕ}
{p : α → Prop}
{q : α → Prop}
(h : ∀ (x : α), p x → q x)
{v : Vector3 α n}
(al : VectorAllP p v)
:
VectorAllP q v