| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Basic auxiliary definitions for magma-like structures |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- You're unlikely to want to use this module directly. Instead you |
| 8 |
-- probably want to be importing the appropriate module from |
| 9 |
-- `Algebra.Properties.(Magma/Semigroup/...).Divisibility` |
| 10 |
|
| 11 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 12 |
|
| 13 |
open import Algebra.Bundles.Raw using (RawMagma) |
| 14 |
open import Data.Product.Base using (_×_) |
| 15 |
open import Level using (_⊔_) |
| 16 |
open import Relation.Binary.Core using (Rel) |
| 17 |
open import Relation.Nullary.Negation.Core using (¬_) |
| 18 |
|
| 19 |
module Algebra.Definitions.RawMagma |
| 20 |
{a ℓ} (M : RawMagma a ℓ) |
| 21 |
where |
| 22 |
|
| 23 |
open RawMagma M renaming (Carrier to A) |
| 24 |
|
| 25 |
------------------------------------------------------------------------ |
| 26 |
-- Divisibility |
| 27 |
|
| 28 |
infixr 4 _,_ |
| 29 |
infix 5 _∣ˡ_ _∤ˡ_ _∣ʳ_ _∤ʳ_ _∣_ _∤_ _∥_ _∦_ |
| 30 |
|
| 31 |
-- Divisibility from the left. |
| 32 |
-- |
| 33 |
-- This and, the definition of right divisibility below, are defined as |
| 34 |
-- records rather than in terms of the base product type in order to |
| 35 |
-- make the use of pattern synonyms more ergonomic (see #2216 for |
| 36 |
-- further details). The record field names are not designed to be |
| 37 |
-- used explicitly and indeed aren't re-exported publicly by |
| 38 |
-- `Algebra.Properties.X.Divisibility` modules. |
| 39 |
|
| 40 |
record _∣ˡ_ (x y : A) : Set (a ⊔ ℓ) where |
| 41 |
constructor _,_ |
| 42 |
field |
| 43 |
quotient : A |
| 44 |
equality : x ∙ quotient ≈ y |
| 45 |
|
| 46 |
_∤ˡ_ : Rel A (a ⊔ ℓ) |
| 47 |
x ∤ˡ y = ¬ x ∣ˡ y |
| 48 |
|
| 49 |
-- Divisibility from the right |
| 50 |
|
| 51 |
record _∣ʳ_ (x y : A) : Set (a ⊔ ℓ) where |
| 52 |
constructor _,_ |
| 53 |
field |
| 54 |
quotient : A |
| 55 |
equality : quotient ∙ x ≈ y |
| 56 |
|
| 57 |
_∤ʳ_ : Rel A (a ⊔ ℓ) |
| 58 |
x ∤ʳ y = ¬ x ∣ʳ y |
| 59 |
|
| 60 |
-- General divisibility |
| 61 |
|
| 62 |
-- The relations _∣ˡ_ and _∣ʳ_ are only equivalent when _∙_ is |
| 63 |
-- commutative. When that is not the case we take `_∣ʳ_` to be the |
| 64 |
-- primary one. |
| 65 |
|
| 66 |
_∣_ : Rel A (a ⊔ ℓ) |
| 67 |
_∣_ = _∣ʳ_ |
| 68 |
|
| 69 |
_∤_ : Rel A (a ⊔ ℓ) |
| 70 |
x ∤ y = ¬ x ∣ y |
| 71 |
|
| 72 |
------------------------------------------------------------------------ |
| 73 |
-- Mutual divisibility. |
| 74 |
|
| 75 |
-- In a monoid, this is an equivalence relation extending _≈_. |
| 76 |
-- When in a cancellative monoid, elements related by _∣∣_ are called |
| 77 |
-- associated, and `x ∣∣ y` means that `x` and `y` differ by some |
| 78 |
-- invertible factor. |
| 79 |
|
| 80 |
-- Example: for ℕ this is equivalent to x ≡ y, |
| 81 |
-- for ℤ this is equivalent to (x ≡ y or x ≡ - y). |
| 82 |
|
| 83 |
_∥_ : Rel A (a ⊔ ℓ) |
| 84 |
x ∥ y = x ∣ y × y ∣ x |
| 85 |
|
| 86 |
_∦_ : Rel A (a ⊔ ℓ) |
| 87 |
x ∦ y = ¬ x ∥ y |
| 88 |
|
| 89 |
|
| 90 |
------------------------------------------------------------------------ |
| 91 |
-- DEPRECATED NAMES |
| 92 |
------------------------------------------------------------------------ |
| 93 |
-- Please use the new names as continuing support for the old names is |
| 94 |
-- not guaranteed. |
| 95 |
|
| 96 |
-- Version 2.3 |
| 97 |
|
| 98 |
_∣∣_ = _∥_ |
| 99 |
{-# WARNING_ON_USAGE _∣∣_ |
| 100 |
"Warning: _∣∣_ was deprecated in v2.3. |
| 101 |
Please use _∥_ instead." |
| 102 |
#-} |
| 103 |
_∤∤_ = _∦_ |
| 104 |
{-# WARNING_ON_USAGE _∤∤_ |
| 105 |
"Warning: _∤∤_ was deprecated in v2.3. |
| 106 |
Please use _∦_ instead." |
| 107 |
#-} |
| 108 |
|