-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add code for generating and working with quotients #43
base: master
Are you sure you want to change the base?
Conversation
I'm not sure where are you using |
Oh, |
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.
One thing that could be nice would be to do the right %access
incantations in UnsafeQuotient
so that the commuting triangle in exists
would commute pointwise.
It might also be worth it to split up the dependent pair in exists
into two fields in the record, since this is the way to define functions out of the quotient.
module Quotients | ||
|
||
import Quotient.Quotient | ||
|
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 use %access public export
?
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 point, forgot that.
src/Quotient/UnsafeQuotient.idr
Outdated
(QuotientType x eq) | ||
(Wrap ** (\a, b, h => QuotientEquality x eq h)) | ||
(\y, f => ((\a => fst f $ unwrap a) ** (\a => Refl))) | ||
(\y, f, g, h, a => trans (cong $ wrapUnwrapId a) (sym $ h $ unwrap a)) |
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.
(\y, f, g, h, a => trans (cong $ wrapUnwrapId a) (sym $ h $ unwrap a)) | |
(\y, f, g, h, (InternalWrap a) => sym $ h a) |
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 find these things very weird. In the previous line where I use unwrap
, I cannot pattern match in the lambda, while in this line I can. The only reason why unwrap
exists is because it didn't work there for me. Do you or @clayrat have any insight as to what might be the issue there?
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.
As for the dependent pair, do you mean that it would be nicer if we didn't have to write
fst $ exists ...
? In that case, I'd just define another function.
Concretely, I suggest to replace the exists
field with the following two fields (possibly with better chosen names):
extension : (y : Type) -> (f : RespectingMap x y eq)
-> carrier -> y
commutes : (y : Type) -> (f : RespectingMap x y eq)
-> extEq (fst f) (extension y f . (fst proj))
Why?
- Most of the time, the function
extension y f
is probably what you want easy access to (what I tried to say above). - Should make it easier to build things stepwise using holes, because Idris doesn't need to juggle sigma types and first projections etc.
- Might make it easier to talk about the code, e.g. 'the commuting triangle in
exists
' above is thecommutes
field.
I'm not sure what you mean by 'the commuting triangle in
exists
would commute pointwise'.
What I meant was that in the Quotients.Unsafe
module, the proof of commutes y f a
is Refl
for every a
, which is nice, but outside this module, nothing reduces anymore.
Wrap : x -> QuotientType x eq | ||
Wrap = InternalWrap | ||
|
||
unwrap : QuotientType x eq -> x |
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.
Probably best not to export unwrap
, as it corresponds to a form of global axiom of choice?
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.
Oh, completely missed that.
I'm not sure what you mean by 'the commuting triangle in As for the dependent pair, do you mean that it would be nicer if we didn't have to write |
This adds some generic code for dealing with (extensional) quotients