Skip to content

Commit 714b67f

Browse files
gallaisjamesmckinna
andcommitted
[ fix ] in non-commutative settings distinguish _∣ˡ_ and _∣ʳ_ (agda#2604)
* [ fix ] in non-commutative settings distinguish _∣ˡ_ and _∣ʳ_ * [ new ] Prefix & Suffix as Left & Right division * [ fix ] my cockup * [ new ] ∙-cong-∣ * [ cleanup ] in the commutative case we don't care about the direction * [ refactor ] Moving propositional results in their own module * [ fix ] forgot the OPTIONS * [ cleanup ] According to agda#2631 --------- Co-authored-by: jamesmckinna <[email protected]>
1 parent 8b5a3d2 commit 714b67f

File tree

8 files changed

+256
-44
lines changed

8 files changed

+256
-44
lines changed

src/Algebra/Properties/CommutativeMagma/Divisibility.agda

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ open CommutativeMagma CM using (magma; _≈_; _∙_; comm)
2020
-- Re-export the contents of magmas
2121

2222
open import Algebra.Properties.Magma.Divisibility magma public
23+
using (_∣_; _,_)
24+
renaming ( ∣ʳ-respʳ-≈ to ∣-respʳ-≈
25+
; ∣ʳ-respˡ-≈ to ∣-respˡ-≈
26+
; ∣ʳ-resp-≈ to ∣-resp-≈
27+
; x∣ʳyx to x∣yx
28+
; xy≈z⇒y∣ʳz to xy≈z⇒y∣z
29+
)
2330

2431
------------------------------------------------------------------------
2532
-- Further properties
@@ -36,7 +43,6 @@ x|xy∧y|xy x y = x∣xy x y , x∣yx y x
3643
xy≈z⇒x|z∧y|z : x y {z} x ∙ y ≈ z x ∣ z × y ∣ z
3744
xy≈z⇒x|z∧y|z x y xy≈z = xy≈z⇒x∣z x y xy≈z , xy≈z⇒y∣z x y xy≈z
3845

39-
4046
------------------------------------------------------------------------
4147
-- DEPRECATED NAMES
4248
------------------------------------------------------------------------

src/Algebra/Properties/CommutativeSemigroup/Divisibility.agda

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module Algebra.Properties.CommutativeSemigroup.Divisibility
1515
where
1616

1717
open CommutativeSemigroup CS
18-
open import Algebra.Properties.CommutativeSemigroup CS using (x∙yz≈xz∙y; x∙yz≈y∙xz)
18+
open import Algebra.Properties.CommutativeSemigroup CS
19+
using (interchange; x∙yz≈xz∙y; x∙yz≈y∙xz)
1920
open ≈-Reasoning setoid
2021

2122
------------------------------------------------------------------------
@@ -39,6 +40,12 @@ x∣y∧z∣x/y⇒xz∣y {x} {y} {z} (x/y , x/y∙x≈y) (p , pz≈x/y) = p , (b
3940
x/y ∙ x ≈⟨ x/y∙x≈y ⟩
4041
y ∎)
4142

43+
∙-cong-∣ : {x y a b} x ∣ y a ∣ b x ∙ a ∣ y ∙ b
44+
∙-cong-∣ {x} {y} {a} {b} (p , px≈y) (q , qa≈b) = p ∙ q , (begin
45+
(p ∙ q) ∙ (x ∙ a) ≈⟨ interchange p q x a ⟩
46+
(p ∙ x) ∙ (q ∙ a) ≈⟨ ∙-cong px≈y qa≈b ⟩
47+
y ∙ b ∎)
48+
4249
x∣y⇒zx∣zy : {x y} z x ∣ y z ∙ x ∣ z ∙ y
4350
x∣y⇒zx∣zy {x} {y} z (q , qx≈y) = q , (begin
4451
q ∙ (z ∙ x) ≈⟨ x∙yz≈y∙xz q z x ⟩

src/Algebra/Properties/Magma/Divisibility.agda

+69-21
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,49 @@ open import Algebra.Definitions.RawMagma rawMagma public
2424
using (_∣_; _∤_; _∥_; _∦_; _∣ˡ_; _∤ˡ_; _∣ʳ_; _∤ʳ_; _,_)
2525

2626
------------------------------------------------------------------------
27-
-- Properties of divisibility
27+
-- Properties of right divisibility
2828

29-
∣-respʳ-≈ : _∣_ Respectsʳ _≈_
30-
∣-respʳ-≈ y≈z (q , qx≈y) = q , trans qx≈y y≈z
29+
ʳ-respʳ-≈ : _∣ʳ_ Respectsʳ _≈_
30+
ʳ-respʳ-≈ y≈z (q , qx≈y) = q , trans qx≈y y≈z
3131

32-
∣-respˡ-≈ : _∣_ Respectsˡ _≈_
33-
∣-respˡ-≈ x≈z (q , qx≈y) = q , trans (∙-congˡ (sym x≈z)) qx≈y
32+
ʳ-respˡ-≈ : _∣ʳ_ Respectsˡ _≈_
33+
ʳ-respˡ-≈ x≈z (q , qx≈y) = q , trans (∙-congˡ (sym x≈z)) qx≈y
3434

35-
∣-resp-≈ : _∣_ Respects₂ _≈_
36-
∣-resp-≈ = ∣-respʳ-≈ , ∣-respˡ-≈
35+
ʳ-resp-≈ : _∣ʳ_ Respects₂ _≈_
36+
ʳ-resp-≈ =ʳ-respʳ-≈ , ∣ʳ-respˡ-≈
3737

38-
x∣yx : x y x ∣ y ∙ x
39-
x∣yx x y = y , refl
38+
x∣ʳyx : x y x ∣ʳ y ∙ x
39+
x∣ʳyx x y = y , refl
4040

41-
xy≈z⇒y∣z : x y {z} x ∙ y ≈ z y ∣ z
42-
xy≈z⇒y∣z x y xy≈z = x , xy≈z
41+
xy≈z⇒y∣ʳz : x y {z} x ∙ y ≈ z y ∣ʳ z
42+
xy≈z⇒y∣ʳz x y xy≈z = x , xy≈z
43+
44+
------------------------------------------------------------------------
45+
-- Properties of left divisibility
46+
47+
∣ˡ-respʳ-≈ : _∣ˡ_ Respectsʳ _≈_
48+
∣ˡ-respʳ-≈ y≈z (q , xq≈y) = q , trans xq≈y y≈z
49+
50+
∣ˡ-respˡ-≈ : _∣ˡ_ Respectsˡ _≈_
51+
∣ˡ-respˡ-≈ x≈z (q , xq≈y) = q , trans (∙-congʳ (sym x≈z)) xq≈y
52+
53+
∣ˡ-resp-≈ : _∣ˡ_ Respects₂ _≈_
54+
∣ˡ-resp-≈ = ∣ˡ-respʳ-≈ , ∣ˡ-respˡ-≈
55+
56+
x∣ˡxy : x y x ∣ˡ x ∙ y
57+
x∣ˡxy x y = y , refl
58+
59+
xy≈z⇒x∣ˡz : x y {z} x ∙ y ≈ z x ∣ˡ z
60+
xy≈z⇒x∣ˡz x y xy≈z = y , xy≈z
4361

4462
------------------------------------------------------------------------
4563
-- Properties of non-divisibility
4664

4765
∤-respˡ-≈ : _∤_ Respectsˡ _≈_
48-
∤-respˡ-≈ x≈y x∤z y∣z = contradiction (∣-respˡ-≈ (sym x≈y) y∣z) x∤z
66+
∤-respˡ-≈ x≈y x∤z y∣ʳz = contradiction (∣ʳ-respˡ-≈ (sym x≈y) y∣ʳz) x∤z
4967

5068
∤-respʳ-≈ : _∤_ Respectsʳ _≈_
51-
∤-respʳ-≈ x≈y z∤x z∣y = contradiction (∣-respʳ-≈ (sym x≈y) z∣y) z∤x
69+
∤-respʳ-≈ x≈y z∤x z∣ʳy = contradiction (∣ʳ-respʳ-≈ (sym x≈y) z∣ʳy) z∤x
5270

5371
∤-resp-≈ : _∤_ Respects₂ _≈_
5472
∤-resp-≈ = ∤-respʳ-≈ , ∤-respˡ-≈
@@ -60,10 +78,10 @@ xy≈z⇒y∣z x y xy≈z = x , xy≈z
6078
∥-sym = swap
6179

6280
∥-respˡ-≈ : _∥_ Respectsˡ _≈_
63-
∥-respˡ-≈ x≈z (x∣y , y∣x) = ∣-respˡ-≈ x≈z x∣y , ∣-respʳ-≈ x≈z y∣x
81+
∥-respˡ-≈ x≈z (x∣ʳy , y∣ʳx) =ʳ-respˡ-≈ x≈z x∣ʳy , ∣ʳ-respʳ-≈ x≈z y∣ʳx
6482

6583
∥-respʳ-≈ : _∥_ Respectsʳ _≈_
66-
∥-respʳ-≈ y≈z (x∣y , y∣x) = ∣-respʳ-≈ y≈z x∣y , ∣-respˡ-≈ y≈z y∣x
84+
∥-respʳ-≈ y≈z (x∣ʳy , y∣ʳx) =ʳ-respʳ-≈ y≈z x∣ʳy , ∣ʳ-respˡ-≈ y≈z y∣ʳx
6785

6886
∥-resp-≈ : _∥_ Respects₂ _≈_
6987
∥-resp-≈ = ∥-respʳ-≈ , ∥-respˡ-≈
@@ -92,20 +110,20 @@ xy≈z⇒y∣z x y xy≈z = x , xy≈z
92110

93111
-- Version 2.2
94112

95-
∣-respˡ = ∣-respˡ-≈
113+
∣-respˡ =ʳ-respˡ-≈
96114
{-# WARNING_ON_USAGE ∣-respˡ
97115
"Warning: ∣-respˡ was deprecated in v2.2.
98-
Please use ∣-respˡ-≈ instead. "
116+
Please use ∣ʳ-respˡ-≈ instead. "
99117
#-}
100-
∣-respʳ = ∣-respʳ-≈
118+
∣-respʳ =ʳ-respʳ-≈
101119
{-# WARNING_ON_USAGE ∣-respʳ
102120
"Warning: ∣-respʳ was deprecated in v2.2.
103-
Please use ∣-respʳ-≈ instead. "
121+
Please use ∣ʳ-respʳ-≈ instead. "
104122
#-}
105-
∣-resp = ∣-resp-≈
123+
∣-resp =ʳ-resp-≈
106124
{-# WARNING_ON_USAGE ∣-resp
107125
"Warning: ∣-resp was deprecated in v2.2.
108-
Please use ∣-resp-≈ instead. "
126+
Please use ∣ʳ-resp-≈ instead. "
109127
#-}
110128

111129
-- Version 2.3
@@ -150,3 +168,33 @@ Please use ∦-respʳ-≈ instead. "
150168
"Warning: ∤∤-resp-≈ was deprecated in v2.3.
151169
Please use ∦-resp-≈ instead. "
152170
#-}
171+
172+
∣-respʳ-≈ = ∣ʳ-respʳ-≈
173+
{-# WARNING_ON_USAGE ∣-respʳ-≈
174+
"Warning: ∣-respʳ-≈ was deprecated in v2.3.
175+
Please use ∣ʳ-respʳ-≈ instead. "
176+
#-}
177+
178+
∣-respˡ-≈ = ∣ʳ-respˡ-≈
179+
{-# WARNING_ON_USAGE ∣-respˡ-≈
180+
"Warning: ∣-respˡ-≈ was deprecated in v2.3.
181+
Please use ∣ʳ-respˡ-≈ instead. "
182+
#-}
183+
184+
∣-resp-≈ = ∣ʳ-resp-≈
185+
{-# WARNING_ON_USAGE ∣-resp-≈
186+
"Warning: ∣-resp-≈ was deprecated in v2.3.
187+
Please use ∣ʳ-resp-≈ instead. "
188+
#-}
189+
190+
x∣yx = x∣ʳyx
191+
{-# WARNING_ON_USAGE x∣yx
192+
"Warning: x∣yx was deprecated in v2.3.
193+
Please use x∣ʳyx instead. "
194+
#-}
195+
196+
xy≈z⇒y∣z = xy≈z⇒y∣ʳz
197+
{-# WARNING_ON_USAGE xy≈z⇒y∣z
198+
"Warning: xy≈z⇒y∣z was deprecated in v2.3.
199+
Please use xy≈z⇒y∣ʳz instead. "
200+
#-}

src/Algebra/Properties/Monoid/Divisibility.agda

+74-17
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,65 @@ open Monoid M
2525
open import Algebra.Properties.Semigroup.Divisibility semigroup public
2626

2727
------------------------------------------------------------------------
28-
-- Additional properties
28+
-- Additional properties for right divisibility
2929

30-
infix 4 ε∣_
30+
infix 4 ε∣ʳ_
31+
32+
ε∣ʳ_ : x ε ∣ʳ x
33+
ε∣ʳ x = x , identityʳ x
34+
35+
∣ʳ-refl : Reflexive _∣ʳ_
36+
∣ʳ-refl {x} = ε , identityˡ x
37+
38+
∣ʳ-reflexive : _≈_ ⇒ _∣ʳ_
39+
∣ʳ-reflexive x≈y = ε , trans (identityˡ _) x≈y
40+
41+
∣ʳ-isPreorder : IsPreorder _≈_ _∣ʳ_
42+
∣ʳ-isPreorder = record
43+
{ isEquivalence = isEquivalence
44+
; reflexive = ∣ʳ-reflexive
45+
; trans = ∣ʳ-trans
46+
}
47+
48+
∣ʳ-preorder : Preorder a ℓ _
49+
∣ʳ-preorder = record
50+
{ isPreorder = ∣ʳ-isPreorder
51+
}
52+
53+
------------------------------------------------------------------------
54+
-- Additional properties for left divisibility
55+
56+
infix 4 ε∣ˡ_
3157

32-
ε∣_ : x ε ∣ x
33-
ε∣ x = x , identityʳ x
58+
ε∣ˡ_ : x ε ∣ˡ x
59+
ε∣ˡ x = x , identityˡ x
3460

35-
∣-refl : Reflexive _∣_
36-
∣-refl {x} = ε , identityˡ x
61+
ˡ-refl : Reflexive _∣ˡ_
62+
ˡ-refl {x} = ε , identityʳ x
3763

38-
∣-reflexive : _≈_ ⇒ _∣_
39-
∣-reflexive x≈y = ε , trans (identityˡ _) x≈y
64+
ˡ-reflexive : _≈_ ⇒ _∣ˡ_
65+
ˡ-reflexive x≈y = ε , trans (identityʳ _) x≈y
4066

41-
∣-isPreorder : IsPreorder _≈_ _∣_
42-
∣-isPreorder = record
67+
ˡ-isPreorder : IsPreorder _≈_ _∣ˡ_
68+
ˡ-isPreorder = record
4369
{ isEquivalence = isEquivalence
44-
; reflexive = ∣-reflexive
45-
; trans = ∣-trans
70+
; reflexive =ˡ-reflexive
71+
; trans =ˡ-trans
4672
}
4773

48-
∣-preorder : Preorder a ℓ _
49-
∣-preorder = record
50-
{ isPreorder = ∣-isPreorder
74+
ˡ-preorder : Preorder a ℓ _
75+
ˡ-preorder = record
76+
{ isPreorder =ˡ-isPreorder
5177
}
5278

5379
------------------------------------------------------------------------
5480
-- Properties of mutual divisibiity
5581

5682
∥-refl : Reflexive _∥_
57-
∥-refl = ∣-refl , ∣-refl
83+
∥-refl =ʳ-refl , ∣ʳ-refl
5884

5985
∥-reflexive : _≈_ ⇒ _∥_
60-
∥-reflexive x≈y = ∣-reflexive x≈y , ∣-reflexive (sym x≈y)
86+
∥-reflexive x≈y =ʳ-reflexive x≈y , ∣ʳ-reflexive (sym x≈y)
6187

6288
∥-isEquivalence : IsEquivalence _∥_
6389
∥-isEquivalence = record
@@ -92,3 +118,34 @@ Please use ∥-reflexive instead. "
92118
"Warning: ∣∣-isEquivalence was deprecated in v2.3.
93119
Please use ∥-isEquivalence instead. "
94120
#-}
121+
122+
infix 4 ε∣_
123+
ε∣_ = ε∣ʳ_
124+
{-# WARNING_ON_USAGE ε∣_
125+
"Warning: ε∣_ was deprecated in v2.3.
126+
Please use ε∣ʳ_ instead. "
127+
#-}
128+
129+
∣-refl = ∣ʳ-refl
130+
{-# WARNING_ON_USAGE ∣-refl
131+
"Warning: ∣-refl was deprecated in v2.3.
132+
Please use ∣ʳ-refl instead. "
133+
#-}
134+
135+
∣-reflexive = ∣ʳ-reflexive
136+
{-# WARNING_ON_USAGE ∣-reflexive
137+
"Warning: ∣-reflexive was deprecated in v2.3.
138+
Please use ∣ʳ-reflexive instead. "
139+
#-}
140+
141+
∣-isPreorder = ∣ʳ-isPreorder
142+
{-# WARNING_ON_USAGE ∣ʳ-isPreorder
143+
"Warning: ∣-isPreorder was deprecated in v2.3.
144+
Please use ∣ʳ-isPreorder instead. "
145+
#-}
146+
147+
∣-preorder = ∣ʳ-preorder
148+
{-# WARNING_ON_USAGE ∣-preorder
149+
"Warning: ∣-preorder was deprecated in v2.3.
150+
Please use ∣ʳ-preorder instead. "
151+
#-}

src/Algebra/Properties/Semigroup/Divisibility.agda

+29-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,36 @@ open Semigroup S
2222
open import Algebra.Properties.Magma.Divisibility magma public
2323

2424
------------------------------------------------------------------------
25-
-- Properties of _∣_
25+
-- Properties of _∣ʳ_
2626

27-
∣-trans : Transitive _∣_
28-
∣-trans (p , px≈y) (q , qy≈z) =
27+
x∣ʳy⇒x∣ʳzy : {x y} z x ∣ʳ y x ∣ʳ z ∙ y
28+
x∣ʳy⇒x∣ʳzy z (p , px≈y) = z ∙ p , trans (assoc z p _) (∙-congˡ px≈y)
29+
30+
x∣ʳy⇒xz∣ʳyz : {x y} z x ∣ʳ y x ∙ z ∣ʳ y ∙ z
31+
x∣ʳy⇒xz∣ʳyz z (p , px≈y) = p , trans (sym (assoc p _ z)) (∙-congʳ px≈y)
32+
33+
∣ʳ-trans : Transitive _∣ʳ_
34+
∣ʳ-trans (p , px≈y) (q , qy≈z) =
2935
q ∙ p , trans (assoc q p _) (trans (∙-congˡ px≈y) qy≈z)
3036

37+
------------------------------------------------------------------------
38+
-- Properties of _∣ˡ__
39+
40+
x∣ˡy⇒x∣ˡyz : {x y} z x ∣ˡ y x ∣ˡ y ∙ z
41+
x∣ˡy⇒x∣ˡyz z (p , xp≈y) = p ∙ z , trans (sym (assoc _ p z)) (∙-congʳ xp≈y)
42+
43+
x∣ˡy⇒zx∣ˡzy : {x y} z x ∣ˡ y z ∙ x ∣ˡ z ∙ y
44+
x∣ˡy⇒zx∣ˡzy z (p , xp≈y) = p , trans (assoc z _ p) (∙-congˡ xp≈y)
45+
46+
∣ˡ-trans : Transitive _∣ˡ_
47+
∣ˡ-trans (p , xp≈y) (q , yq≈z) =
48+
p ∙ q , trans (sym (assoc _ p q)) (trans (∙-congʳ xp≈y) yq≈z)
49+
3150
------------------------------------------------------------------------
3251
-- Properties of _∥_
3352

3453
∥-trans : Transitive _∥_
35-
∥-trans (x∣y , y∣x) (y∣z , z∣y) = ∣-trans x∣y y∣z , ∣-trans z∣y y∣x
54+
∥-trans (x∣y , y∣x) (y∣z , z∣y) =ʳ-trans x∣y y∣z , ∣ʳ-trans z∣y y∣x
3655

3756

3857
------------------------------------------------------------------------
@@ -48,3 +67,9 @@ open import Algebra.Properties.Magma.Divisibility magma public
4867
"Warning: ∣∣-trans was deprecated in v2.3.
4968
Please use ∥-trans instead. "
5069
#-}
70+
71+
∣-trans = ∣ʳ-trans
72+
{-# WARNING_ON_USAGE ∣-trans
73+
"Warning: ∣-trans was deprecated in v2.3.
74+
Please use ∣ʳ-trans instead. "
75+
#-}

src/Data/List/Relation/Binary/Prefix/Homogeneous/Properties.agda

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ open import Data.List.Relation.Binary.Pointwise as Pointwise using (Pointwise)
1818
open import Data.List.Relation.Binary.Prefix.Heterogeneous
1919
open import Data.List.Relation.Binary.Prefix.Heterogeneous.Properties
2020

21+
2122
private
2223
variable
2324
a b r s : Level
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Properties of the propositional prefix relation
5+
------------------------------------------------------------------------
6+
7+
{-# OPTIONS --cubical-compatible --safe #-}
8+
9+
module Data.List.Relation.Binary.Prefix.Propositional.Properties {a} {A : Set a} where
10+
11+
open import Data.List.Base using (List; []; _∷_)
12+
open import Data.List.Properties using (++-monoid)
13+
14+
open import Data.List.Relation.Binary.Prefix.Heterogeneous
15+
using (Prefix; []; _∷_; fromView; _++_)
16+
open import Data.List.Relation.Binary.Prefix.Homogeneous.Properties
17+
import Data.List.Relation.Binary.Pointwise as Pointwise
18+
19+
open import Algebra.Properties.Monoid.Divisibility (++-monoid A)
20+
21+
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
22+
open import Relation.Binary using (_⇒_)
23+
24+
------------------------------------------------------------------------
25+
-- The inductive definition of the propositional Prefix relation is
26+
-- equivalent to the notion of left divisibility induced by the
27+
-- (List A, _++_, []) monoid
28+
29+
Prefix-as-∣ˡ : Prefix _≡_ ⇒ _∣ˡ_
30+
Prefix-as-∣ˡ [] = ε∣ˡ _
31+
Prefix-as-∣ˡ (refl ∷ tl) = x∣ˡy⇒zx∣ˡzy (_ ∷ []) (Prefix-as-∣ˡ tl)
32+
33+
∣ˡ-as-Prefix : _∣ˡ_ ⇒ Prefix _≡_
34+
∣ˡ-as-Prefix (rest , refl) = fromView (Pointwise.refl refl ++ rest)

0 commit comments

Comments
 (0)