| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Multiplication over a monoid (i.e. repeated addition) |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Bundles using (CommutativeMonoid) |
| 10 |
open import Data.Nat.Base as ℕ using (ℕ; zero; suc) |
| 11 |
|
| 12 |
module Algebra.Properties.CommutativeMonoid.Mult |
| 13 |
{a ℓ} (M : CommutativeMonoid a ℓ) where |
| 14 |
|
| 15 |
-- View of the monoid operator as addition |
| 16 |
open CommutativeMonoid M |
| 17 |
renaming |
| 18 |
( _∙_ to _+_ |
| 19 |
; ∙-cong to +-cong |
| 20 |
; ∙-congʳ to +-congʳ |
| 21 |
; ∙-congˡ to +-congˡ |
| 22 |
; identityˡ to +-identityˡ |
| 23 |
; identityʳ to +-identityʳ |
| 24 |
; assoc to +-assoc |
| 25 |
; ε to 0# |
| 26 |
) |
| 27 |
|
| 28 |
open import Relation.Binary.Reasoning.Setoid setoid |
| 29 |
open import Algebra.Properties.CommutativeSemigroup commutativeSemigroup |
| 30 |
|
| 31 |
------------------------------------------------------------------------ |
| 32 |
-- Re-export definition and properties for monoids |
| 33 |
|
| 34 |
open import Algebra.Properties.Monoid.Mult monoid public |
| 35 |
|
| 36 |
------------------------------------------------------------------------ |
| 37 |
-- Properties of _×_ |
| 38 |
|
| 39 |
×-distrib-+ : ∀ x y n → n × (x + y) ≈ n × x + n × y |
| 40 |
×-distrib-+ x y zero = sym (+-identityˡ 0# ) |
| 41 |
×-distrib-+ x y (suc n) = begin |
| 42 |
x + y + n × (x + y) ≈⟨ +-congˡ (×-distrib-+ x y n) ⟩ |
| 43 |
x + y + (n × x + n × y) ≈⟨ +-assoc x y (n × x + n × y) ⟩ |
| 44 |
x + (y + (n × x + n × y)) ≈⟨ +-congˡ (x∙yz≈y∙xz y (n × x) (n × y)) ⟩ |
| 45 |
x + (n × x + suc n × y) ≈⟨ x∙yz≈xy∙z x (n × x) (suc n × y) ⟩ |
| 46 |
suc n × x + suc n × y ∎ |