Skip to content

Commit d171042

Browse files
committed
refactor: fix agda#2587
1 parent c562cd8 commit d171042

File tree

9 files changed

+57
-30
lines changed

9 files changed

+57
-30
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Non-backwards compatible changes
1717
significantly faster. However, its reduction behaviour on open terms may have
1818
changed.
1919

20+
* The definitions of `Algebra.Structures.IsHeytingCommutativeRing` and
21+
`Algebra.Structures.IsHeytingCommutativeRing` have been refactored, together
22+
with that of `Relation.Binary.Definitions.Tight` on which they depend.
23+
2024
Minor improvements
2125
------------------
2226

src/Algebra/Apartness/Bundles.agda

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Algebra.Apartness.Bundles where
1010

1111
open import Level using (_⊔_; suc)
1212
open import Relation.Binary.Core using (Rel)
13-
open import Relation.Binary.Bundles using (ApartnessRelation)
13+
open import Relation.Binary.Bundles using (TightApartnessRelation)
1414
open import Algebra.Core using (Op₁; Op₂)
1515
open import Algebra.Bundles using (CommutativeRing)
1616
open import Algebra.Apartness.Structures
@@ -36,8 +36,8 @@ record HeytingCommutativeRing c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ
3636
commutativeRing : CommutativeRing c ℓ₁
3737
commutativeRing = record { isCommutativeRing = isCommutativeRing }
3838

39-
apartnessRelation : ApartnessRelation c ℓ₁ ℓ₂
40-
apartnessRelation = record { isApartnessRelation = isApartnessRelation }
39+
tightApartnessRelation : TightApartnessRelation c ℓ₁ ℓ₂
40+
tightApartnessRelation = record { isTightApartnessRelation = isTightApartnessRelation }
4141

4242

4343
record HeytingField c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
@@ -61,5 +61,5 @@ record HeytingField c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
6161
heytingCommutativeRing : HeytingCommutativeRing c ℓ₁ ℓ₂
6262
heytingCommutativeRing = record { isHeytingCommutativeRing = isHeytingCommutativeRing }
6363

64-
apartnessRelation : ApartnessRelation c ℓ₁ ℓ₂
65-
apartnessRelation = record { isApartnessRelation = isApartnessRelation }
64+
open HeytingCommutativeRing heytingCommutativeRing public
65+
using (commutativeRing; tightApartnessRelation)

src/Algebra/Apartness/Structures.agda

+10-12
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,21 @@ module Algebra.Apartness.Structures
1717
where
1818

1919
open import Level using (_⊔_; suc)
20-
open import Data.Product.Base using (∃-syntax; _×_; _,_; proj₂)
2120
open import Algebra.Definitions _≈_ using (Invertible)
2221
open import Algebra.Structures _≈_ using (IsCommutativeRing)
23-
open import Relation.Binary.Structures using (IsEquivalence; IsApartnessRelation)
24-
open import Relation.Binary.Definitions using (Tight)
25-
open import Relation.Nullary.Negation using (¬_)
22+
open import Relation.Binary.Structures
23+
using (IsEquivalence; IsApartnessRelation; IsTightApartnessRelation)
2624
import Relation.Binary.Properties.ApartnessRelation as AR
2725

2826

2927
record IsHeytingCommutativeRing : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
3028

3129
field
32-
isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#
33-
isApartnessRelation : IsApartnessRelation _≈_ _#_
30+
isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#
31+
isTightApartnessRelation : IsTightApartnessRelation _≈_ _#_
3432

3533
open IsCommutativeRing isCommutativeRing public
36-
open IsApartnessRelation isApartnessRelation public
37-
38-
field
39-
#⇒invertible : {x y} x # y Invertible 1# _*_ (x - y)
40-
invertible⇒# : {x y} Invertible 1# _*_ (x - y) x # y
34+
open IsTightApartnessRelation isTightApartnessRelation public
4135

4236
¬#-isEquivalence : IsEquivalence _¬#_
4337
¬#-isEquivalence = AR.¬#-isEquivalence refl isApartnessRelation
@@ -47,6 +41,10 @@ record IsHeytingField : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
4741

4842
field
4943
isHeytingCommutativeRing : IsHeytingCommutativeRing
50-
tight : Tight _≈_ _#_
5144

5245
open IsHeytingCommutativeRing isHeytingCommutativeRing public
46+
47+
field
48+
#⇒invertible : {x y} x # y Invertible 1# _*_ (x - y)
49+
invertible⇒# : {x y} Invertible 1# _*_ (x - y) x # y
50+

src/Data/Rational/Properties.agda

+3-4
Original file line numberDiff line numberDiff line change
@@ -1299,15 +1299,14 @@ module _ where
12991299
isHeytingCommutativeRing : IsHeytingCommutativeRing _≡_ _≢_ _+_ _*_ -_ 0ℚ 1ℚ
13001300
isHeytingCommutativeRing = record
13011301
{ isCommutativeRing = isCommutativeRing
1302-
; isApartnessRelation = ≉-isApartnessRelation
1303-
; #⇒invertible = #⇒invertible
1304-
; invertible⇒# = invertible⇒#
1302+
; isTightApartnessRelation = ≉-isTightApartnessRelation
13051303
}
13061304

13071305
isHeytingField : IsHeytingField _≡_ _≢_ _+_ _*_ -_ 0ℚ 1ℚ
13081306
isHeytingField = record
13091307
{ isHeytingCommutativeRing = isHeytingCommutativeRing
1310-
; tight = ≉-tight
1308+
; #⇒invertible = #⇒invertible
1309+
; invertible⇒# = invertible⇒#
13111310
}
13121311

13131312
heytingCommutativeRing : HeytingCommutativeRing 0ℓ 0ℓ 0ℓ

src/Data/Rational/Unnormalised/Properties.agda

+11-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ open import Relation.Binary.Core using (_⇒_; _Preserves_⟶_; _Preserves₂_
3535
open import Relation.Binary.Bundles
3636
using (Setoid; DecSetoid; Preorder; TotalPreorder; Poset; TotalOrder; DecTotalOrder; StrictPartialOrder; StrictTotalOrder; DenseLinearOrder)
3737
open import Relation.Binary.Structures
38-
using (IsEquivalence; IsDecEquivalence; IsApartnessRelation; IsTotalPreorder; IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder; IsStrictPartialOrder; IsStrictTotalOrder; IsDenseLinearOrder)
38+
using (IsEquivalence; IsDecEquivalence; IsApartnessRelation; IsTightApartnessRelation; IsTotalPreorder; IsPreorder; IsPartialOrder; IsTotalOrder; IsDecTotalOrder; IsStrictPartialOrder; IsStrictTotalOrder; IsDenseLinearOrder)
3939
open import Relation.Binary.Definitions
4040
using (Reflexive; Symmetric; Transitive; Cotransitive; Tight; Decidable; Antisymmetric; Asymmetric; Dense; Total; Trans; Trichotomous; Irreflexive; Irrelevant; _Respectsˡ_; _Respectsʳ_; _Respects₂_; tri≈; tri<; tri>)
4141
import Relation.Binary.Consequences as BC
@@ -139,8 +139,13 @@ p ≃? q = Dec.map′ *≡* drop-*≡* (↥ p ℤ.* ↧ q ℤ.≟ ↥ q ℤ.*
139139
}
140140

141141
≄-tight : Tight _≃_ _≄_
142-
proj₁ (≄-tight p q) ¬p≄q = Dec.decidable-stable (p ≃? q) ¬p≄q
143-
proj₂ (≄-tight p q) p≃q p≄q = p≄q p≃q
142+
≄-tight p q = Dec.decidable-stable (p ≃? q)
143+
144+
≄-isTightApartnessRelation : IsTightApartnessRelation _≃_ _≄_
145+
≄-isTightApartnessRelation = record
146+
{ isApartnessRelation = ≄-isApartnessRelation
147+
; tight = ≄-tight
148+
}
144149

145150
≃-setoid : Setoid 0ℓ 0ℓ
146151
≃-setoid = record
@@ -1399,15 +1404,14 @@ nonNeg*nonNeg⇒nonNeg p q = nonNegative
13991404
+-*-isHeytingCommutativeRing : IsHeytingCommutativeRing _≃_ _≄_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
14001405
+-*-isHeytingCommutativeRing = record
14011406
{ isCommutativeRing = +-*-isCommutativeRing
1402-
; isApartnessRelation = ≄-isApartnessRelation
1403-
; #⇒invertible = ≄⇒invertible
1404-
; invertible⇒# = invertible⇒≄
1407+
; isTightApartnessRelation = ≄-isTightApartnessRelation
14051408
}
14061409

14071410
+-*-isHeytingField : IsHeytingField _≃_ _≄_ _+_ _*_ -_ 0ℚᵘ 1ℚᵘ
14081411
+-*-isHeytingField = record
14091412
{ isHeytingCommutativeRing = +-*-isHeytingCommutativeRing
1410-
; tight = ≄-tight
1413+
; #⇒invertible = ≄⇒invertible
1414+
; invertible⇒# = invertible⇒≄
14111415
}
14121416

14131417
------------------------------------------------------------------------

src/Relation/Binary/Bundles.agda

+15
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,18 @@ record ApartnessRelation c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) w
424424
renaming (_≁_ to _¬#_; _∼ᵒ_ to _#ᵒ_; _≁ᵒ_ to _¬#ᵒ_)
425425
hiding (Carrier; _≈_ ; _∼_)
426426

427+
record TightApartnessRelation c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
428+
infix 4 _≈_ _#_
429+
field
430+
Carrier : Set c
431+
_≈_ : Rel Carrier ℓ₁
432+
_#_ : Rel Carrier ℓ₂
433+
isTightApartnessRelation : IsTightApartnessRelation _≈_ _#_
434+
435+
open IsTightApartnessRelation isTightApartnessRelation public
436+
using (isApartnessRelation; tight)
437+
438+
apartnessRelation : ApartnessRelation _ _ _
439+
apartnessRelation = record { isApartnessRelation = isApartnessRelation }
440+
441+
open ApartnessRelation apartnessRelation public

src/Relation/Binary/Definitions.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Cotransitive : Rel A ℓ → Set _
147147
Cotransitive _#_ = {x y} x # y z (x # z) ⊎ (z # y)
148148

149149
Tight : Rel A ℓ₁ Rel A ℓ₂ Set _
150-
Tight _≈_ _#_ = x y (¬ x # y x ≈ y) × (x ≈ y ¬ x # y)
150+
Tight _≈_ _#_ = x y ¬ x # y x ≈ y
151151

152152
-- Properties of order morphisms, aka order-preserving maps
153153

src/Relation/Binary/Properties/DecSetoid.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ open SetoidProperties setoid
4040
≉-apartnessRelation = record { isApartnessRelation = ≉-isApartnessRelation }
4141

4242
≉-tight : Tight _≈_ _≉_
43-
≉-tight x y = decidable-stable (x ≟ y) , ≉-irrefl
43+
≉-tight x y = decidable-stable (x ≟ y)

src/Relation/Binary/Structures.agda

+7
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,10 @@ record IsApartnessRelation (_#_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) whe
328328

329329
_¬#_ : A A Set _
330330
x ¬# y = ¬ (x # y)
331+
332+
record IsTightApartnessRelation (_#_ : Rel A ℓ₂) : Set (a ⊔ ℓ ⊔ ℓ₂) where
333+
field
334+
isApartnessRelation : IsApartnessRelation _#_
335+
tight : Tight _≈_ _#_
336+
337+
open IsApartnessRelation isApartnessRelation public

0 commit comments

Comments
 (0)