-
Notifications
You must be signed in to change notification settings - Fork 257
[ add ] Pointwise lifting of algebra to Data.Vec.Functional (Functional vector module #1945 redux) #2817
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
Open
e-mniang
wants to merge
4
commits into
agda:master
Choose a base branch
from
e-mniang:updating-pr-1945
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[ add ] Pointwise lifting of algebra to Data.Vec.Functional (Functional vector module #1945 redux) #2817
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
------------------------------------------------------------------------ | ||
-- 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; suc; _⊔_) | ||
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 a | ||
n : ℕ | ||
|
||
------------------------------------------------------------------------ | ||
-- Vector-lifted relations & operators | ||
|
||
pointwiseᵛ : ( _≈_ : Rel A ℓ ) → Rel (Vector A n) ℓ | ||
pointwiseᵛ _≈_ = Pointwise _≈_ | ||
|
||
zipWithᵛ : Op₂ A → Op₂ (Vector A n) | ||
zipWithᵛ _∙_ = zipWith _∙_ | ||
|
||
mapᵛ : Op₁ A → Op₁ (Vector A n) | ||
mapᵛ f = map f | ||
e-mniang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
------------------------------------------------------------------------ | ||
-- Vector-lifted raw structures | ||
|
||
rawMagmaᵛ : RawMagma a ℓ → (n : ℕ) → RawMagma a ℓ | ||
rawMagmaᵛ M n = | ||
e-mniang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
record | ||
{ Carrier = Vector M.Carrier n | ||
; _≈_ = pointwiseᵛ M._≈_ | ||
; _∙_ = zipWithᵛ M._∙_ | ||
} | ||
where module M = RawMagma M | ||
|
||
rawMonoidᵛ : RawMonoid a ℓ → (n : ℕ) → RawMonoid a ℓ | ||
rawMonoidᵛ M n = | ||
record | ||
{ RawMagma (rawMagmaᵛ M.rawMagma n) | ||
; ε = λ _ → M.ε | ||
} | ||
where module M = RawMonoid M | ||
|
||
rawGroupᵛ : RawGroup a ℓ → (n : ℕ) → RawGroup a ℓ | ||
rawGroupᵛ G n = | ||
record | ||
{ RawMonoid (rawMonoidᵛ G.rawMonoid n) | ||
; _⁻¹ = mapᵛ G._⁻¹ | ||
} | ||
where module G = RawGroup G | ||
|
||
rawNearSemiringᵛ : RawNearSemiring a ℓ → (n : ℕ) → RawNearSemiring a ℓ | ||
rawNearSemiringᵛ NS n = | ||
record | ||
{ Carrier = Vector NS.Carrier n | ||
; _≈_ = pointwiseᵛ NS._≈_ | ||
; _+_ = zipWithᵛ NS._+_ | ||
; _*_ = zipWithᵛ NS._*_ | ||
; 0# = λ _ → NS.0# | ||
} | ||
where module NS = RawNearSemiring NS | ||
|
||
rawSemiringᵛ : RawSemiring a ℓ → (n : ℕ) → RawSemiring a ℓ | ||
rawSemiringᵛ S n = | ||
record | ||
{ RawNearSemiring (rawNearSemiringᵛ S.rawNearSemiring n) | ||
; 1# = λ _ → S.1# | ||
} | ||
where module S = RawSemiring S | ||
|
||
rawRingᵛ : RawRing a ℓ → (n : ℕ) → RawRing a ℓ | ||
rawRingᵛ R n = | ||
record | ||
{ RawSemiring (rawSemiringᵛ R.rawSemiring n) | ||
; -_ = mapᵛ R.-_ | ||
} | ||
where module R = RawRing R | ||
|
||
e-mniang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
------------------------------------------------------------------------ | ||
-- Vector actions (left/right scalar multiplication) | ||
|
||
_*ₗᵛ_ : {S : Set a} → Op₂ S → Opₗ S (Vector S n) | ||
_*ₗᵛ_ _*_ r xs = map (r *_) xs | ||
e-mniang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
_*ᵣᵛ_ : {S : Set a} → Op₂ S → Opᵣ S (Vector S n) | ||
_*ᵣᵛ_ _*_ xs r = map (_* r) xs | ||
e-mniang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
------------------------------------------------------------------------ | ||
-- Vector-lifted semimodule bundles | ||
|
||
rawLeftSemimoduleᵛ : (NS : RawNearSemiring a ℓ) (n : ℕ) → RawLeftSemimodule (RawNearSemiring.Carrier NS) a ℓ | ||
rawLeftSemimoduleᵛ NS n = | ||
record | ||
{ Carrierᴹ = Vector NS.Carrier n | ||
; _≈ᴹ_ = pointwiseᵛ NS._≈_ | ||
; _+ᴹ_ = zipWithᵛ NS._+_ | ||
; _*ₗ_ = _*ₗᵛ_ NS._*_ | ||
; 0ᴹ = λ _ → NS.0# | ||
} | ||
where module NS = RawNearSemiring NS | ||
|
||
rawRightSemimoduleᵛ : (NS : RawNearSemiring a ℓ) (n : ℕ) → RawRightSemimodule (RawNearSemiring.Carrier NS) a ℓ | ||
rawRightSemimoduleᵛ NS n = | ||
record | ||
{ Carrierᴹ = Vector NS.Carrier n | ||
; _≈ᴹ_ = pointwiseᵛ NS._≈_ | ||
; _+ᴹ_ = zipWithᵛ NS._+_ | ||
; _*ᵣ_ = _*ᵣᵛ_ NS._*_ | ||
; 0ᴹ = λ _ → NS.0# | ||
} | ||
where module NS = RawNearSemiring NS | ||
|
||
rawBisemimoduleᵛ : (NS : RawNearSemiring a ℓ) (n : ℕ) → RawBisemimodule (RawNearSemiring.Carrier NS) | ||
(RawNearSemiring.Carrier NS) a ℓ | ||
rawBisemimoduleᵛ NS n = | ||
record | ||
{ Carrierᴹ = Vector NS.Carrier n | ||
; _≈ᴹ_ = pointwiseᵛ NS._≈_ | ||
; _+ᴹ_ = zipWithᵛ NS._+_ | ||
; _*ₗ_ = _*ₗᵛ_ NS._*_ | ||
; _*ᵣ_ = _*ᵣᵛ_ NS._*_ | ||
; 0ᴹ = λ _ → NS.0# | ||
} | ||
where module NS = RawNearSemiring NS |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.