-
Notifications
You must be signed in to change notification settings - Fork 247
/
Copy pathDivisibility.agda
152 lines (119 loc) · 4.84 KB
/
Divisibility.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
------------------------------------------------------------------------
-- The Agda standard library
--
-- Divisibility over magmas
------------------------------------------------------------------------
{-# OPTIONS --cubical-compatible --safe #-}
open import Algebra.Bundles using (Magma)
module Algebra.Properties.Magma.Divisibility {a ℓ} (M : Magma a ℓ) where
open import Data.Product.Base using (_,_; swap)
open import Relation.Binary.Definitions
using (_Respects_; _Respectsˡ_; _Respectsʳ_; _Respects₂_; Symmetric)
open import Relation.Nullary.Negation.Core using (contradiction)
open Magma M
------------------------------------------------------------------------
-- Re-export divisibility relations publicly
open import Algebra.Definitions.RawMagma rawMagma public
using (_∣_; _∤_; _∥_; _∦_; _∣ˡ_; _∤ˡ_; _∣ʳ_; _∤ʳ_; _,_)
------------------------------------------------------------------------
-- Properties of divisibility
∣-respʳ-≈ : _∣_ Respectsʳ _≈_
∣-respʳ-≈ y≈z (q , qx≈y) = q , trans qx≈y y≈z
∣-respˡ-≈ : _∣_ Respectsˡ _≈_
∣-respˡ-≈ x≈z (q , qx≈y) = q , trans (∙-congˡ (sym x≈z)) qx≈y
∣-resp-≈ : _∣_ Respects₂ _≈_
∣-resp-≈ = ∣-respʳ-≈ , ∣-respˡ-≈
x∣yx : ∀ x y → x ∣ y ∙ x
x∣yx x y = y , refl
xy≈z⇒y∣z : ∀ x y {z} → x ∙ y ≈ z → y ∣ z
xy≈z⇒y∣z x y xy≈z = ∣-respʳ-≈ xy≈z (x∣yx y x)
------------------------------------------------------------------------
-- Properties of non-divisibility
∤-respˡ-≈ : _∤_ Respectsˡ _≈_
∤-respˡ-≈ x≈y x∤z y∣z = contradiction (∣-respˡ-≈ (sym x≈y) y∣z) x∤z
∤-respʳ-≈ : _∤_ Respectsʳ _≈_
∤-respʳ-≈ x≈y z∤x z∣y = contradiction (∣-respʳ-≈ (sym x≈y) z∣y) z∤x
∤-resp-≈ : _∤_ Respects₂ _≈_
∤-resp-≈ = ∤-respʳ-≈ , ∤-respˡ-≈
------------------------------------------------------------------------
-- Properties of mutual divisibility _∥_
∥-sym : Symmetric _∥_
∥-sym = swap
∥-respˡ-≈ : _∥_ Respectsˡ _≈_
∥-respˡ-≈ x≈z (x∣y , y∣x) = ∣-respˡ-≈ x≈z x∣y , ∣-respʳ-≈ x≈z y∣x
∥-respʳ-≈ : _∥_ Respectsʳ _≈_
∥-respʳ-≈ y≈z (x∣y , y∣x) = ∣-respʳ-≈ y≈z x∣y , ∣-respˡ-≈ y≈z y∣x
∥-resp-≈ : _∥_ Respects₂ _≈_
∥-resp-≈ = ∥-respʳ-≈ , ∥-respˡ-≈
------------------------------------------------------------------------
-- Properties of mutual non-divisibility _∤∤_
∦-sym : Symmetric _∦_
∦-sym x∦y y∥x = contradiction (∥-sym y∥x) x∦y
∦-respˡ-≈ : _∦_ Respectsˡ _≈_
∦-respˡ-≈ x≈y x∦z y∥z = contradiction (∥-respˡ-≈ (sym x≈y) y∥z) x∦z
∦-respʳ-≈ : _∦_ Respectsʳ _≈_
∦-respʳ-≈ x≈y z∦x z∥y = contradiction (∥-respʳ-≈ (sym x≈y) z∥y) z∦x
∦-resp-≈ : _∦_ Respects₂ _≈_
∦-resp-≈ = ∦-respʳ-≈ , ∦-respˡ-≈
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 2.2
∣-respˡ = ∣-respˡ-≈
{-# WARNING_ON_USAGE ∣-respˡ
"Warning: ∣-respˡ was deprecated in v2.2.
Please use ∣-respˡ-≈ instead. "
#-}
∣-respʳ = ∣-respʳ-≈
{-# WARNING_ON_USAGE ∣-respʳ
"Warning: ∣-respʳ was deprecated in v2.2.
Please use ∣-respʳ-≈ instead. "
#-}
∣-resp = ∣-resp-≈
{-# WARNING_ON_USAGE ∣-resp
"Warning: ∣-resp was deprecated in v2.2.
Please use ∣-resp-≈ instead. "
#-}
-- Version 2.3
∣∣-sym = ∥-sym
{-# WARNING_ON_USAGE ∣∣-sym
"Warning: ∣∣-sym was deprecated in v2.3.
Please use ∥-sym instead. "
#-}
∣∣-respˡ-≈ = ∥-respˡ-≈
{-# WARNING_ON_USAGE ∣∣-respˡ-≈
"Warning: ∣∣-respˡ-≈ was deprecated in v2.3.
Please use ∥-respˡ-≈ instead. "
#-}
∣∣-respʳ-≈ = ∥-respʳ-≈
{-# WARNING_ON_USAGE ∣∣-respʳ-≈
"Warning: ∣∣-respʳ-≈ was deprecated in v2.3.
Please use ∥-respʳ-≈ instead. "
#-}
∣∣-resp-≈ = ∥-resp-≈
{-# WARNING_ON_USAGE ∣∣-resp-≈
"Warning: ∣∣-resp-≈ was deprecated in v2.3.
Please use ∥-resp-≈ instead. "
#-}
∤∤-sym = ∦-sym
{-# WARNING_ON_USAGE ∤∤-sym
"Warning: ∤∤-sym was deprecated in v2.3.
Please use ∦-sym instead. "
#-}
∤∤-respˡ-≈ = ∦-respˡ-≈
{-# WARNING_ON_USAGE ∤∤-respˡ-≈
"Warning: ∤∤-respˡ-≈ was deprecated in v2.3.
Please use ∦-respˡ-≈ instead. "
#-}
∤∤-respʳ-≈ = ∦-respʳ-≈
{-# WARNING_ON_USAGE ∤∤-respʳ-≈
"Warning: ∤∤-respʳ-≈ was deprecated in v2.3.
Please use ∦-respʳ-≈ instead. "
#-}
∤∤-resp-≈ = ∦-resp-≈
{-# WARNING_ON_USAGE ∤∤-resp-≈
"Warning: ∤∤-resp-≈ was deprecated in v2.3.
Please use ∦-resp-≈ instead. "
#-}