forked from agda/agda-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDivisibility.agda
46 lines (35 loc) · 1.82 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
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of divisibility over commutative semigroups
------------------------------------------------------------------------
{-# OPTIONS --cubical-compatible --safe #-}
open import Algebra using (CommutativeSemigroup)
open import Data.Product.Base using (_,_)
import Relation.Binary.Reasoning.Setoid as EqReasoning
module Algebra.Properties.CommutativeSemigroup.Divisibility
{a ℓ} (CS : CommutativeSemigroup a ℓ)
where
open CommutativeSemigroup CS
open import Algebra.Properties.CommutativeSemigroup CS using (x∙yz≈xz∙y; x∙yz≈y∙xz)
open EqReasoning setoid
------------------------------------------------------------------------
-- Re-export the contents of divisibility over semigroups
open import Algebra.Properties.Semigroup.Divisibility semigroup public
------------------------------------------------------------------------
-- Re-export the contents of divisibility over commutative magmas
open import Algebra.Properties.CommutativeMagma.Divisibility commutativeMagma public
using (x∣xy; xy≈z⇒x∣z; ∣-factors; ∣-factors-≈)
------------------------------------------------------------------------
-- New properties
x∣y∧z∣x/y⇒xz∣y : ∀ {x y z} → ((x/y , _) : x ∣ y) → z ∣ x/y → x ∙ z ∣ y
x∣y∧z∣x/y⇒xz∣y {x} {y} {z} (x/y , x/y∙x≈y) (p , pz≈x/y) = p , (begin
p ∙ (x ∙ z) ≈⟨ x∙yz≈xz∙y p x z ⟩
(p ∙ z) ∙ x ≈⟨ ∙-congʳ pz≈x/y ⟩
x/y ∙ x ≈⟨ x/y∙x≈y ⟩
y ∎)
x∣y⇒zx∣zy : ∀ {x y} z → x ∣ y → z ∙ x ∣ z ∙ y
x∣y⇒zx∣zy {x} {y} z (q , qx≈y) = q , (begin
q ∙ (z ∙ x) ≈⟨ x∙yz≈y∙xz q z x ⟩
z ∙ (q ∙ x) ≈⟨ ∙-congˡ qx≈y ⟩
z ∙ y ∎)