Skip to content
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
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a295308
added Functional Algebra Properties
guilhermehas Apr 17, 2023
3037439
put some things in Base
guilhermehas Apr 17, 2023
468bb69
added changelog
guilhermehas Apr 17, 2023
700b114
added the names
guilhermehas Apr 17, 2023
623d474
changed VC to Vector Carrier
guilhermehas Apr 17, 2023
a5f6a10
changed semiGroup to semigroup
guilhermehas Apr 17, 2023
514ef92
modified the CHANGELOG
guilhermehas Apr 17, 2023
ce75303
added all the definitions
guilhermehas Apr 17, 2023
7d62c1c
changed to commutative ring to add module
guilhermehas Apr 17, 2023
3ed6e0b
fixed isModule
guilhermehas Apr 17, 2023
81548b0
added ring * and 1m
guilhermehas Apr 18, 2023
1b684fc
add all operators of functional vec
guilhermehas Apr 18, 2023
6604b6e
changed the code to be more general
guilhermehas May 18, 2023
bc7d02d
using rawStructures instead
guilhermehas May 19, 2023
51a8adc
fixed base exportation
guilhermehas May 25, 2023
841be8c
proved more definitions
guilhermehas May 26, 2023
62b0af2
added monoid properties
guilhermehas May 26, 2023
651c316
added isGroup and isAbGroup
guilhermehas May 26, 2023
1c520d1
added semiring properties
guilhermehas May 26, 2023
2f9e635
added Ring Properties
guilhermehas May 26, 2023
9fc2632
changed back to espilon and dot definition
guilhermehas May 26, 2023
e39e20e
added magma definitions
guilhermehas May 26, 2023
59e693e
added some more groups
guilhermehas May 26, 2023
967be03
added structures inside
guilhermehas May 27, 2023
4dccb0e
added the bundles
guilhermehas May 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3027,3 +3027,113 @@ This is a full list of proofs that have changed form to use irrelevant instance
```agda
<-weakInduction-startingFrom : P i → (∀ j → P (inject₁ j) → P (suc j)) → ∀ {j} → j ≥ i → P j
```

Copy link
Member

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

* In `Data.Vec.Functional.Algebra.Base`
```agda
_≈ᴹ_ : Rel (Vector Carrier n) ℓ
_+ᴹ_ : Op₂ $ Vector Carrier n
0ᴹ : Vector Carrier n
-ᴹ_ : Op₁ $ Vector Carrier n
_*ₗ_ : Opₗ Carrier (Vector Carrier n)
```

* Added algebraic properties in `Data.Vec.Functional.Algebra.Properties`
```agda
+ᴹ-cong : Congruent₂ (_+ᴹ_ {n})
*ᴹ-cong : Congruent₂ (_*ᴹ_ {n})
+ᴹ-assoc : Associative (_+ᴹ_ {n})
*ᴹ-assoc : Associative (_*ᴹ_ {n})
+ᴹ-comm : Commutative (_+ᴹ_ {n})
*ᴹ-comm : Commutative (_*ᴹ_ {n})
+ᴹ-identityˡ : LeftIdentity (0ᴹ {n}) _+ᴹ_
*ᴹ-identityˡ : LeftIdentity (1ᴹ {n}) _*ᴹ_
+ᴹ-identityʳ : RightIdentity (0ᴹ {n}) _+ᴹ_
*ᴹ-identityʳ : RightIdentity (1ᴹ {n}) _*ᴹ_
+ᴹ-identity : Identity (0ᴹ {n}) _+ᴹ_
*ᴹ-identity : Identity (1ᴹ {n}) _*ᴹ_
-ᴹ‿cong : Congruent₁ (-ᴹ_ {n})
-ᴹ‿inverseˡ : AD'.LeftInverse (0ᴹ {n}) -ᴹ_ _+ᴹ_
-ᴹ‿inverseʳ : AD'.RightInverse (0ᴹ {n}) -ᴹ_ _+ᴹ_
-ᴹ‿inverse : AD'.Inverse (0ᴹ {n}) -ᴹ_ _+ᴹ_
*ₗ-cong : LD.Congruent SR._≈_ (_*ₗ_ {n})
*ₗ-zeroˡ : LD.LeftZero SR.0# (0ᴹ {n}) _*ₗ_
*ₗ-distribʳ : _*ₗ_ LD.DistributesOverʳ SR._+_ ⟶ (_+ᴹ_ {n})
*ₗ-identityˡ : LD.LeftIdentity SR.1# (_*ₗ_ {n})
*ₗ-assoc : LD.Associative SR._*_ (_*ₗ_ {n})
*ₗ-zeroʳ : LD.RightZero (0ᴹ {n}) _*ₗ_
*ₗ-distribˡ : _*ₗ_ LD.DistributesOverˡ (_+ᴹ_ {n})
*ᵣ-cong : RD.Congruent SR._≈_ (_*ᵣ_ {n})
*ᵣ-distribˡ : _*ᵣ_ RD.DistributesOverˡ SR._+_ ⟶ (_+ᴹ_ {n})
*ᵣ-zeroˡ : RD.LeftZero (0ᴹ {n}) _*ᵣ_
*ᵣ-identityʳ : RD.RightIdentity SR.1# (_*ᵣ_ {n})
*ᵣ-assoc : RD.Associative SR._*_ (_*ᵣ_ {n})
*ᵣ-zeroʳ : RD.RightZero SR.0# (0ᴹ {n}) _*ᵣ_
*ᵣ-distribʳ : _*ᵣ_ RD.DistributesOverʳ (_+ᴹ_ {n})
*ₗ-*ᵣ-assoc : BD.Associative (_*ₗ_ {n}) _*ᵣ_
*ᴹ-zeroˡ : AD'.LeftZero (0ᴹ {n}) _*ᴹ_
*ᴹ-zeroʳ : AD'.RightZero (0ᴹ {n}) _*ᴹ_
*ᴹ-zero : AD'.Zero (0ᴹ {n}) _*ᴹ_
*ᴹ-+ᴹ-distribˡ : (_*ᴹ_ {n}) AD'.DistributesOverˡ _+ᴹ_
*ᴹ-+ᴹ-distribʳ : (_*ᴹ_ {n}) AD'.DistributesOverʳ _+ᴹ_
*ᴹ-+ᴹ-distrib : (_*ᴹ_ {n}) AD'.DistributesOver _+ᴹ_
```

* Added structures in `Data.Vec.Functional.Algebra.Properties`
```agda
isMagma : IsMagma (_+ᴹ_ {n})
*ᴹ-isMagma : IsMagma (_*ᴹ_ {n})
isCommutativeMagma : IsCommutativeMagma (_+ᴹ_ {n})
isSemigroup : IsSemigroup (_+ᴹ_ {n})
*ᴹ-isSemigroup : IsSemigroup (_*ᴹ_ {n})
isCommutativeSemigroup : IsCommutativeSemigroup (_+ᴹ_ {n})
isMonoid : IsMonoid (_+ᴹ_ {n}) 0ᴹ
*ᴹ-isMonoid : IsMonoid (_*ᴹ_ {n}) 1ᴹ
isCommutativeMonoid : IsCommutativeMonoid (_+ᴹ_ {n}) 0ᴹ
isGroup : IsGroup (_+ᴹ_ {n}) 0ᴹ -ᴹ_
isAbelianGroup : IsAbelianGroup (_+ᴹ_ {n}) 0ᴹ -ᴹ_
isPreleftSemimodule : IsPreleftSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ₗ_
isPrerightSemimodule : IsPrerightSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ᵣ_
isRightSemimodule : IsRightSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ᵣ_
isBisemimodule : IsBisemimodule semiring semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ₗ_ _*ᵣ_
isRightModule : IsRightModule ring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ -ᴹ_ _*ᵣ_
isBimodule : IsBimodule ring ring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_
isLeftSemimodule : IsLeftSemimodule semiring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ _*ₗ_
isLeftModule : IsLeftModule ring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_
isModule : IsModule cring (_≈ᴹ_ {n}) _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_
+ᴹ-*-isNearSemiring : IsNearSemiring (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ
+ᴹ-*-isSemiringWithoutOne : IsSemiringWithoutOne (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ
+ᴹ-*-isCommutativeSemiringWithoutOne : IsCommutativeSemiringWithoutOne (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ
+ᴹ-*-isSemiringWithoutAnnihilatingZero : IsSemiringWithoutAnnihilatingZero (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ 1ᴹ
+ᴹ-*-isSemiring : IsSemiring (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ 1ᴹ
+ᴹ-*-isCommutativeSemiring : IsCommutativeSemiring (_+ᴹ_ {n}) _*ᴹ_ 0ᴹ 1ᴹ
+ᴹ-*-isRingWithoutOne : IsRingWithoutOne (_+ᴹ_ {n}) _*ᴹ_ -ᴹ_ 0ᴹ
+ᴹ-*-isRing : IsRing (_+ᴹ_ {n}) _*ᴹ_ -ᴹ_ 0ᴹ 1ᴹ
+ᴹ-*-isCommutativeRing : IsCommutativeRing (_+ᴹ_ {n}) _*ᴹ_ -ᴹ_ 0ᴹ 1ᴹ
```

* Added bundles in `Data.Vec.Functional.Algebra.Properties`
```agda
magma : ℕ → Magma _ _
*ᴹ-magma : ℕ → Magma _ _
commutativeMagma : ℕ → CommutativeMagma _ _
semigroup : ℕ → Semigroup _ _
*ᴹ-semigroup : ℕ → Semigroup _ _
commutativeSemigroup : ℕ → CommutativeSemigroup _ _
monoid : ℕ → Monoid _ _
*ᴹ-monoid : ℕ → Monoid _ _
commutativeMonoid : ℕ → CommutativeMonoid _ _
group : ℕ → Group _ _
leftSemimodule : ℕ → LeftSemimodule _ _ _
leftModule : ℕ → LeftModule _ _ _
bisemimodule : ℕ → Bisemimodule _ _ _ _
rightModule : ℕ → RightModule _ _ _
bimodule : ℕ → Bimodule _ _ _ _
module' : ℕ → Module _ _ _
+ᴹ-*-nearSemiring : ℕ → NearSemiring _ _
+ᴹ-*-semiringWithoutOne : ℕ → SemiringWithoutOne _ _
+ᴹ-*-commutativeSemiringWithoutOne : ℕ → CommutativeSemiringWithoutOne _ _
+ᴹ-*-semiringWithoutAnnihilatingZero : ℕ → SemiringWithoutAnnihilatingZero _ _
+ᴹ-*-semiring : ℕ → Semiring _ _
+ᴹ-*-commutativeSemiring : ℕ → CommutativeSemiring _ _
+ᴹ-*-ringWithoutOne : ℕ → RingWithoutOne _ _
```
53 changes: 53 additions & 0 deletions src/Data/Vec/Functional/Algebra/Base.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
------------------------------------------------------------------------
-- 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 ℓ} (cring : CommutativeRing c ℓ) where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy about this whole module being parameterized on CommutativeRing, as many of the definitions work with smaller algebraic structures, but I'm not sure what to do about it. Maybe other people have some ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't (yet) looked at this too closely, but it seems as though we might more generally want d isX implies (Vector n d) isX and then if d is suitable as X scalars for the right notion of IsYModule over X then (Vector n d) isYModule over d...?


private variable
n : ℕ

open CommutativeRing cring
open VecSetoid setoid

_≈ᴹ_ : Rel (Vector Carrier n) ℓ
_≈ᴹ_ = _≋_

_+ᴹ_ : Op₂ $ Vector Carrier n
_+ᴹ_ = zipWith _+_

_*ᴹ_ : Op₂ $ Vector Carrier n
_*ᴹ_ = zipWith _*_

0ᴹ : Vector Carrier n
0ᴹ = replicate 0#

1ᴹ : Vector Carrier n
1ᴹ = replicate 1#

-ᴹ_ : Op₁ $ Vector Carrier n
-ᴹ_ = map $ -_

_*ₗ_ : Opₗ Carrier (Vector Carrier n)
_*ₗ_ r = map (r *_)

_*ᵣ_ : Opᵣ Carrier (Vector Carrier n)
xs *ᵣ r = map (_* r) xs
Loading