-
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
Draft
jamesmckinna
wants to merge
12
commits into
agda:master
Choose a base branch
from
jamesmckinna:subsetoid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f787fec
[ add ] `Setoid` from `PartialSetoid`
jamesmckinna 51c0b54
fix: `CHANGELOG`
jamesmckinna a6144ca
restore: `Properties`
jamesmckinna bbdbe2b
restore: `Properties`
jamesmckinna 324c197
fix: `CHANGELOG`
jamesmckinna 3f73a0b
add: `Construct` module
jamesmckinna 84a43af
refactor: use `proj₁` and `proj₂`
jamesmckinna 80b3a4b
refactor: removed `refl` and inlined its definition
jamesmckinna cda4a4f
refactor: use `record` type
jamesmckinna fb73572
add: `Defined`
jamesmckinna 97d6137
use: `Defined`
jamesmckinna f38d5b5
refactor: via `Kernel` pairs
jamesmckinna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/Relation/Binary/Construct/SetoidFromPartialSetoid.agda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Structures | ||
using (IsEquivalence) | ||
open import Relation.Binary.Morphism.Structures | ||
using (IsRelHomomorphism; IsRelMonomorphism) | ||
|
||
private | ||
module S = PartialSetoid S | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Definitions | ||
|
||
record Carrier : Set (a ⊔ ℓ) where | ||
|
||
field | ||
ι : S.Carrier | ||
refl : ι 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 } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 must say that I expected the carrier to be called
Carrier
(and notι
) with the record called something like 'Reflective' or some such.Thinking some more, I think having a definition for
Defined x
(expanding tox S.≈ x
) might make the overall definition more perspicuous.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.
So...
Carrier
(capitalised) is the carrier type; did you envisagecarrier
(lower-case) for the name of its inhabitant?I was motivated by my proposal under Substructures and quotients in the
Algebra.*
hierarchy #1899 to have a standardised name which then becomes the underlying function of the homo-/mono-morphism injectingCarrier
intoS.Carrier
... but part of my thinking was also that the record itself doesn't merit an 'interesting' name... because it should only be exposed through itsSetoid
API, when it would moreover, again receive the nameCarrier
... (and be renamed, presumably, at any client use-site, if needed)Defined
sounds a good suggestion forRelation.Binary.Definitions
... DRY says we should then redefineReflexive
in terms of it?On naming, I think I was struck looking back over #2071 that the carrier type of the symmetric interior is given an 'interesting'/'informative' name, when in fact that's another case (I now think), where therecord
type is a concrete implementation detail which should only really be accessed/accessible via the API for theConstruct
being defined... esp. given that the module import path already cues the construction as that of the symmetric interior...UPDATED: I've gone back over that last paragraph, and it doesn't any longer make sense!? Sorry for the noise!
Let me retry :
#2071 defines a construction on binary relations, not on types, whereas
Carrier
constructs a type towards building aSetoid
, so it's not obvious that it belongs underConstruct
?The operating construct on binary relations involved here is simply
_on_
, but I'd hesitate before putting the derived constructions asProperties
ofRelation.Binary.Construct.On
...?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.
D'oh!?
I've ended up defining
subset
=equaliser of kernel pair
for a/the special case of the 'inclusion'...
So it is probably better to refactor this as
kernel pair of arbitrary function
(Fam
again!?), and then specialise that atid
?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 comment
The 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.