Skip to content

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 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,10 @@ Non-backwards compatible changes
- The records in `Function.Structures` and `Function.Bundles` export proofs
of these under the names `strictlySurjective`, `strictlyInverseˡ` and
`strictlyInverseʳ`,
- Conversion functions have been added in both directions to
`Function.Consequences(.Propositional/Setoid)`.
- Conversion functions for the definitions have been added in both directions
to `Function.Consequences(.Propositional/Setoid)`.
- Conversion functions for structures have been added in
`Function.Structures.Biased`.
Comment on lines +756 to +757
Copy link
Contributor

@jamesmckinna jamesmckinna Nov 25, 2023

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 a user-guide to the library, which we don't really have (yet)?

Enough to make me raise issue #2213 ...


### New `Function.Strict`

Expand Down
2 changes: 1 addition & 1 deletion src/Algebra/Structures/Biased.agda
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. In some sense...

------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Product/Function/Dependent/Propositional.agda
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module _ where
(∀ {x} → A x ↠ B (to I↠J x)) →
Σ I A ↠ Σ J B
Σ-↠ {I = I} {J = J} {A = A} {B = B} I↠J A↠B =
mk↠ (strictlySurjective⇒surjective strictlySurjective′)
mk↠strictlySurjective
where
to′ : Σ I A → Σ J B
to′ = map (to I↠J) (to A↠B)
Expand Down
1 change: 1 addition & 0 deletions src/Function.agda
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ open import Function.Base public
open import Function.Strict public
open import Function.Definitions public
open import Function.Structures public
open import Function.Structures.Biased public
open import Function.Bundles public
2 changes: 1 addition & 1 deletion src/Function/Construct/Symmetry.agda
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module _ {≈₁ : Rel A ℓ₁} {≈₂ : Rel B ℓ₂} {f : A → B} {f⁻¹ :
isLeftInverse : IsRightInverse ≈₁ ≈₂ f f⁻¹ → IsLeftInverse ≈₂ ≈₁ f⁻¹ f
isLeftInverse inv = record
{ isCongruent = isCongruent F.isCongruent F.from-cong
; from-cong = F.cong
; from-cong = F.to-cong
; inverseˡ = inverseˡ ≈₁ ≈₂ F.inverseʳ
} where module F = IsRightInverse inv

Expand Down
2 changes: 1 addition & 1 deletion src/Function/Structures.agda
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ record IsRightInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁
inverseʳ : Inverseʳ _≈₁_ _≈₂_ to from

open IsCongruent isCongruent public
renaming (cong to cong)
renaming (cong to to-cong)

strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from
strictlyInverseʳ x = inverseʳ Eq₂.refl
Expand Down
127 changes: 127 additions & 0 deletions src/Function/Structures/Biased.agda
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)
1 change: 0 additions & 1 deletion src/Relation/Binary/PropositionalEquality.agda
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,3 @@ isPropositional = Irrelevant
Please use Relation.Nullary.Irrelevant instead. "
#-}