From 71cdd278bb008bb4375e8d5b2b6b00e3d5bf393a Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Sat, 28 Mar 2026 22:23:16 -0500 Subject: Begin separating vector concepts from matrices --- Data/Vector/CommutativeMonoid.agda | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Data/Vector/CommutativeMonoid.agda (limited to 'Data/Vector/CommutativeMonoid.agda') diff --git a/Data/Vector/CommutativeMonoid.agda b/Data/Vector/CommutativeMonoid.agda new file mode 100644 index 0000000..c7b4a73 --- /dev/null +++ b/Data/Vector/CommutativeMonoid.agda @@ -0,0 +1,40 @@ +{-# OPTIONS --without-K --safe #-} + +open import Algebra using (Monoid; CommutativeMonoid) +open import Level using (Level; _⊔_) + +module Data.Vector.CommutativeMonoid {c ℓ : Level} (CM : CommutativeMonoid c ℓ) where + +module CM = CommutativeMonoid CM + +import Data.Vec.Relation.Binary.Pointwise.Inductive as PW + +open import Data.Vector.Core CM.setoid using (Vector; _≊_; module ≊) +open import Data.Vector.Monoid CM.monoid as M using (_⊕_) +open import Data.Nat using (ℕ) +open import Data.Vec using (Vec) + +open CM +open Vec + +private + variable + n : ℕ + +opaque + + unfolding _⊕_ + + ⊕-comm : (V W : Vector n) → V ⊕ W ≊ W ⊕ V + ⊕-comm [] [] = ≊.refl + ⊕-comm (v ∷ V) (w ∷ W) = comm v w PW.∷ ⊕-comm V W + +-- A commutative monoid of vectors for each natural number +Vectorₘ : ℕ → CommutativeMonoid c (c ⊔ ℓ) +Vectorₘ n = record + { Monoid (M.Vectorₘ n) + ; isCommutativeMonoid = record + { Monoid (M.Vectorₘ n) + ; comm = ⊕-comm + } + } -- cgit v1.2.3