Skip to content
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

Why bother with Agda.Builtin.Cubical.Id? #157

Closed
amp12 opened this issue Jun 18, 2019 · 13 comments
Closed

Why bother with Agda.Builtin.Cubical.Id? #157

amp12 opened this issue Jun 18, 2019 · 13 comments
Labels
faq (frequently) asked questions wontfix This will not be worked on

Comments

@amp12
Copy link

amp12 commented Jun 18, 2019

The following is a question/comment, rather than a bug report.

As I understand it, Agda.Builtin.Cubical.Id hardwires into
Agda-cubical Andrew Swan's trick for creating an identity type with
definitional computational rule within the cubical sets model of Type
Theory.

Why bother? There is already a perfectly good identity type with
definitional computational rule within Agda, given by
Agda.Builtin.Equality (≡). This can be proved to be path equivalent to
Agda-cubical's path type (here denoted ~ to distinguish it from
) -- see the proof
here.

The advantage of over Id from Agda.Builtin.Cubical.Id is that we
have access to pattern matching on refl.

@martinescardo
Copy link
Contributor

martinescardo commented Jun 18, 2019 via email

@martinescardo
Copy link
Contributor

Also using this trick of yours (which I tried myself to be able to do pattern atching on refl as you say) breaks computation, and this is a reason for not using the Agda builtin equality with cubical Agda.

@Saizan
Copy link
Contributor

Saizan commented Jun 18, 2019

Soon transp will actually compute for inductive families, which should indeed make the equality from Agda.Builtin.Equality no lesser than Swan's Id.

@martinescardo
Copy link
Contributor

That'd be great.

@martinescardo
Copy link
Contributor

It will mean that I have to do nothing to port my development from Agda to cubical Agda.

@amp12
Copy link
Author

amp12 commented Jun 18, 2019

@martinescardo: could you elaborate your comment about it breaking computation? (an example?)

@martinescardo
Copy link
Contributor

In principle I could. But I will not try as I can't come up with a quick example. The way we discovered this, with Chuangjie, was when porting his PhD thesis Agda code to cubical.

http://www.cs.bham.ac.uk/~mhe/chuangjie-xu-thesis-cubical/

The first thing we tried was precisely your trick. Then when we tried to compute a modulus of uniform continuity, which should have been zero, we instead got a pattern matching runtime error.

We then instead used Swan's identity type and converted all definitions by pattern matching to uses of J, which took 10 hours.

@amp12
Copy link
Author

amp12 commented Jun 18, 2019

you are truly dedicated scholars! :-)

@martinescardo
Copy link
Contributor

I think it is enough to use an example that uses funext to compute a number, such as the one I gave in this file https://github.com/agda/cubical/blob/master/Cubical/Foundations/HoTT-UF.agda

@Saizan
Copy link
Contributor

Saizan commented Jun 18, 2019

Here's a small example.

open import Agda.Builtin.Equality
open import Agda.Primitive.Cubical renaming (primTransp to transp)

coerce : ∀ {A B : Set} → A ≡ B → A → B
coerce refl x = x

data D : Set where
  d : D

test = coerce (transp (\ _ → D ≡ D) i0 refl) d

{-                                                                                                                                                                                     
                                                                                                                                                                                       
C-c C-n test                                                                                                                                                                           
                                                                                                                                                                                       
Time: 2ms                                                                                                                                                                              
coerce (transp (λ _ → D ≡ D) i0 refl) d                                                                                                                                                
                                                                                                                                                                                       
-}

@martinescardo
Copy link
Contributor

martinescardo commented Jun 18, 2019

@Saizan : I am puzzled how being able to compute with inductive families will make the above example work.

@martinescardo
Copy link
Contributor

martinescardo commented Jun 18, 2019

@amp12 To elaborate a bit, what happens is that Agda computes by matching on refl, but then instead of seeing a refl it sees something injected in the identity type by the equivalence you describe, which is not a refl, and then Agda doesn't know what to do.

@Saizan
Copy link
Contributor

Saizan commented Jun 19, 2019

@martinescardo In the future, coerce will be automatically given extra clauses that will be able to deal with the residual transports on the index, as those too will be canonical elements, given that they cannot be represented by refl.

@Saizan Saizan added faq (frequently) asked questions wontfix This will not be worked on labels Jul 29, 2019
@Saizan Saizan closed this as completed Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
faq (frequently) asked questions wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants