| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Consequences of a monomorphism between ring-like structures |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- See Data.Nat.Binary.Properties for examples of how this and similar |
| 8 |
-- modules can be used to easily translate properties between types. |
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
open import Algebra.Bundles using (RawRing) |
| 13 |
open import Algebra.Morphism.Structures using (IsRingMonomorphism) |
| 14 |
|
| 15 |
|
| 16 |
module Algebra.Morphism.RingMonomorphism |
| 17 |
{a b ℓ₁ ℓ₂} {R₁ : RawRing a ℓ₁} {R₂ : RawRing b ℓ₂} {⟦_⟧} |
| 18 |
(isRingMonomorphism : IsRingMonomorphism R₁ R₂ ⟦_⟧) |
| 19 |
where |
| 20 |
|
| 21 |
open IsRingMonomorphism isRingMonomorphism |
| 22 |
open RawRing R₁ renaming (Carrier to A; _≈_ to _≈₁_) |
| 23 |
open RawRing R₂ renaming |
| 24 |
( Carrier to B; _≈_ to _≈₂_; _+_ to _⊕_ |
| 25 |
; _*_ to _⊛_; 1# to 1#₂; 0# to 0#₂; -_ to ⊝_) |
| 26 |
import Algebra.Morphism.GroupMonomorphism as GroupMonomorphism |
| 27 |
import Algebra.Morphism.MonoidMonomorphism as MonoidMonomorphism |
| 28 |
open import Relation.Binary.Core using (Rel) |
| 29 |
open import Algebra.Definitions |
| 30 |
using (_DistributesOverˡ_; _DistributesOverʳ_ ; _DistributesOver_ |
| 31 |
; LeftZero; RightZero; Zero) |
| 32 |
open import Algebra.Structures |
| 33 |
using (IsRing; IsCommutativeRing; IsGroup; IsMagma) |
| 34 |
open import Data.Product.Base using (proj₁; proj₂; _,_) |
| 35 |
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning |
| 36 |
|
| 37 |
------------------------------------------------------------------------ |
| 38 |
-- Re-export all properties of group and monoid monomorphisms |
| 39 |
|
| 40 |
open GroupMonomorphism +-isGroupMonomorphism public |
| 41 |
renaming |
| 42 |
( assoc to +-assoc |
| 43 |
; comm to +-comm |
| 44 |
; cong to +-cong |
| 45 |
; idem to +-idem |
| 46 |
; sel to +-sel |
| 47 |
; ⁻¹-cong to neg-cong |
| 48 |
|
| 49 |
; identity to +-identity; identityˡ to +-identityˡ; identityʳ to +-identityʳ |
| 50 |
; cancel to +-cancel; cancelˡ to +-cancelˡ; cancelʳ to +-cancelʳ |
| 51 |
; zero to +-zero; zeroˡ to +-zeroˡ; zeroʳ to +-zeroʳ |
| 52 |
|
| 53 |
; isMagma to +-isMagma |
| 54 |
; isSemigroup to +-isSemigroup |
| 55 |
; isMonoid to +-isMonoid |
| 56 |
; isSelectiveMagma to +-isSelectiveMagma |
| 57 |
; isBand to +-isBand |
| 58 |
; isCommutativeMonoid to +-isCommutativeMonoid |
| 59 |
) |
| 60 |
|
| 61 |
open MonoidMonomorphism *-isMonoidMonomorphism public |
| 62 |
renaming |
| 63 |
( assoc to *-assoc |
| 64 |
; comm to *-comm |
| 65 |
; cong to *-cong |
| 66 |
; idem to *-idem |
| 67 |
; sel to *-sel |
| 68 |
|
| 69 |
; identity to *-identity; identityˡ to *-identityˡ; identityʳ to *-identityʳ |
| 70 |
; cancel to *-cancel; cancelˡ to *-cancelˡ; cancelʳ to *-cancelʳ |
| 71 |
; zero to *-zero; zeroˡ to *-zeroˡ; zeroʳ to *-zeroʳ |
| 72 |
|
| 73 |
; isMagma to *-isMagma |
| 74 |
; isSemigroup to *-isSemigroup |
| 75 |
; isMonoid to *-isMonoid |
| 76 |
; isSelectiveMagma to *-isSelectiveMagma |
| 77 |
; isBand to *-isBand |
| 78 |
; isCommutativeMonoid to *-isCommutativeMonoid |
| 79 |
) |
| 80 |
|
| 81 |
------------------------------------------------------------------------ |
| 82 |
-- Properties |
| 83 |
|
| 84 |
module _ (+-isGroup : IsGroup _≈₂_ _⊕_ 0#₂ ⊝_) |
| 85 |
(*-isMagma : IsMagma _≈₂_ _⊛_) where |
| 86 |
|
| 87 |
open IsGroup +-isGroup hiding (setoid; refl; sym) |
| 88 |
open IsMagma *-isMagma renaming (∙-cong to ◦-cong) |
| 89 |
open ≈-Reasoning setoid |
| 90 |
|
| 91 |
distribˡ : _DistributesOverˡ_ _≈₂_ _⊛_ _⊕_ → _DistributesOverˡ_ _≈₁_ _*_ _+_ |
| 92 |
distribˡ distribˡ x y z = injective (begin |
| 93 |
⟦ x * (y + z) ⟧ ≈⟨ *-homo x (y + z) ⟩ |
| 94 |
⟦ x ⟧ ⊛ ⟦ y + z ⟧ ≈⟨ ◦-cong refl (+-homo y z) ⟩ |
| 95 |
⟦ x ⟧ ⊛ (⟦ y ⟧ ⊕ ⟦ z ⟧) ≈⟨ distribˡ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ ⟩ |
| 96 |
⟦ x ⟧ ⊛ ⟦ y ⟧ ⊕ ⟦ x ⟧ ⊛ ⟦ z ⟧ ≈⟨ ∙-cong (*-homo x y) (*-homo x z) ⟨ |
| 97 |
⟦ x * y ⟧ ⊕ ⟦ x * z ⟧ ≈⟨ +-homo (x * y) (x * z) ⟨ |
| 98 |
⟦ x * y + x * z ⟧ ∎) |
| 99 |
|
| 100 |
distribʳ : _DistributesOverʳ_ _≈₂_ _⊛_ _⊕_ → _DistributesOverʳ_ _≈₁_ _*_ _+_ |
| 101 |
distribʳ distribˡ x y z = injective (begin |
| 102 |
⟦ (y + z) * x ⟧ ≈⟨ *-homo (y + z) x ⟩ |
| 103 |
⟦ y + z ⟧ ⊛ ⟦ x ⟧ ≈⟨ ◦-cong (+-homo y z) refl ⟩ |
| 104 |
(⟦ y ⟧ ⊕ ⟦ z ⟧) ⊛ ⟦ x ⟧ ≈⟨ distribˡ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ ⟩ |
| 105 |
⟦ y ⟧ ⊛ ⟦ x ⟧ ⊕ ⟦ z ⟧ ⊛ ⟦ x ⟧ ≈⟨ ∙-cong (*-homo y x) (*-homo z x) ⟨ |
| 106 |
⟦ y * x ⟧ ⊕ ⟦ z * x ⟧ ≈⟨ +-homo (y * x) (z * x) ⟨ |
| 107 |
⟦ y * x + z * x ⟧ ∎) |
| 108 |
|
| 109 |
distrib : _DistributesOver_ _≈₂_ _⊛_ _⊕_ → _DistributesOver_ _≈₁_ _*_ _+_ |
| 110 |
distrib distrib = distribˡ (proj₁ distrib) , distribʳ (proj₂ distrib) |
| 111 |
|
| 112 |
zeroˡ : LeftZero _≈₂_ 0#₂ _⊛_ → LeftZero _≈₁_ 0# _*_ |
| 113 |
zeroˡ zeroˡ x = injective (begin |
| 114 |
⟦ 0# * x ⟧ ≈⟨ *-homo 0# x ⟩ |
| 115 |
⟦ 0# ⟧ ⊛ ⟦ x ⟧ ≈⟨ ◦-cong 0#-homo refl ⟩ |
| 116 |
0#₂ ⊛ ⟦ x ⟧ ≈⟨ zeroˡ ⟦ x ⟧ ⟩ |
| 117 |
0#₂ ≈⟨ 0#-homo ⟨ |
| 118 |
⟦ 0# ⟧ ∎) |
| 119 |
|
| 120 |
zeroʳ : RightZero _≈₂_ 0#₂ _⊛_ → RightZero _≈₁_ 0# _*_ |
| 121 |
zeroʳ zeroʳ x = injective (begin |
| 122 |
⟦ x * 0# ⟧ ≈⟨ *-homo x 0# ⟩ |
| 123 |
⟦ x ⟧ ⊛ ⟦ 0# ⟧ ≈⟨ ◦-cong refl 0#-homo ⟩ |
| 124 |
⟦ x ⟧ ⊛ 0#₂ ≈⟨ zeroʳ ⟦ x ⟧ ⟩ |
| 125 |
0#₂ ≈⟨ 0#-homo ⟨ |
| 126 |
⟦ 0# ⟧ ∎) |
| 127 |
|
| 128 |
zero : Zero _≈₂_ 0#₂ _⊛_ → Zero _≈₁_ 0# _*_ |
| 129 |
zero zero = zeroˡ (proj₁ zero) , zeroʳ (proj₂ zero) |
| 130 |
|
| 131 |
neg-distribˡ-* : (∀ x y → (⊝ (x ⊛ y)) ≈₂ ((⊝ x) ⊛ y)) → (∀ x y → (- (x * y)) ≈₁ ((- x) * y)) |
| 132 |
neg-distribˡ-* neg-distribˡ-* x y = injective (begin |
| 133 |
⟦ - (x * y) ⟧ ≈⟨ -‿homo (x * y) ⟩ |
| 134 |
⊝ ⟦ x * y ⟧ ≈⟨ ⁻¹-cong (*-homo x y) ⟩ |
| 135 |
⊝ (⟦ x ⟧ ⊛ ⟦ y ⟧) ≈⟨ neg-distribˡ-* ⟦ x ⟧ ⟦ y ⟧ ⟩ |
| 136 |
⊝ ⟦ x ⟧ ⊛ ⟦ y ⟧ ≈⟨ ◦-cong (sym (-‿homo x)) refl ⟩ |
| 137 |
⟦ - x ⟧ ⊛ ⟦ y ⟧ ≈⟨ sym (*-homo (- x) y) ⟩ |
| 138 |
⟦ - x * y ⟧ ∎) |
| 139 |
|
| 140 |
neg-distribʳ-* : (∀ x y → (⊝ (x ⊛ y)) ≈₂ (x ⊛ (⊝ y))) → (∀ x y → (- (x * y)) ≈₁ (x * (- y))) |
| 141 |
neg-distribʳ-* neg-distribʳ-* x y = injective (begin |
| 142 |
⟦ - (x * y) ⟧ ≈⟨ -‿homo (x * y) ⟩ |
| 143 |
⊝ ⟦ x * y ⟧ ≈⟨ ⁻¹-cong (*-homo x y) ⟩ |
| 144 |
⊝ (⟦ x ⟧ ⊛ ⟦ y ⟧) ≈⟨ neg-distribʳ-* ⟦ x ⟧ ⟦ y ⟧ ⟩ |
| 145 |
⟦ x ⟧ ⊛ ⊝ ⟦ y ⟧ ≈⟨ ◦-cong refl (sym (-‿homo y)) ⟩ |
| 146 |
⟦ x ⟧ ⊛ ⟦ - y ⟧ ≈⟨ sym (*-homo x (- y)) ⟩ |
| 147 |
⟦ x * - y ⟧ ∎) |
| 148 |
|
| 149 |
isRing : IsRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ → IsRing _≈₁_ _+_ _*_ -_ 0# 1# |
| 150 |
isRing isRing = record |
| 151 |
{ +-isAbelianGroup = isAbelianGroup R.+-isAbelianGroup |
| 152 |
; *-cong = *-cong R.*-isMagma |
| 153 |
; *-assoc = *-assoc R.*-isMagma R.*-assoc |
| 154 |
; *-identity = *-identity R.*-isMagma R.*-identity |
| 155 |
; distrib = distrib R.+-isGroup R.*-isMagma R.distrib |
| 156 |
} where module R = IsRing isRing |
| 157 |
|
| 158 |
isCommutativeRing : IsCommutativeRing _≈₂_ _⊕_ _⊛_ ⊝_ 0#₂ 1#₂ → |
| 159 |
IsCommutativeRing _≈₁_ _+_ _*_ -_ 0# 1# |
| 160 |
isCommutativeRing isCommRing = record |
| 161 |
{ isRing = isRing C.isRing |
| 162 |
; *-comm = *-comm C.*-isMagma C.*-comm |
| 163 |
} where module C = IsCommutativeRing isCommRing |