Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d171042
refactor: fix #2587
jamesmckinna Feb 18, 2025
d07718c
refactor: properties of `HeytingField`, not `HeytingCommutativeRing`
jamesmckinna Feb 18, 2025
7f2f4af
refactor: give `DecSetoid`s the structure of `(Is)TightApartnessRelat…
jamesmckinna Feb 18, 2025
408433d
fix: unsaved commits
jamesmckinna Feb 18, 2025
92f8248
refactor: move property `x-0≈x` to `Algebra.Properties.AbelianGroup`,…
jamesmckinna Feb 19, 2025
55a7384
refactor: deprecate and tighten `import`s
jamesmckinna Feb 19, 2025
3786f55
fix: `CHANGELOG` plus tidying up
jamesmckinna Feb 19, 2025
5da81d0
Merge branch 'master' into refactor-heyting
jamesmckinna Feb 19, 2025
31b51a6
refactor: resolve merge of #2576
jamesmckinna Feb 19, 2025
f891093
refactor: another attempt to resolve merge of #2576
jamesmckinna Feb 19, 2025
a8d6284
refactor: re-export from `Relation.Binary.Properties.(Dec)Setoid`
jamesmckinna Feb 19, 2025
1f9a4c1
refactor: tighten re-export from `Relation.Binary.Properties.DecSetoid`
jamesmckinna Feb 19, 2025
48bef4a
refactor: re-export from `apartnessRelation` from `HeytingCommutative…
jamesmckinna Feb 19, 2025
cdc57d2
fix: better `CHANGELOG`?
jamesmckinna Feb 19, 2025
fb2da3e
fix: one last re-export?
jamesmckinna Feb 19, 2025
8dcb5b6
Merge branch 'agda:master' into refactor-heyting
jamesmckinna Feb 21, 2025
adebb3c
Merge branch 'master' into refactor-heyting
jamesmckinna Jun 11, 2026
df7e404
fix: symbol
jamesmckinna Jun 11, 2026
f0f84ef
Merge branch 'master' into refactor-heyting
jamesmckinna Jun 12, 2026
5634375
Merge branch 'master' into refactor-heyting
jamesmckinna Jun 15, 2026
14e7a06
Merge branch 'master' into refactor-heyting
jamesmckinna Jun 16, 2026
24a1d62
Merge branch 'master' into refactor-heyting
jamesmckinna Jun 22, 2026
23125e0
fix: `without-K`
jamesmckinna Jun 22, 2026
edef67f
Merge branch 'master' into refactor-heyting
jamesmckinna Jul 1, 2026
3509b3d
add: strong extensionality for `_+_` and `_*_`
jamesmckinna Jul 3, 2026
bad5cbb
fix: axiomatisation, but TODO still need to implement for `Data.Ratio…
jamesmckinna Jul 3, 2026
a6a4e78
Merge branch 'master' into refactor-heyting
jamesmckinna Jul 16, 2026
0450028
add: `Definitions` and `Consequences` for apartness relations
jamesmckinna Jul 15, 2026
547a9f7
refactor: reflect new module structure
jamesmckinna Jul 16, 2026
e790454
refactor: complete `IsHeytingCommutativeRing` axiomatisation
jamesmckinna Jul 16, 2026
92162b9
refactor: complete `IsHeytingCommutativeRing` axiomatisation; tidy up
jamesmckinna Jul 16, 2026
343806e
fix: `whitespace`
jamesmckinna Jul 16, 2026
1616502
fix: unsolved goal
jamesmckinna Jul 16, 2026
4774a2b
Apply suggestion from @jamesmckinna
jamesmckinna Jul 16, 2026
257d8ce
Update version number for deprecations
jamesmckinna Jul 16, 2026
3aa3c80
tweak
jamesmckinna Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 96 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ Highlights
Bug-fixes
---------

* In `Algebra.Apartness.Structures`, renamed `sym` from `IsApartnessRelation`
to `#-sym` in order to avoid overloaded projection. The field names
`irrefl` and `cotrans` are similarly renamed for the sake of consistency.

* Removed unnecessary parameter `zero : Zero 0# *` from
`Algebra.Structures.IsNonAssociativeRing`.

Expand All @@ -72,6 +76,21 @@ Bug-fixes
Non-backwards compatible changes
--------------------------------

* The definitions of `Algebra.Structures.IsHeyting*` and

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a draft, but in the final version it would be good to explain broadly what the refactorings actually are here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See latest commits, hopefully enough, but not too much, detail now!

`Algebra.Bundles.Heyting*` have been refactored, together
with that of `Relation.Binary.Definitions.Tight` on which they depend.
Specifically:
- `Tight _≈_ _#_` has been redefined as `∀ x y → ¬ x # y → x ≈ y`,
dropping the redundant second conjunct, because it is equivalent to
`Irreflexive _≈_ _#_`.
- new definitions: `(Is)TightApartnessRelation` structure/bundle, exploiting
the above redefinition.
- the definition of `HeytingCommutativeRing` now drops the properties of
invertibility, in favour of moving them to `HeytingField`.
- both `Heyting*` algebraic structure/bundles have been redefined to base
off an underlying `TightApartnessRelation`.
- both also further require `_+_`/`_*_` to be `StronglyExtensional` wrt `_#_`.

* A major overhaul of the `Function` hierarchy sees the systematic development
and use of the theory of the left inverse `from` to a given `Surjective` function
`to`, as a consequence of which we can achieve full symmetry of `Bijection`, in
Expand Down Expand Up @@ -177,6 +196,12 @@ Deprecated modules
Deprecated names
----------------

* In `Algebra.Apartness.Properties.HeytingCommutativeRing`:
```agda
x-0≈x ↦ Algebra.Properties.Ring.x-0#≈x
#-sym ↦ Algebra.Apartness.Structures.IsHeytingCommutativeRing.#-sym
```

* In `Algebra.Definitions`:
```agda
StarLeftExpansive ↦ Relation.Binary.Definitions.KleeneAlgebra.StarLeftExpansive
Expand Down Expand Up @@ -277,6 +302,15 @@ Deprecated names
New modules
-----------

* `Algebra.Apartness.Consequences`, relationships between definitions, given
properties of a given apartness relation, notably `Cotransitive _#_`.

* `Algebra.Apartness.Definitions`, properties of algebraic operations wrt
a given apartness relation `_#_`.

* `Algebra.Apartness.Properties.HeytingField`, refactoring the existing
`Algebra.Apartness.Properties.HeytingCommutativeRing`.

* `Algebra.Properties.KleeneAlgebra` has been completely rewritten.

* `Codata.Guarded.Stream.Relation.Unary.Linked` for a proof that each pair
Expand Down Expand Up @@ -317,6 +351,18 @@ New modules
Additions to existing modules
-----------------------------

* In `Algebra.Apartness.Bundles.HeytingCommutativeRing`:
```agda
TightApartnessRelation c ℓ₁ ℓ₂ : Set _
```

* In `Algebra.Apartness.Structures.IsHeytingCommutativeRing`:
```agda
IsTightApartnessRelation _≈_ _#_ : Set _
+-stronglyExtensional : StronglyExtensional _#_ _+_
*-stronglyExtensional : StronglyExtensional _#_ _*_
```

* In `Algebra.Consequences.Base`:
```agda
almost⇒exceptˡ : _AlmostLeftCancellative′_ _≈_ P _•_ →
Expand Down Expand Up @@ -347,6 +393,21 @@ Additions to existing modules
Except_RightCancellative_ : (P : Pred A p) → Op₂ A → Set _
```

* In `Algebra.Properties.AbelianGroup`:
```agda
x-ε≈x : RightIdentity ε _-_
```

* In `Algebra.Properties.RingWithoutOne`:
```agda
x-0#≈x : RightIdentity 0# _-_
```

* In `Algebra.Structures.IsKleeneAlgebra`:
```agda
_≤_ : Rel A _
```

* In `Algebra.Properties.KleeneAlgebra`:
```agda
≤-reflexive : _≈_ ⇒ _≤_
Expand All @@ -359,11 +420,6 @@ Additions to existing modules
poset : Poset _ _
```

* In `Algebra.Structures.IsKleeneAlgebra`:
```agda
_≤_ : Rel A _
```

* In `Data.Bool.Properties`:
```agda
∨-monoid : Monoid 0ℓ 0ℓ
Expand Down Expand Up @@ -478,6 +534,29 @@ Additions to existing modules
(q ℤ.* + p) / (r ℕ.* p) ≡ q / r
i/n+j/n≡[i+j]/n : ∀ (i j : ℤ) (n : ℕ) .{{_ : ℕ.NonZero n }} →
i / n + j / n ≡ (i ℤ.+ j) / n
+-stronglyCongruentˡ : ∀ p → StronglyCongruent₁ _≢_ (p +_)
+-stronglyCongruentʳ : ∀ r → StronglyCongruent₁ _≢_ (_+ r)
+-stronglyCongruent : StronglyCongruent₂ _≢_ _+_
+-stronglyExtensional : StronglyExtensional _≢_ _+_
*-stronglyCongruentˡ : ∀ p → StronglyCongruent₁ _≢_ (p *_)
*-stronglyCongruentʳ : ∀ r → StronglyCongruent₁ _≢_ (_* r)
*-stronglyCongruent : StronglyCongruent₂ _≢_ _*_
*-stronglyExtensional : StronglyExtensional _≢_ _*_
```

* In `Data.Rational.Unnormalised.Properties`:
```agda
≄-apartnessRelation : ApartnessRelation _ _ _
≄-isTightApartnessRelation : IsTightApartnessRelation _≃_ _≄_
≄-tightApartnessRelation : TightApartnessRelation _ _ _
+-stronglyCongruentˡ : ∀ p → StronglyCongruent₁ _≄_ (p +_)
+-stronglyCongruentʳ : ∀ r → StronglyCongruent₁ _≄_ (_+ r)
+-stronglyCongruent : StronglyCongruent₂ _≄_ _+_
+-stronglyExtensional : StronglyExtensional _≄_ _+_
*-stronglyCongruentˡ : ∀ p → StronglyCongruent₁ _≄_ (p *_)
*-stronglyCongruentʳ : ∀ r → StronglyCongruent₁ _≄_ (_* r)
*-stronglyCongruent : StronglyCongruent₂ _≄_ _*_
*-stronglyExtensional : StronglyExtensional _≄_ _*_
```

* In `Data.Vec.Properties`:
Expand Down Expand Up @@ -596,6 +675,7 @@ Additions to existing modules

HalfRightAdjoint : Rel A ℓ₁ → Rel B ℓ₂ → (A → B) → (B → A) → Set _
HalfRightAdjoint _≤_ _⊑_ f g = ∀ {x y} → (f x ⊑ y → x ≤ g y)

module KleeneAlgebra (_≤_ : Rel A ℓ₁) where
StarLeftExpansive : ∀ (e : A) (_+_ _*_ : Fun₂ A) (_⋆ : Fun₁ A) → Set _
StarRightExpansive : ∀ (e : A) (_+_ _*_ : Fun₂ A) (_⋆ : Fun₁ A) → Set _
Expand All @@ -605,6 +685,17 @@ Additions to existing modules
StarDestructive : ∀ (_+_ _*_ : Fun₂ A) (_⋆ : Fun₁ A) → Set _
```

* In `Relation.Binary.Properties.DecSetoid`:
```agda
≉-isTightApartnessRelation : IsTightApartnessRelation _≈_ _#_
≉-tightApartnessRelation : TightApartnessRelation _ _ _
```
Additionally,
```agda
≉-tight : Tight _≈_ _≉_
```
has been redefined to reflect the change in the definition of `Tight`.

* In `Relation.Unary`:
```agda
Unique : Rel A ℓ₁ → Pred A ℓ₂ → Pred A _
Expand Down
13 changes: 8 additions & 5 deletions src/Algebra/Apartness/Bundles.agda
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Algebra.Apartness.Bundles where

open import Level using (_⊔_; suc)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.Bundles using (ApartnessRelation)
open import Relation.Binary.Bundles using (TightApartnessRelation)
open import Algebra.Core using (Op₁; Op₂)
open import Algebra.Bundles using (CommutativeRing)
open import Algebra.Apartness.Structures using (IsHeytingCommutativeRing; IsHeytingField)
Expand All @@ -36,8 +36,11 @@ record HeytingCommutativeRing c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ
commutativeRing : CommutativeRing c ℓ₁
commutativeRing = record { isCommutativeRing = isCommutativeRing }

apartnessRelation : ApartnessRelation c ℓ₁ ℓ₂
apartnessRelation = record { isApartnessRelation = isApartnessRelation }
Comment thread
JacquesCarette marked this conversation as resolved.
tightApartnessRelation : TightApartnessRelation c ℓ₁ ℓ₂
tightApartnessRelation = record { isTightApartnessRelation = isTightApartnessRelation }

open TightApartnessRelation tightApartnessRelation public
using (apartnessRelation)


record HeytingField c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
Expand All @@ -61,5 +64,5 @@ record HeytingField c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
heytingCommutativeRing : HeytingCommutativeRing c ℓ₁ ℓ₂
heytingCommutativeRing = record { isHeytingCommutativeRing = isHeytingCommutativeRing }

apartnessRelation : ApartnessRelation c ℓ₁ ℓ₂
apartnessRelation = record { isApartnessRelation = isApartnessRelation }
open HeytingCommutativeRing heytingCommutativeRing public
using (commutativeRing; tightApartnessRelation; apartnessRelation)
36 changes: 36 additions & 0 deletions src/Algebra/Apartness/Consequences.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lemmas relating algebraic definitions wrt an apartness.
------------------------------------------------------------------------

{-# OPTIONS --without-K --safe #-}

open import Relation.Binary.Core using (Rel)

module Algebra.Apartness.Consequences
{a ℓ} {A : Set a} (_#_ : Rel A ℓ) where

open import Algebra.Core using (Op₁; Op₂)
open import Algebra.Apartness.Definitions _#_
open import Data.Product.Base using (_,_)
import Data.Sum.Base as Sum
open import Level using (Level)
open import Relation.Binary.Definitions
using (Cotransitive)

private
variable
r : Level
f : Op₁ A
_∙_ : Op₂ A


------------------------------------------------------------------------
-- Cotransitive plus StronglyCongruent₂ implies StronglyExtensional

cotransitive∧congruent⇒extensional : Cotransitive _#_ →
StronglyCongruent₂ _∙_ → StronglyExtensional _∙_
cotransitive∧congruent⇒extensional
{_∙_ = _∙_} cotrans cong@(congˡ , congʳ) {y = y} {w = w} xy#wz
= Sum.map (congʳ y) (congˡ w) (cotrans xy#wz (w ∙ y))
38 changes: 38 additions & 0 deletions src/Algebra/Apartness/Definitions.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of operations, relative to an apartness relation
------------------------------------------------------------------------

{-# OPTIONS --without-K --safe #-}

open import Relation.Binary.Core using (Rel; _⇒_)

module Algebra.Apartness.Definitions
{a ℓ} {A : Set a} -- The underlying set
(_#_ : Rel A ℓ) -- The underlying apartness
where

open import Algebra.Core using (Op₁; Op₂)
open import Data.Product.Base using (_×_)
open import Data.Sum.Base using (_⊎_)
open import Function.Base using (_on_)


------------------------------------------------------------------------
-- Properties of operations

module _ (f : Op₁ A) where

StronglyCongruent₁ : Set _
StronglyCongruent₁ = (_#_ on f) ⇒ _#_

module _ (_∙_ : Op₂ A) where

StronglyCongruent₂ : Set _
StronglyCongruent₂ =
(∀ x → StronglyCongruent₁ (x ∙_)) × (∀ z → StronglyCongruent₁ (_∙ z))

StronglyExtensional : Set _
StronglyExtensional = ∀ {x y w z} → (x ∙ y) # (w ∙ z) → x # w ⊎ y # z

93 changes: 24 additions & 69 deletions src/Algebra/Apartness/Properties/HeytingCommutativeRing.agda
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,31 @@
open import Algebra.Apartness.Bundles using (HeytingCommutativeRing)

module Algebra.Apartness.Properties.HeytingCommutativeRing
{c ℓ₁ ℓ₂} (HCR : HeytingCommutativeRing c ℓ₁ ℓ₂) where
{c ℓ₁ ℓ₂} (heytingCommutativeRing : HeytingCommutativeRing c ℓ₁ ℓ₂) where

open import Function.Base using (_∘_)
open import Data.Product.Base using (_,_; proj₁; proj₂)
open import Algebra using (CommutativeRing; RightIdentity; Invertible; LeftInvertible; RightInvertible)
open import Algebra.Bundles using (CommutativeRing)

open HeytingCommutativeRing HCR
open CommutativeRing commutativeRing using (ring; *-commutativeMonoid)
open HeytingCommutativeRing heytingCommutativeRing using (commutativeRing)
open CommutativeRing commutativeRing using (ring)
open import Algebra.Properties.Ring ring using (x-0#≈x)

open import Algebra.Properties.Ring ring
using (-0#≈0#; -‿distribˡ-*; -‿distribʳ-*; -‿anti-homo-+; -‿involutive)
open import Relation.Binary.Definitions using (Symmetric)
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
open import Algebra.Properties.CommutativeMonoid *-commutativeMonoid

private variable
x y z : Carrier

invertibleˡ⇒# : LeftInvertible _≈_ 1# _*_ (x - y) → x # y
invertibleˡ⇒# = invertible⇒# ∘ invertibleˡ⇒invertible

invertibleʳ⇒# : RightInvertible _≈_ 1# _*_ (x - y) → x # y
invertibleʳ⇒# = invertible⇒# ∘ invertibleʳ⇒invertible

x-0≈x : RightIdentity _≈_ 0# _-_
x-0≈x x = trans (+-congˡ -0#≈0#) (+-identityʳ x)

1#0 : 1# # 0#
1#0 = invertibleˡ⇒# (1# , 1*[x-0]≈x)
where
1*[x-0]≈x : 1# * (x - 0#) ≈ x
1*[x-0]≈x {x} = trans (*-identityˡ (x - 0#)) (x-0≈x x)

x#0y#0→xy#0 : x # 0# → y # 0# → x * y # 0#
x#0y#0→xy#0 {x} {y} x#0 y#0 = helper (#⇒invertible x#0) (#⇒invertible y#0)
where

helper : Invertible _≈_ 1# _*_ (x - 0#) → Invertible _≈_ 1# _*_ (y - 0#) → x * y # 0#
helper (x⁻¹ , x⁻¹*x≈1 , x*x⁻¹≈1) (y⁻¹ , y⁻¹*y≈1 , y*y⁻¹≈1)
= invertibleˡ⇒# (y⁻¹ * x⁻¹ , y⁻¹*x⁻¹*x*y≈1)
where
open ≈-Reasoning setoid

y⁻¹*x⁻¹*x*y≈1 : y⁻¹ * x⁻¹ * (x * y - 0#) ≈ 1#
y⁻¹*x⁻¹*x*y≈1 = begin
y⁻¹ * x⁻¹ * (x * y - 0#) ≈⟨ *-congˡ (x-0≈x (x * y)) ⟩
y⁻¹ * x⁻¹ * (x * y) ≈⟨ *-assoc y⁻¹ x⁻¹ (x * y) ⟩
y⁻¹ * (x⁻¹ * (x * y)) ≈⟨ *-congˡ (*-assoc x⁻¹ x y) ⟨
y⁻¹ * ((x⁻¹ * x) * y) ≈⟨ *-congˡ (*-congʳ (*-congˡ (x-0≈x x))) ⟨
y⁻¹ * ((x⁻¹ * (x - 0#)) * y) ≈⟨ *-congˡ (*-congʳ x⁻¹*x≈1) ⟩
y⁻¹ * (1# * y) ≈⟨ *-congˡ (*-identityˡ y) ⟩
y⁻¹ * y ≈⟨ *-congˡ (x-0≈x y) ⟨
y⁻¹ * (y - 0#) ≈⟨ y⁻¹*y≈1 ⟩
1# ∎

#-congʳ : x ≈ y → x # z → y # z
#-congʳ {x} {y} {z} x≈y x#z = helper (#⇒invertible x#z)
where

helper : Invertible _≈_ 1# _*_ (x - z) → y # z
helper (x-z⁻¹ , x-z⁻¹*x-z≈1# , x-z*x-z⁻¹≈1#)
= invertibleˡ⇒# (x-z⁻¹ , x-z⁻¹*y-z≈1)
where
open ≈-Reasoning setoid

x-z⁻¹*y-z≈1 : x-z⁻¹ * (y - z) ≈ 1#
x-z⁻¹*y-z≈1 = begin
x-z⁻¹ * (y - z) ≈⟨ *-congˡ (+-congʳ x≈y) ⟨
x-z⁻¹ * (x - z) ≈⟨ x-z⁻¹*x-z≈1# ⟩
1# ∎

#-congˡ : y ≈ z → x # y → x # z
#-congˡ y≈z x#y = #-sym (#-congʳ y≈z (#-sym x#y))
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.

-- Version 3.0

x-0≈x = x-0#≈x
{-# WARNING_ON_USAGE x-0≈x
"Warning: x-0≈x was deprecated in v3.0.
Please use Algebra.Properties.Ring.x-0#≈x instead."
#-}

open HeytingCommutativeRing heytingCommutativeRing public using (#-sym)
{-# WARNING_ON_USAGE #-sym
"Warning: #-sym was deprecated in v3.0.
Please use Algebra.Apartness.Structures.IsHeytingCommutativeRing.#-sym instead."
#-}
Loading
Loading