-
Notifications
You must be signed in to change notification settings - Fork 239
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
Functional vector module #1945
Draft
guilhermehas
wants to merge
25
commits into
agda:master
Choose a base branch
from
guilhermehas:functional-vector-module
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.
Draft
Functional vector module #1945
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a295308
added Functional Algebra Properties
guilhermehas 3037439
put some things in Base
guilhermehas 468bb69
added changelog
guilhermehas 700b114
added the names
guilhermehas 623d474
changed VC to Vector Carrier
guilhermehas a5f6a10
changed semiGroup to semigroup
guilhermehas 514ef92
modified the CHANGELOG
guilhermehas ce75303
added all the definitions
guilhermehas 7d62c1c
changed to commutative ring to add module
guilhermehas 3ed6e0b
fixed isModule
guilhermehas 81548b0
added ring * and 1m
guilhermehas 1b684fc
add all operators of functional vec
guilhermehas 6604b6e
changed the code to be more general
guilhermehas bc7d02d
using rawStructures instead
guilhermehas 51a8adc
fixed base exportation
guilhermehas 841be8c
proved more definitions
guilhermehas 62b0af2
added monoid properties
guilhermehas 651c316
added isGroup and isAbGroup
guilhermehas 1c520d1
added semiring properties
guilhermehas 2f9e635
added Ring Properties
guilhermehas 9fc2632
changed back to espilon and dot definition
guilhermehas e39e20e
added magma definitions
guilhermehas 59e693e
added some more groups
guilhermehas 967be03
added structures inside
guilhermehas 4dccb0e
added the bundles
guilhermehas 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 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 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,46 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Some Vector-related module Definitions | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Function using (_$_) | ||
open import Data.Product hiding (map) | ||
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 | ||
import Data.Vec.Functional.Relation.Binary.Equality.Setoid as VecSetoid | ||
import Algebra.Definitions as AD | ||
import Algebra.Structures as AS | ||
|
||
module Data.Vec.Functional.Algebra.Base | ||
{c ℓ} (ring : Ring c ℓ) where | ||
|
||
private variable | ||
n : ℕ | ||
|
||
open Ring ring | ||
open VecSetoid setoid | ||
|
||
VC = Vector Carrier | ||
guilhermehas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_≈ᴹ_ : Rel (VC n) ℓ | ||
_≈ᴹ_ = _≋_ | ||
|
||
_+ᴹ_ : Op₂ $ VC n | ||
_+ᴹ_ = zipWith _+_ | ||
|
||
0ᴹ : VC n | ||
0ᴹ = replicate 0# | ||
|
||
-ᴹ_ : Op₁ $ VC n | ||
-ᴹ_ = map $ -_ | ||
|
||
_*ₗ_ : Opₗ Carrier (VC n) | ||
_*ₗ_ r = map (r *_) |
This file contains 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,173 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Some Vector-related module properties | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Function using (_$_) | ||
open import Data.Product hiding (map) | ||
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 | ||
import Data.Vec.Functional.Relation.Binary.Equality.Setoid as VecSetoid | ||
import Algebra.Definitions as AD | ||
import Algebra.Structures as AS | ||
import Data.Vec.Functional.Algebra.Base as VFA | ||
|
||
module Data.Vec.Functional.Algebra.Properties | ||
{c ℓ} (ring : Ring c ℓ) where | ||
|
||
private variable | ||
n : ℕ | ||
|
||
open Ring ring | ||
open VecSetoid setoid | ||
open VFA ring | ||
module SR = Semiring semiring | ||
open module AD' {n} = AD (_≈ᴹ_ {n}) | ||
open module AS' {n} = AS (_≈ᴹ_ {n}) | ||
open module LD {n} = LeftDefs Carrier (_≈ᴹ_ {n}) using (Congruent) | ||
|
||
------------------------------------------------------------------------ | ||
-- Algebraic properties of _+ᴹ_ -ᴹ_ _*ₗ_ | ||
|
||
+ᴹ-cong : Congruent₂ (_+ᴹ_ {n}) | ||
+ᴹ-cong x≈y u≈v _ = +-cong (x≈y _) (u≈v _) | ||
|
||
+ᴹ-assoc : Associative (_+ᴹ_ {n}) | ||
+ᴹ-assoc _ _ _ _ = +-assoc _ _ _ | ||
guilhermehas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
+ᴹ-comm : Commutative (_+ᴹ_ {n}) | ||
+ᴹ-comm _ _ _ = +-comm _ _ | ||
|
||
+ᴹ-identityˡ : LeftIdentity (0ᴹ {n}) _+ᴹ_ | ||
+ᴹ-identityˡ _ _ = +-identityˡ _ | ||
|
||
+ᴹ-identityʳ : RightIdentity (0ᴹ {n}) _+ᴹ_ | ||
+ᴹ-identityʳ _ _ = +-identityʳ _ | ||
|
||
+ᴹ-identity : Identity (0ᴹ {n}) _+ᴹ_ | ||
+ᴹ-identity = +ᴹ-identityˡ , +ᴹ-identityʳ | ||
|
||
-ᴹ‿cong : Congruent₁ (-ᴹ_ {n}) | ||
-ᴹ‿cong f _ = -‿cong (f _) | ||
|
||
-ᴹ‿inverseˡ : AD'.LeftInverse (0ᴹ {n}) -ᴹ_ _+ᴹ_ | ||
-ᴹ‿inverseˡ _ _ = -‿inverseˡ _ | ||
|
||
-ᴹ‿inverseʳ : AD'.RightInverse (0ᴹ {n}) -ᴹ_ _+ᴹ_ | ||
-ᴹ‿inverseʳ _ _ = -‿inverseʳ _ | ||
|
||
-ᴹ‿inverse : AD'.Inverse (0ᴹ {n}) -ᴹ_ _+ᴹ_ | ||
-ᴹ‿inverse = -ᴹ‿inverseˡ , -ᴹ‿inverseʳ | ||
|
||
*ₗ-cong : Congruent SR._≈_ (_*ₗ_ {n}) | ||
*ₗ-cong x≈y u≈v i = *-cong x≈y (u≈v i) | ||
|
||
*ₗ-zeroˡ : LD.LeftZero SR.0# (0ᴹ {n}) _*ₗ_ | ||
*ₗ-zeroˡ f i = zeroˡ (f i) | ||
|
||
*ₗ-distribʳ : _*ₗ_ LD.DistributesOverʳ SR._+_ ⟶ (_+ᴹ_ {n}) | ||
*ₗ-distribʳ _ _ _ _ = distribʳ _ _ _ | ||
|
||
*ₗ-identityˡ : LD.LeftIdentity SR.1# (_*ₗ_ {n}) | ||
*ₗ-identityˡ _ _ = *-identityˡ _ | ||
|
||
*ₗ-assoc : LD.Associative SR._*_ (_*ₗ_ {n}) | ||
*ₗ-assoc _ _ _ _ = *-assoc _ _ _ | ||
|
||
*ₗ-zeroʳ : LD.RightZero (0ᴹ {n}) _*ₗ_ | ||
*ₗ-zeroʳ _ _ = zeroʳ _ | ||
|
||
*ₗ-distribˡ : _*ₗ_ LD.DistributesOverˡ (_+ᴹ_ {n}) | ||
*ₗ-distribˡ _ _ _ _ = distribˡ _ _ _ | ||
|
||
------------------------------------------------------------------------ | ||
-- Structures | ||
|
||
isMagma : IsMagma (_+ᴹ_ {n}) | ||
isMagma = record | ||
{ isEquivalence = ≋-isEquivalence _ | ||
; ∙-cong = +ᴹ-cong | ||
} | ||
|
||
isSemigroup : IsSemigroup (_+ᴹ_ {n}) | ||
isSemigroup = record | ||
{ isMagma = isMagma | ||
; assoc = +ᴹ-assoc | ||
} | ||
|
||
isMonoid : IsMonoid (_+ᴹ_ {n}) 0ᴹ | ||
isMonoid = record | ||
{ isSemigroup = isSemigroup | ||
; identity = +ᴹ-identity | ||
} | ||
|
||
isCommutativeMonoid : IsCommutativeMonoid (_+ᴹ_ {n}) 0ᴹ | ||
isCommutativeMonoid = record | ||
{ isMonoid = isMonoid | ||
; comm = +ᴹ-comm | ||
} | ||
|
||
isPreleftSemimodule : IsPreleftSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ₗ_ | ||
isPreleftSemimodule = record | ||
{ *ₗ-cong = *ₗ-cong | ||
; *ₗ-zeroˡ = *ₗ-zeroˡ | ||
; *ₗ-distribʳ = *ₗ-distribʳ | ||
; *ₗ-identityˡ = *ₗ-identityˡ | ||
; *ₗ-assoc = *ₗ-assoc | ||
; *ₗ-zeroʳ = *ₗ-zeroʳ | ||
; *ₗ-distribˡ = *ₗ-distribˡ | ||
} | ||
|
||
isLeftSemimodule : IsLeftSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ₗ_ | ||
isLeftSemimodule = record | ||
{ +ᴹ-isCommutativeMonoid = isCommutativeMonoid | ||
; isPreleftSemimodule = isPreleftSemimodule | ||
} | ||
|
||
isLeftModule : IsLeftModule ring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ | ||
isLeftModule = record | ||
{ isLeftSemimodule = isLeftSemimodule | ||
; -ᴹ‿cong = -ᴹ‿cong | ||
; -ᴹ‿inverse = -ᴹ‿inverse | ||
} | ||
|
||
------------------------------------------------------------------------ | ||
-- Bundles | ||
|
||
magma : ℕ → Magma _ _ | ||
magma n = record | ||
{ isMagma = isMagma {n} | ||
} | ||
|
||
semiGroup : ℕ → Semigroup _ _ | ||
guilhermehas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
semiGroup n = record | ||
{ isSemigroup = isSemigroup {n} | ||
} | ||
|
||
monoid : ℕ → Monoid _ _ | ||
monoid n = record | ||
{ isMonoid = isMonoid {n} | ||
} | ||
|
||
commutativeMonoid : ℕ → CommutativeMonoid _ _ | ||
commutativeMonoid n = record | ||
{ isCommutativeMonoid = isCommutativeMonoid {n} | ||
} | ||
|
||
leftSemimodule : ℕ → LeftSemimodule _ _ _ | ||
leftSemimodule n = record | ||
{ isLeftSemimodule = isLeftSemimodule {n} | ||
} | ||
|
||
leftModule : ℕ → LeftModule _ _ _ | ||
leftModule n = record | ||
{ isLeftModule = isLeftModule {n} | ||
} |
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.
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