Debian Codegraph @

src/Algebra/Properties/Semiring/Mult.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Multiplication by a natural number over a semiring
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Algebra.Bundles using (Semiring)
10
11 module Algebra.Properties.Semiring.Mult
12 {a ℓ} (S : Semiring a ℓ) where
13
14 open import Data.Nat.Base as ℕ using (zero; suc)
15
16 open Semiring S renaming (zero to *-zero)
17
18 open import Relation.Binary.Reasoning.Setoid setoid
19 open import Algebra.Definitions _≈_ using (_IdempotentOn_)
20
21 ------------------------------------------------------------------------
22 -- Re-export definition from the monoid
23
24 open import Algebra.Properties.Monoid.Mult +-monoid public
25
26 ------------------------------------------------------------------------
27 -- Properties of _×_
28
29 -- (0 ×_) is (0# *_)
30
31 ×-homo-0# : ∀ x → 0 × x ≈ 0# * x
32 ×-homo-0# x = sym (zeroˡ x)
33
34 -- (1 ×_) is (1# *_)
35
36 ×-homo-1# : ∀ x → 1 × x ≈ 1# * x
37 ×-homo-1# x = trans (×-homo-1 x) (sym (*-identityˡ x))
38
39 -- (n ×_) commutes with _*_
40
41 ×-comm-* : ∀ n x y → x * (n × y) ≈ n × (x * y)
42 ×-comm-* zero x y = zeroʳ x
43 ×-comm-* (suc n) x y = begin
44 x * (suc n × y) ≡⟨⟩
45 x * (y + n × y) ≈⟨ distribˡ _ _ _ ⟩
46 x * y + x * (n × y) ≈⟨ +-congˡ (×-comm-* n _ _) ⟩
47 x * y + n × (x * y) ≡⟨⟩
48 suc n × (x * y) ∎
49
50 -- (n ×_) associates with _*_
51
52 ×-assoc-* : ∀ n x y → (n × x) * y ≈ n × (x * y)
53 ×-assoc-* zero x y = zeroˡ y
54 ×-assoc-* (suc n) x y = begin
55 (suc n × x) * y ≡⟨⟩
56 (x + n × x) * y ≈⟨ distribʳ _ _ _ ⟩
57 x * y + (n × x) * y ≈⟨ +-congˡ (×-assoc-* n _ _) ⟩
58 x * y + n × (x * y) ≡⟨⟩
59 suc n × (x * y) ∎
60
61 -- (_× x) is homomorphic with respect to _ℕ.*_/_*_ for idempotent x.
62
63 idem-×-homo-* : ∀ m n {x} → (_*_ IdempotentOn x) → (m × x) * (n × x) ≈ (m ℕ.* n) × x
64 idem-×-homo-* m n {x} idem = begin
65 (m × x) * (n × x) ≈⟨ ×-assoc-* m x (n × x) ⟩
66 m × (x * (n × x)) ≈⟨ ×-congʳ m (×-comm-* n x x) ⟩
67 m × (n × (x * x)) ≈⟨ ×-assocˡ _ m n ⟩
68 (m ℕ.* n) × (x * x) ≈⟨ ×-congʳ (m ℕ.* n) idem ⟩
69 (m ℕ.* n) × x ∎
70
71 -- (_× 1#) is homomorphic with respect to _ℕ.*_/_*_.
72
73 ×1-homo-* : ∀ m n → (m ℕ.* n) × 1# ≈ (m × 1#) * (n × 1#)
74 ×1-homo-* m n = sym (idem-×-homo-* m n (*-identityʳ 1#))
75
76 ------------------------------------------------------------------------
77 -- DEPRECATED NAMES
78 ------------------------------------------------------------------------
79 -- Please use the new names as continuing support for the old names is
80 -- not guaranteed.
81
82 -- Version 2.1
83
84 1×-identityʳ = ×-homo-1
85 {-# WARNING_ON_USAGE 1×-identityʳ
86 "Warning: 1×-identityʳ was deprecated in v2.1.
87 Please use ×-homo-1 instead. "
88 #-}