-
Notifications
You must be signed in to change notification settings - Fork 251
Add biased versions of Function structures #2210
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
Merged
Merged
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
-- The Agda standard library | ||
-- | ||
-- Ways to give instances of certain structures where some fields can | ||
-- be given in terms of others | ||
-- be given in terms of others. Re-exported via `Algebra`. | ||
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. Ditto. In some sense... |
||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
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
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
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
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
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,127 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- Ways to give instances of certain structures where some fields can | ||
-- be given in terms of others. | ||
-- The contents of this file should usually be accessed from `Function`. | ||
------------------------------------------------------------------------ | ||
|
||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
open import Relation.Binary.Core using (Rel) | ||
open import Relation.Binary.Bundles using (Setoid) | ||
open import Relation.Binary.Structures using (IsEquivalence) | ||
|
||
module Function.Structures.Biased {a b ℓ₁ ℓ₂} | ||
{A : Set a} (_≈₁_ : Rel A ℓ₁) -- Equality over the domain | ||
{B : Set b} (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain | ||
where | ||
|
||
open import Data.Product.Base as Product using (∃; _×_; _,_) | ||
open import Function.Base | ||
open import Function.Definitions | ||
open import Function.Structures _≈₁_ _≈₂_ | ||
open import Function.Consequences.Setoid | ||
open import Level using (_⊔_) | ||
|
||
------------------------------------------------------------------------ | ||
-- Surjection | ||
------------------------------------------------------------------------ | ||
|
||
record IsStrictSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
isCongruent : IsCongruent f | ||
strictlySurjective : StrictlySurjective _≈₂_ f | ||
|
||
open IsCongruent isCongruent public | ||
|
||
isSurjection : IsSurjection f | ||
isSurjection = record | ||
{ isCongruent = isCongruent | ||
; surjective = strictlySurjective⇒surjective | ||
Eq₁.setoid Eq₂.setoid cong strictlySurjective | ||
} | ||
|
||
open IsStrictSurjection public | ||
using () renaming (isSurjection to isStrictSurjection) | ||
|
||
------------------------------------------------------------------------ | ||
-- Bijection | ||
------------------------------------------------------------------------ | ||
|
||
record IsStrictBijection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
isInjection : IsInjection f | ||
strictlySurjective : StrictlySurjective _≈₂_ f | ||
|
||
isBijection : IsBijection f | ||
isBijection = record | ||
{ isInjection = isInjection | ||
; surjective = strictlySurjective⇒surjective | ||
Eq₁.setoid Eq₂.setoid cong strictlySurjective | ||
} where open IsInjection isInjection | ||
|
||
open IsStrictBijection public | ||
using () renaming (isBijection to isStrictBijection) | ||
|
||
------------------------------------------------------------------------ | ||
-- Left inverse | ||
------------------------------------------------------------------------ | ||
|
||
record IsStrictLeftInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
isCongruent : IsCongruent to | ||
from-cong : Congruent _≈₂_ _≈₁_ from | ||
strictlyInverseˡ : StrictlyInverseˡ _≈₂_ to from | ||
|
||
isLeftInverse : IsLeftInverse to from | ||
isLeftInverse = record | ||
{ isCongruent = isCongruent | ||
; from-cong = from-cong | ||
; inverseˡ = strictlyInverseˡ⇒inverseˡ | ||
Eq₁.setoid Eq₂.setoid cong strictlyInverseˡ | ||
} where open IsCongruent isCongruent | ||
|
||
open IsStrictLeftInverse public | ||
using () renaming (isLeftInverse to isStrictLeftInverse) | ||
|
||
------------------------------------------------------------------------ | ||
-- Right inverse | ||
------------------------------------------------------------------------ | ||
|
||
record IsStrictRightInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
isCongruent : IsCongruent to | ||
from-cong : Congruent _≈₂_ _≈₁_ from | ||
strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from | ||
|
||
isRightInverse : IsRightInverse to from | ||
isRightInverse = record | ||
{ isCongruent = isCongruent | ||
; from-cong = from-cong | ||
; inverseʳ = strictlyInverseʳ⇒inverseʳ | ||
Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ | ||
} where open IsCongruent isCongruent | ||
|
||
open IsStrictRightInverse public | ||
using () renaming (isRightInverse to isStrictRightInverse) | ||
|
||
------------------------------------------------------------------------ | ||
-- Inverse | ||
------------------------------------------------------------------------ | ||
|
||
record IsStrictInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where | ||
field | ||
isLeftInverse : IsLeftInverse to from | ||
strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from | ||
|
||
isInverse : IsInverse to from | ||
isInverse = record | ||
{ isLeftInverse = isLeftInverse | ||
; inverseʳ = strictlyInverseʳ⇒inverseʳ | ||
Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ | ||
} where open IsLeftInverse isLeftInverse | ||
|
||
open IsStrictInverse public | ||
using () renaming (isInverse to isStrictInverse) |
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 |
---|---|---|
|
@@ -135,4 +135,3 @@ isPropositional = Irrelevant | |
Please use Relation.Nullary.Irrelevant instead. " | ||
#-} | ||
|
||
|
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.
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, it's good to see these things documented in the
CHANGELOG
(which by its very nature, is 'permanent' only to the extent that diligent users/developers can face wading back through the GitHub history; otherwise, we should regard such commentary as 'essentially ephemeral', much like this review comment ;-)), but at some point, we might want such observations/ux hacks to be added to auser-guide
to the library, which we don't really have (yet)?Enough to make me raise issue #2213 ...