Documentation

MathematicalLogic.Vec

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).

theorem Nat.pair_le_pair_left {a₁ a₂ b : } (h : a₁ a₂) :
pair a₁ b pair a₂ b
theorem Nat.pair_le_pair_right {b₁ b₂ a : } (h : b₁ b₂) :
pair a b₁ pair a b₂
theorem Nat.pair_lt_pair_left' {a₁ a₂ b₁ b₂ : } (h₁ : a₁ < a₂) (h₂ : b₁ b₂) :
pair a₁ b₁ < pair a₂ b₂
theorem Nat.pair_lt_pair_right' {a₁ a₂ b₁ b₂ : } (h₁ : a₁ a₂) (h₂ : b₁ < b₂) :
pair a₁ b₁ < pair a₂ b₂
theorem Nat.pair_le_pair {a₁ a₂ b₁ b₂ : } (h₁ : a₁ a₂) (h₂ : b₁ b₂) :
pair a₁ b₁ pair a₂ b₂
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
        def Fin.cases1 {motive : Fin 1Sort u_1} (zero : motive 0) (i : Fin 1) :
        motive i
        Equations
        Instances For
          def Fin.cases2 {motive : Fin 2Sort u_1} (zero : motive 0) (one : motive 1) (i : Fin 2) :
          motive i
          Equations
          Instances For
            def Fin.cases3 {motive : Fin 3Sort u_1} (zero : motive 0) (one : motive 1) (two : motive 2) (i : Fin 3) :
            motive i
            Equations
            Instances For
              def Fin.cases4 {motive : Fin 4Sort u_1} (zero : motive 0) (one : motive 1) (two : motive 2) (three : motive 3) (i : Fin 4) :
              motive i
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[simp]
                theorem Fin.forall_fin_three {p : Fin 3Prop} :
                (∀ (i : Fin 3), p i) p 0 p 1 p 2
                @[simp]
                theorem Fin.forall_fin_four {p : Fin 4Prop} :
                (∀ (i : Fin 4), p i) p 0 p 1 p 2 p 3
                @[simp]
                theorem Fin.exists_fin_three {p : Fin 3Prop} :
                (∃ (i : Fin 3), p i) p 0 p 1 p 2
                @[simp]
                theorem Fin.exists_fin_four {p : Fin 4Prop} :
                (∃ (i : Fin 4), p i) p 0 p 1 p 2 p 3
                def Fin.castAdd' {n : } (x : Fin n) (m : ) :
                Fin (m + n)

                castAdd' x m embeds x : Fin n in Fin (m + n). This is the converse of castAdd m i which embeds into Fin (n + m).

                Equations
                Instances For
                  @[simp]
                  theorem Fin.castAdd'_zero {n m : } :
                  castAdd' 0 m = 0
                  @[simp]
                  theorem Fin.castAdd'_succ {n✝ : } {x : Fin n✝} {m : } :
                  @[simp]
                  theorem Fin.castAdd'_one {n m : } :
                  castAdd' 1 m = 1
                  @[simp]
                  theorem Fin.addNat_succ {n✝ : } {x : Fin n✝} {m : } :
                  x.addNat (m + 1) = (x.addNat m).succ
                  def Fin.addCases' {m n : } {motive : Fin (m + n)Sort u} (left : (i : Fin n) → motive (i.castAdd' m)) (right : (i : Fin m) → motive (i.addNat n)) (i : Fin (m + n)) :
                  motive i
                  Equations
                  Instances For
                    @[reducible]
                    def Vec (α : Type u) (n : ) :

                    Vec α n is an abbreviation of Fin n → α, a vector of length n.

                    Equations
                    Instances For
                      def Vec.nil {α : Type u} :
                      Vec α 0
                      Equations
                      Instances For
                        def Vec.cons {α : Type u} {n : } (a : α) (v : Vec α n) :
                        Vec α (n + 1)
                        Equations
                        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
                                @[simp]
                                theorem Vec.cons_succ {α✝ : Type u_1} {a : α✝} {n✝ : } {v : Vec α✝ n✝} {i : Fin n✝} :
                                (a ∷ᵥ v) i.succ = v i
                                theorem Vec.cons_zero {α✝ : Type u_1} {a : α✝} {n✝ : } {v : Vec α✝ n✝} :
                                (a ∷ᵥ v) 0 = a
                                theorem Vec.cons_one {α : Type u} {n : } {a : α} {v : Vec α (n + 1)} :
                                (a ∷ᵥ v) 1 = v 0
                                theorem Vec.cons_two {α : Type u} {n : } {a : α} {v : Vec α (n + 2)} :
                                (a ∷ᵥ v) 2 = v 1
                                theorem Vec.cons_three {α : Type u} {n : } {a : α} {v : Vec α (n + 3)} :
                                (a ∷ᵥ v) 3 = v 2
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem Vec.ext {α : Type u} {n : } {v₁ v₂ : Vec α n} :
                                  (∀ (i : Fin n), v₁ i = v₂ i)v₁ = v₂
                                  theorem Vec.ext_iff {α : Type u} {n : } {v₁ v₂ : Vec α n} :
                                  v₁ = v₂ ∀ (i : Fin n), v₁ i = v₂ i
                                  def Vec.head {α : Type u} {n : } (v : Vec α (n + 1)) :
                                  α
                                  Equations
                                  Instances For
                                    @[simp]
                                    theorem Vec.head_cons {α✝ : Type u_1} {a : α✝} {n✝ : } {v : Vec α✝ n✝} :
                                    (a ∷ᵥ v).head = a
                                    def Vec.tail {α : Type u} {n : } (v : Vec α (n + 1)) :
                                    Vec α n
                                    Equations
                                    Instances For
                                      @[simp]
                                      theorem Vec.tail_apply {α : Type u} {n : } {x : Fin n} {v : Vec α (n + 1)} :
                                      v.tail x = v x.succ
                                      @[simp]
                                      theorem Vec.tail_cons {α✝ : Type u_1} {a : α✝} {n✝ : } {v : Vec α✝ n✝} :
                                      (a ∷ᵥ v).tail = v
                                      @[simp]
                                      theorem Vec.cons_eq_iff {α✝ : Type u_1} {a₁ : α✝} {n✝ : } {v₁ : Vec α✝ n✝} {a₂ : α✝} {v₂ : Vec α✝ n✝} :
                                      a₁ ∷ᵥ v₁ = a₂ ∷ᵥ v₂ a₁ = a₂ v₁ = v₂
                                      theorem Vec.eq_nil {α : Type u} (v : Vec α 0) :
                                      theorem Vec.eq_cons {α : Type u} {n : } (v : Vec α (n + 1)) :
                                      theorem Vec.eq_one {α : Type u} (v : Vec α 1) :
                                      v = [v 0]ᵥ
                                      theorem Vec.eq_two {α : Type u} (v : Vec α 2) :
                                      v = [v 0, v 1]ᵥ
                                      theorem Vec.eq_three {α : Type u} (v : Vec α 3) :
                                      v = [v 0, v 1, v 2]ᵥ
                                      theorem Vec.eq_four {α : Type u} (v : Vec α 4) :
                                      v = [v 0, v 1, v 2, v 3]ᵥ
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        theorem Vec.exists_vec_succ {α : Type u} {n : } {p : Vec α (n + 1)Prop} :
                                        (∃ (v : Vec α (n + 1)), p v) ∃ (a : α) (v : Vec α n), p (a ∷ᵥ v)
                                        @[simp]
                                        theorem Vec.exists_vec0 {α : Type u} {p : Vec α 0Prop} :
                                        (∃ (v : Vec α 0), p v) p []ᵥ
                                        @[simp]
                                        theorem Vec.exists_vec1 {α : Type u} {p : Vec α 1Prop} :
                                        (∃ (v : Vec α 1), p v) ∃ (x : α), p [x]ᵥ
                                        @[simp]
                                        theorem Vec.exists_vec2 {α : Type u} {p : Vec α 2Prop} :
                                        (∃ (v : Vec α 2), p v) ∃ (x : α) (y : α), p [x, y]ᵥ
                                        @[simp]
                                        theorem Vec.exists_vec3 {α : Type u} {p : Vec α 3Prop} :
                                        (∃ (v : Vec α 3), p v) ∃ (x : α) (y : α) (z : α), p [x, y, z]ᵥ
                                        def Vec.rec {α : Type u} {motive : {n : } → Vec α nSort v} (nil : motive []ᵥ) (cons : {n : } → (a : α) → (v : Vec α n) → motive vmotive (a ∷ᵥ v)) {n : } (v : Vec α n) :
                                        motive v
                                        Equations
                                        Instances For
                                          @[simp]
                                          theorem Vec.rec_nil {α : Type u} {motive : {n : } → Vec α nSort v} (nil : motive []ᵥ) (cons : {n : } → (a : α) → (v : Vec α n) → motive vmotive (a ∷ᵥ v)) :
                                          rec nil (fun {n : } => cons) []ᵥ = nil
                                          @[simp]
                                          theorem Vec.rec_cons {α : Type u} {motive : {n : } → Vec α nSort v} (nil : motive []ᵥ) (cons : {n : } → (a : α) → (v : Vec α n) → motive vmotive (a ∷ᵥ v)) {a : α} {n✝ : } {v : Vec α n✝} :
                                          rec nil (fun {n : } => cons) (a ∷ᵥ v) = cons a v (rec nil (fun {n : } => cons) v)
                                          theorem Vec.comp_cons {α✝ : Type u_1} {δ✝ : Type u_2} {f : α✝δ✝} {a : α✝} {n✝ : } {v : Vec α✝ n✝} :
                                          f (a ∷ᵥ v) = f a ∷ᵥ f v
                                          def Vec.rcons {α : Type u} {n : } (v : Vec α n) (x : α) :
                                          Vec α (n + 1)
                                          Equations
                                          Instances For
                                            @[simp]
                                            theorem Vec.rcons_nil {α✝ : Type u_1} {x : α✝} :
                                            @[simp]
                                            theorem Vec.rcons_cons {α✝ : Type u_1} {x : α✝} {n✝ : } {v : Vec α✝ n✝} {y : α✝} :
                                            (x ∷ᵥ v).rcons y = x ∷ᵥ v.rcons y
                                            @[simp]
                                            theorem Vec.rcons_last {α✝ : Type u_1} {n✝ : } {v : Vec α✝ n✝} {a : α✝} :
                                            v.rcons a (Fin.last n✝) = a
                                            @[simp]
                                            theorem Vec.rcons_castSucc {α✝ : Type u_1} {n✝ : } {v : Vec α✝ n✝} {a : α✝} {x : Fin n✝} :
                                            v.rcons a x.castSucc = v x
                                            def Vec.append {α : Type u} {n m : } (v₁ : Vec α n) (v₂ : Vec α m) :
                                            Vec α (m + n)

                                            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
                                            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
                                              Instances For
                                                @[simp]
                                                theorem Vec.nil_append {α✝ : Type u_1} {n✝ : } {v : Vec α✝ n✝} :
                                                @[simp]
                                                theorem Vec.cons_append {α✝ : Type u_1} {a : α✝} {n✝ : } {v₁ : Vec α✝ n✝} {n✝¹ : } {v₂ : Vec α✝ n✝¹} :
                                                a ∷ᵥ v₁ ++ᵥ v₂ = a ∷ᵥ (v₁ ++ᵥ v₂)
                                                @[simp]
                                                theorem Vec.append_left {α : Type u} {m n✝ : } {v₁ : Vec α n✝} {x : Fin n✝} {v₂ : Vec α m} :
                                                (v₁ ++ᵥ v₂) (x.castAdd' m) = v₁ x
                                                @[simp]
                                                theorem Vec.append_right {α : Type u} {n n✝ : } {v₂ : Vec α n✝} {x : Fin n✝} {v₁ : Vec α n} :
                                                (v₁ ++ᵥ v₂) (x.addNat n) = v₂ x
                                                theorem Vec.eq_append {α : Type u} {m n : } (v : Vec α (m + n)) :
                                                v = (fun (i : Fin n) => v (i.castAdd' m)) ++ᵥ fun (i : Fin m) => v (i.addNat n)
                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  instance Vec.decEq {α : Type u} {n : } [DecidableEq α] :
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  def Vec.max {n : } :
                                                  Vec n
                                                  Equations
                                                  Instances For
                                                    theorem Vec.le_max {n : } {v : Vec n} (i : Fin n) :
                                                    v i v.max
                                                    theorem Vec.max_le {n m : } {v : Vec n} :
                                                    (∀ (i : Fin n), v i m)v.max m
                                                    theorem Vec.max_le_iff {n m : } {v : Vec n} :
                                                    v.max m ∀ (i : Fin n), v i m
                                                    @[simp]
                                                    theorem Vec.max_zero {n : } :
                                                    (max fun (x : Fin n) => 0) = 0
                                                    theorem Vec.max_eq_nth {n : } (v : Vec (n + 1)) :
                                                    ∃ (i : Fin (n + 1)), v.max = v i
                                                    theorem Vec.le_max_iff {n m : } {v : Vec (n + 1)} :
                                                    m v.max ∃ (i : Fin (n + 1)), m v i
                                                    theorem Vec.max_pos_iff {n : } {v : Vec n} :
                                                    v.max > 0 ∃ (i : Fin n), v i > 0
                                                    theorem Vec.max_zero_iff {n : } {v : Vec n} :
                                                    v.max = 0 ∀ (i : Fin n), v i = 0
                                                    def Vec.paired {n : } :
                                                    Vec n

                                                    paired [a₁, ⋯, aₙ]ᵥ is ⟪a₁, ⟪a₂, ⟪⋯, ⟪aₙ, 0⟫⟫⟫ where ⟪x, y⟫ is Nat.pair.

                                                    Equations
                                                    Instances For
                                                      theorem Vec.le_paired {n : } {i : Fin n} {v : Vec n} :
                                                      v i v.paired
                                                      theorem Vec.paired_le_paired {n : } {v₁ v₂ : Vec n} :
                                                      (∀ (i : Fin n), v₁ i v₂ i)v₁.paired v₂.paired
                                                      @[simp]
                                                      theorem Vec.paired_nil {v : Vec 0} :
                                                      v.paired = 0
                                                      @[simp]
                                                      theorem Vec.unpair_paired {n : } {v : Vec (n + 1)} :
                                                      def Vec.encode {α : Type u} [Encodable α] {n : } (v : Vec α n) :
                                                      Equations
                                                      Instances For
                                                        def Vec.decode {α : Type u} [Encodable α] (n k : ) :
                                                        Option (Vec α n)
                                                        Equations
                                                        Instances For
                                                          theorem Vec.encode_decode {α : Type u} [Encodable α] {n : } {v : Vec α n} :
                                                          instance Vec.encodable {α : Type u} [Encodable α] {n : } :
                                                          Encodable (Vec α n)
                                                          Equations
                                                          @[simp]
                                                          theorem Vec.encode_nil {α : Type u} [Encodable α] {v : Vec α 0} :
                                                          @[simp]
                                                          theorem Vec.encode_cons {α : Type u} [Encodable α] {n : } {a : α} {v : Vec α n} :
                                                          theorem Vec.encode_eq {α : Type u} [Encodable α] {n : } {v : Vec α n} :
                                                          instance Vec.instCountable {α : Type u} {n : } [Countable α] :
                                                          Countable (Vec α n)
                                                          def Vec.toList {α : Type u} {n : } (v : Vec α n) :
                                                          List α
                                                          Equations
                                                          Instances For
                                                            instance Vec.instRepr {α : Type u} {n : } [Repr α] :
                                                            Repr (Vec α n)
                                                            Equations