-
Notifications
You must be signed in to change notification settings - Fork 242
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
[ refactor ] fixes #2568; proves full symmetry for Bijection
#2569
base: master
Are you sure you want to change the base?
Conversation
Bijection
Bijection
Bijection
CHANGELOG.md
Outdated
* In `Function.Consequences`: the theory of the left inverse of a surjective function | ||
```agda | ||
module Section (surj : Surjective ≈₁ ≈₂ f) | ||
``` |
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.
Should this module be lifted out from Consequences
to the top-level of Function.*
? Or somewhere else?
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.
Given that the only property used in the Section
module is surjective⇒strictlySurjective
, it is tempting to inline that, against lifting out the whole module, and deprecating Function.Consequences.*
entirely, as those properties are nowhere else used in stdlib
? ... downstream PR... ?
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.
Hmmm... not 'nowhere':
Data.Product.Function.Dependent.Setoid
(usingFunction.Consequences.Setoid
)Data.Nat.Binary.Properties
... (typical in usingFunction.Consequences.Propositional
)Data.List.Relation.Unary.Enumerates.Setoid.Properties
(which can be simplified!) [ refactor ]Data.List.Relation.Unary.Enumerates.Setoid.Properties
using tighter lemma fromFunction.Consequences
#2574- the various uses in
Function
module _ (≈₁ : Rel A ℓ₁) (≈₂ : Rel B ℓ₂) {f : A → B} {f⁻¹ : B → A} where | ||
|
||
inverseʳ : Inverseˡ ≈₁ ≈₂ f f⁻¹ → Inverseʳ ≈₂ ≈₁ f⁻¹ f | ||
inverseʳ inv = inv | ||
inverseʳ = id | ||
|
||
inverseˡ : Inverseʳ ≈₁ ≈₂ f f⁻¹ → Inverseˡ ≈₂ ≈₁ f⁻¹ f | ||
inverseˡ inv = inv | ||
inverseˡ = id | ||
|
||
inverseᵇ : Inverseᵇ ≈₁ ≈₂ f f⁻¹ → Inverseᵇ ≈₂ ≈₁ f⁻¹ f | ||
inverseᵇ (invˡ , invʳ) = (invʳ , invˡ) | ||
inverseᵇ = swap | ||
|
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.
It's tempting to want to deprecate/remove this whole section, else move to Function.Consequences
.
In any case, the use of the lemmas in this module has been inlined away, against such a move.
@@ -20,16 +20,16 @@ | |||
module Function.Bundles where | |||
|
|||
open import Function.Base using (_∘_) | |||
open import Function.Consequences.Propositional | |||
using (strictlySurjective⇒surjective; strictlyInverseˡ⇒inverseˡ; strictlyInverseʳ⇒inverseʳ) |
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.
It is tempting to want to inline these, as, in the Propositional
case, they each take on a particularly simple form which is obscured by the three levels of indirection in these definitions...
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.
inline these where?
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.
Firstly, in Function.Consequences.Propositional
(see latest commit), but one could even imagine inlining these definitions (given how simple they are) at any call-site...?
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.
Last words on this:
- I think it is better, given that the types of the corresponding lemmas in
Function.Consequences.Propositional
differ from those inFunction.Consequences{.Setoid}
(by makingf
explicit), we can, moreover should, feel free to reimplement them, as is now done; - the explicit quantification seems necessary in the handful of call-sites where these lemmas are actually used (and with enough of them, that I no longer propose inlining them there)...
- ... BUT is wrong for
strictlyInverseʳ⇒inverseʳ
where it isf⁻¹
which should be supplied explicitly, and notf
! Fixing this should form part of [ DRY ] StreamlineFunction.*
hierarchy #2570
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.
Spectacular work. Just one question and one nitpick.
@@ -20,16 +20,16 @@ | |||
module Function.Bundles where | |||
|
|||
open import Function.Base using (_∘_) | |||
open import Function.Consequences.Propositional | |||
using (strictlySurjective⇒surjective; strictlyInverseˡ⇒inverseˡ; strictlyInverseʳ⇒inverseʳ) |
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.
inline these where?
src/Function/Consequences.agda
Outdated
@@ -23,22 +24,22 @@ private | |||
a b ℓ₁ ℓ₂ : Level | |||
A B : Set a | |||
≈₁ ≈₂ : Rel A ℓ₁ | |||
f f⁻¹ : A → B | |||
to f f⁻¹ : A → B |
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 understand that the way variables work, this declaration of f
and f⁻¹
will actually have the 'right' things in practice, I find the declaration here confusion, i.e. I would prefer an additional line with f⁻¹ : B → A
for clarity.
And I thought you'd rename f
to to
and f⁻¹
to from
everywhere?
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.
Re: variables.
You're absolutely right. Much clearer for ux/ergonomic reasons, and the typechecker needn't care!
Re: inlining.
Two things about this:
- I'd thought these lemmas weren't used quite as much as they are (I was really focused on their use in
Function.*
), so the case for inlining is less strong now - that said, the
Function.Consequences.Propositional
version probably should be inlined/redefined in that module, because in that setting, the waycong
andtrans
are defined for_≡_
means that they take a much simpler form than that inheriting fromSetoid
...
Re: f
and f⁻¹
.
I'd thought to have to
and from
for the new uses (and not simply those in Structures
/Bundles
), but I'm not really a fan of 'gratuitous' alpha-conversion elsewhere, if only for the sake of keeping the footprint of the PR smaller. But I could be persuaded... ;-)
A comprehensive overhaul building on the proposed refactoring in #2568 . Finally finished, I think!
UPDATED: now all 'done', and a lot tighter/smoother/cleaner
Function.Consequences
? (check implicit/explicit bindings of lemmas there, esp. in their use later)Bijection
now proved, old weaker formsym-≡
etc. now deprecated (this was abug
!)Congruent ≈₂ ≈₁ section
outright under similar equational assumptions!Function.Construct.Symmetry
Congruent ≈₁ ≈₂ f
from{injective|bijective}
IsBijective
, and ofBijection
, without detour viaInverse
TODO:
CHANGELOG
Function.Construct.Symmetry
Function.Properties.Bijection
to prove full symmetry ofIsBijective
etc.NB.
Function.*
to rationalise the existence of a section to a givenSurjective f
#2568 are optional, it's more a case of agreeing the 'right' names; existing commits make the change so as to highlight where the work has happened*WithoutCongruence
constructions, but a v3.0 cleanup PR would remove the old proofs entirely and rename to remove that suffix