-
Notifications
You must be signed in to change notification settings - Fork 257
[ add ] Setoid
from PartialSetoid
#2816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f787fec
51c0b54
a6144ca
bbdbe2b
324c197
3f73a0b
84a43af
80b3a4b
cda4a4f
fb73572
97d6137
f38d5b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Equaliser of a kernel pair in Setoid | ||
------------------------------------------------------------------------ | ||
|
||
open import Relation.Binary.Bundles using (PartialSetoid; Setoid) | ||
|
||
module Relation.Binary.Construct.Kernel | ||
{a i ℓ} {I : Set i} | ||
(S : PartialSetoid a ℓ) (let module S = PartialSetoid S) | ||
(f g : I → S.Carrier) | ||
where | ||
|
||
open import Function.Base using (id; _∘_; _on_) | ||
open import Level using (Level; _⊔_) | ||
open import Relation.Binary.Core using (Rel) | ||
open import Relation.Binary.Definitions using (Defined) | ||
open import Relation.Binary.Structures using (IsEquivalence) | ||
open import Relation.Binary.Morphism.Structures | ||
using (IsRelHomomorphism; IsRelMonomorphism) | ||
|
||
import Relation.Binary.Properties.PartialSetoid S as Properties | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Definitions | ||
|
||
record Carrier : Set (a ⊔ i ⊔ ℓ) where | ||
|
||
field | ||
h : I | ||
refl : (f h) S.≈ (g h) | ||
|
||
ι : S.Carrier | ||
ι = f h | ||
|
||
|
||
open Carrier public using (ι) | ||
|
||
_≈_ : Rel Carrier _ | ||
_≈_ = S._≈_ on ι | ||
|
||
-- Structure | ||
|
||
isEquivalence : IsEquivalence _≈_ | ||
isEquivalence = record | ||
{ refl = λ {x = x} → Properties.partial-reflˡ (Carrier.refl x) | ||
; sym = S.sym | ||
; trans = S.trans | ||
} | ||
|
||
-- Bundle | ||
|
||
setoid : Setoid _ _ | ||
setoid = record { isEquivalence = isEquivalence } | ||
|
||
-- Monomorphism | ||
|
||
isRelHomomorphism : IsRelHomomorphism _≈_ S._≈_ ι | ||
isRelHomomorphism = record { cong = id } | ||
|
||
isRelMonomorphism : IsRelMonomorphism _≈_ S._≈_ ι | ||
isRelMonomorphism = record { isHomomorphism = isRelHomomorphism ; injective = id } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Conversion of a PartialSetoid into a Setoid | ||
------------------------------------------------------------------------ | ||
|
||
open import Relation.Binary.Bundles using (PartialSetoid; Setoid) | ||
|
||
module Relation.Binary.Construct.SetoidFromPartialSetoid | ||
{a ℓ} (S : PartialSetoid a ℓ) where | ||
|
||
open import Function.Base using (id; _on_) | ||
open import Level using (_⊔_) | ||
open import Relation.Binary.Core using (Rel) | ||
open import Relation.Binary.Definitions using (Defined) | ||
open import Relation.Binary.Structures using (IsEquivalence) | ||
open import Relation.Binary.Morphism.Structures | ||
using (IsRelHomomorphism; IsRelMonomorphism) | ||
|
||
private | ||
module S = PartialSetoid S | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Definitions | ||
|
||
record Carrier : Set (a ⊔ ℓ) where | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I must say that I expected the carrier to be called Thinking some more, I think having a definition for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So...
UPDATED: I've gone back over that last paragraph, and it doesn't any longer make sense!? Sorry for the noise! Let me retry : The operating construct on binary relations involved here is simply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. D'oh!? I've ended up defining So it is probably better to refactor this as Or: take a breath and sit on my hands for a bit... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good realization - I certainly had not spotted that. Perhaps sitting is indeed wise. |
||
|
||
field | ||
ι : S.Carrier | ||
refl : Defined S._≈_ ι | ||
|
||
open Carrier public using (ι) | ||
|
||
_≈_ : Rel Carrier _ | ||
_≈_ = S._≈_ on ι | ||
|
||
-- Structure | ||
|
||
isEquivalence : IsEquivalence _≈_ | ||
isEquivalence = record | ||
{ refl = λ {x = x} → Carrier.refl x | ||
; sym = S.sym | ||
; trans = S.trans | ||
} | ||
|
||
-- Bundle | ||
|
||
setoid : Setoid _ _ | ||
setoid = record { isEquivalence = isEquivalence } | ||
|
||
-- Monomorphism | ||
|
||
isRelHomomorphism : IsRelHomomorphism _≈_ S._≈_ ι | ||
isRelHomomorphism = record { cong = id } | ||
|
||
isRelMonomorphism : IsRelMonomorphism _≈_ S._≈_ ι | ||
isRelMonomorphism = record { isHomomorphism = isRelHomomorphism ; injective = id } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Conversion of a PartialSetoid into a Setoid | ||
------------------------------------------------------------------------ | ||
|
||
open import Relation.Binary.Bundles using (PartialSetoid) | ||
|
||
module Relation.Binary.Construct.SubSetoid | ||
{a ℓ} (S : PartialSetoid a ℓ) | ||
where | ||
|
||
open import Function.Base using (id) | ||
import Relation.Binary.Construct.Kernel as Kernel | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Definitions | ||
|
||
open module SubSetoid = Kernel S id id public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not happy with this record being called
Carrier
and its 'carrier' field being calledh
. To me,Carrier
will always mean the underlying type of somethingSetoid
-based. So re-using that name confounds expectations.It feels like
Carrier
is instead some kind ofIndex
-type with a distinguished pointh
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JacquesCarette I'm reluctant to antagonise the collective wisdom of McMaster any more than I already seem to be doing over order-theoretic concepts, so I'll try to restate my position FTR, and then happily let others decide what becomes of this:
Carrier
(therecord
type) as theCarrier
(field value) of "somethingSetoid
based", namely the bundle defining the 'subset on whichf
andg
equalise'Setoid
interface (cf. [DRY] what's the best way topublic
ly re-export properties/structure? #2391 ); I guess I could make itprivate
, to improve matters? Alternatively, it could indeed be renamed, but as I say, I regard it as an abstract data type, existing solely to be a choice of domain for theisRelMonomorphism
definition... viz. as a way of speaking about 'the subset on whichf
andg
equalise'f
, andg
defining some diagram (here: a parallel pair with domainI
, as per the 'sub-thing as given by a map on indices' construction, to haveh
, or perhaps better here,k
(forKernel
, except that old-timey category theory books tend to useh
for the universal equalising map, andk
for the corresponding coequalising map in a coequaliser diagram) define the (appropriate) unique mediating morphism (I won't debate uniqueness or otherwise here, given higher-minded, and higher-dimensional, sensitivities about 'uniqueness up to what?'); given the way thatfield
name become projection functions, that, again precisely, establishesh
, or whatever we end up calling it, as a function of typeCarrier → I
, and again, conventionally, in such a way as to fit the diagram of parallel arrowsf
,g
...ι : Carrier → S.Carrier
, as, again precisely, corresponding to 'the injection intoS
of the subset on whichf
andg
equalise', but again, the actual name seems really neither here nor there, but for the fact that, again from thepublic
exports,h
is never again mentioned (so its name is similarly immaterial/abstract)I'd be quite happy to say 'puns considered harmful', and rename everything, but for the fact that these objects/constructions giving rise to the (intended for
public
export) definitions_≈_
isEquivalence
setoid
isRelMonomorphism
do all need to be named. Perhaps it was failure of imagination on my part not to be able to come up with better ones, but in the end, I thought, it turns out mistakenly, that the ones I chose, for the reasons above, made the best 'fit'.
HTH!
See above:
h
defines, as a projection, a function fromCarrier
toI
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making it
private
would go part of the way, for sure. Some puns I like, but somehow not this one.The argument "establishing this as the
Carrier
of ..." doesn't go very far, as it could be extended to so many more things.Have you considered
Equalizer
as the name?EqualAt
, if we want a less fancy name?