Vector #
This files defines Vec as an abbreviation of Fin n → α. (This is different with Vector.)
A lot of definitions in this file are just encapsulations of those under Fin namespace; the reason
to create a new namespace is to allow dot notation and to avoid potential naming collision.
Vec type is heavily used in this library, mainly because (Fin n → α) → α can be used in
inductive definitions very naturally (while other solutions, including List α → α and
mutual inductive, generate very complicated recursors).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Create an expression of OfNat.ofNat i : Fin (n + 1).
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
Equations
- Fin.cases1 zero i = Fin.cases zero (fun (x : Fin 0) => x.elim0) i
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Vec.«term_∷ᵥ_» = Lean.ParserDescr.trailingNode `Vec.«term_∷ᵥ_» 67 68 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ∷ᵥ ") (Lean.ParserDescr.cat `term 67))
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
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
Equations
- One or more equations did not get rendered due to their size.
Instances For
append v₁ v₂ adds elements in v₁ : Vec α n before elements in v₂ : Vec α m, but returns a vector
of length m + n. This is the converse of Fin.append which returns vector of n + m.
Instances For
append v₁ v₂ adds elements in v₁ : Vec α n before elements in v₂ : Vec α m, but returns a vector
of length m + n. This is the converse of Fin.append which returns vector of n + m.
Equations
- Vec.«term_++ᵥ_» = Lean.ParserDescr.trailingNode `Vec.«term_++ᵥ_» 65 65 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ++ᵥ ") (Lean.ParserDescr.cat `term 66))
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.
Equations
- v.encode = Vec.paired fun (i : Fin n) => Encodable.encode (v i)
Instances For
Equations
- Vec.decode 0 x✝ = if x✝ = 0 then some []ᵥ else none
- Vec.decode n.succ x✝ = do let a ← Encodable.decode (Nat.unpair x✝).1 let v ← Vec.decode n (Nat.unpair x✝).2 some (a ∷ᵥ v)
Instances For
Equations
- Vec.encodable = { encode := fun (v : Vec α n) => v.encode, decode := fun (k : ℕ) => Vec.decode n k, encodek := ⋯ }
Equations
- Vec.instRepr = { reprPrec := fun (v : Vec α n) (x : ℕ) => Std.Format.bracketFill "[" (Std.Format.joinSep (Vec.toList (repr ∘ v)) (Std.Format.text ", ")) "]ᵥ" }