File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
src/Algebra/Properties/Semiring Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,11 @@ New modules
147
147
Algebra.Construct.LexProduct.Inner
148
148
```
149
149
150
+ * Properties of sums over semirings
151
+ ```
152
+ Algebra.Properties.Semiring.Sum
153
+ ```
154
+
150
155
* Sorting algorithms over lists:
151
156
```
152
157
Data.List.Sort
Original file line number Diff line number Diff line change
1
+ ------------------------------------------------------------------------
2
+ -- The Agda standard library
3
+ --
4
+ -- Finite summations over a semiring
5
+ ------------------------------------------------------------------------
6
+
7
+ {-# OPTIONS --without-K --safe #-}
8
+
9
+ open import Algebra.Bundles using (Semiring)
10
+
11
+ module Algebra.Properties.Semiring.Sum {c} {ℓ} (R : Semiring c ℓ) where
12
+
13
+ open import Data.Nat.Base using (zero; suc)
14
+ open import Data.Vec.Functional
15
+ open Semiring R
16
+
17
+ ------------------------------------------------------------------------
18
+ -- Re-export summation over monoids
19
+
20
+ open import Algebra.Properties.CommutativeMonoid.Sum +-commutativeMonoid public
21
+
22
+ ------------------------------------------------------------------------
23
+ -- Properties
24
+
25
+ *-distribˡ-sum : ∀ {n} x (ys : Vector Carrier n) → x * sum ys ≈ sum (map (x *_) ys)
26
+ *-distribˡ-sum {zero} x ys = zeroʳ x
27
+ *-distribˡ-sum {suc n} x ys = trans (distribˡ x (head ys) (sum (tail ys))) (+-congˡ (*-distribˡ-sum x (tail ys)))
28
+
29
+ *-distribʳ-sum : ∀ {n} x (ys : Vector Carrier n) → sum ys * x ≈ sum (map (_* x) ys)
30
+ *-distribʳ-sum {zero} x ys = zeroˡ x
31
+ *-distribʳ-sum {suc n} x ys = trans (distribʳ x (head ys) (sum (tail ys))) (+-congˡ (*-distribʳ-sum x (tail ys)))
You can’t perform that action at this time.
0 commit comments