-
Notifications
You must be signed in to change notification settings - Fork 259
Functional vector module #1945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Functional vector module #1945
Changes from all commits
a295308
3037439
468bb69
700b114
623d474
a5f6a10
514ef92
ce75303
7d62c1c
3ed6e0b
81548b0
1b684fc
6604b6e
bc7d02d
51a8adc
841be8c
62b0af2
651c316
1c520d1
2f9e635
9fc2632
e39e20e
59e693e
967be03
4dccb0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| ------------------------------------------------------------------------ | ||
| -- The Agda standard library | ||
| -- | ||
| -- Some Vector-related module Definitions | ||
| ------------------------------------------------------------------------ | ||
|
|
||
| {-# OPTIONS --cubical-compatible --safe #-} | ||
|
|
||
| module Data.Vec.Functional.Algebra.Base where | ||
|
|
||
| open import Level using (Level) | ||
| open import Function using (_$_) | ||
| open import Data.Nat using (ℕ) | ||
| open import Data.Fin using (Fin) | ||
| open import Data.Vec.Functional | ||
| open import Algebra.Core | ||
| open import Algebra.Bundles | ||
| open import Algebra.Module | ||
| open import Relation.Binary using (Rel) | ||
| open import Data.Vec.Functional.Relation.Binary.Pointwise using (Pointwise) | ||
|
|
||
| private variable | ||
| a ℓ : Level | ||
| A : Set ℓ | ||
| n : ℕ | ||
|
|
||
| module EqualityVecFunc (_≈_ : Rel A ℓ) where | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason everything in here is in sub-modules? That is not a common |
||
| _≈ᴹ_ : Rel (Vector A n) ℓ | ||
| _≈ᴹ_ = Pointwise _≈_ | ||
|
|
||
| module VecAddition (_∙_ : Op₂ A) where | ||
| _∙ᴹ_ : Op₂ $ Vector A n | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not call this |
||
| _∙ᴹ_ = zipWith _∙_ | ||
|
|
||
| module VecMagma (rawMagma : RawMagma a ℓ) where | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expected the 'result' here to define an instance the structure |
||
| open RawMagma rawMagma public | ||
| open VecAddition _∙_ public | ||
| open EqualityVecFunc _≈_ public | ||
|
|
||
| module VecMonoid (rawMonoid : RawMonoid a ℓ) where | ||
| open RawMonoid rawMonoid using (rawMagma; ε) public | ||
| open VecMagma rawMagma public | ||
|
|
||
| εᴹ : Vector Carrier n | ||
| εᴹ = replicate ε | ||
|
|
||
| module VecGroup (rawGroup : RawGroup a ℓ) where | ||
| open RawGroup rawGroup using (rawMonoid; _⁻¹) public | ||
| open VecMonoid rawMonoid public | ||
|
|
||
| -ᴹ_ : Op₁ $ Vector Carrier n | ||
| -ᴹ_ = map $ _⁻¹ | ||
|
|
||
| module VecNearSemiring (rawNearSemiring : RawNearSemiring a ℓ) where | ||
| open RawNearSemiring rawNearSemiring using (+-rawMonoid; *-rawMagma) public | ||
| open VecMonoid +-rawMonoid renaming (ε to 0#; εᴹ to 0ᴹ; _∙ᴹ_ to _+ᴹ_; _∙_ to _+_) public | ||
| open VecMagma *-rawMagma public renaming (_∙ᴹ_ to _*ᴹ_; _∙_ to _*_) using () | ||
|
|
||
| _*ₗ_ : Opₗ Carrier (Vector Carrier n) | ||
| _*ₗ_ r = map (r *_) | ||
|
|
||
| _*ᵣ_ : Opᵣ Carrier (Vector Carrier n) | ||
| _*ᵣ_ xs r = map (_* r) xs | ||
|
|
||
| module VecSemiring (rawSemiring : RawSemiring a ℓ) where | ||
| open RawSemiring rawSemiring using (rawNearSemiring; 1#; *-rawMonoid) public | ||
| open VecNearSemiring rawNearSemiring public | ||
| open VecMonoid *-rawMonoid public renaming (εᴹ to 1ᴹ) using () | ||
|
|
||
| module VecRing (rawRing : RawRing a ℓ) where | ||
| open RawRing rawRing using (+-rawGroup; rawSemiring) public | ||
| open VecGroup +-rawGroup public using (-ᴹ_) | ||
| open VecSemiring rawSemiring public | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these cases we typically only mention we have added entirely new modules rather than listing their content.
Cf. https://github.com/agda/agda-stdlib/blob/master/CHANGELOG.md#new-modules