Skip to content

Improve constraint reporting for cubical #3605

Closed

Description

@guillaumebrunerie

This is surely well-known but I haven’t found a bug report about it. I find it quite difficult to work with cubical Agda because the constraint reporting on end points is incomprehensible. See for instance the code below.

{-# OPTIONS --cubical #-} 

open import Cubical.Core.Everything public

postulate
  A : Set
  a b a' b' : A
  p : a ≡ b

test : a' ≡ b'
test i = hcomp (λ j → (λ {(i = i0) → ?; (i = i1) → ?})) (p i)

Current output when doing C-c C-l:

?0 : A
?1 : A
_15 : A  [ at /tmp/xx.agda:11,10-68 ]
_16 : A  [ at /tmp/xx.agda:11,10-68 ]

———— Errors ————————————————————————————————————————————————
Failed to solve the following constraints:
  a' = _16 (i = i0) : A
  b' = _16 (i = i1) : A
  _15
    := λ i →
         hcomp (λ j → λ { (i = i0) → ?0 (j = j) ; (i = i1) → ?1 (j = j) })
         (p i)
    [blocked on problem 20]
  [20] b = ?1 (j = i0) : A
  [20] a = ?0 (j = i0) : A

Expected output:

?0 : A
?1 : A

———— Constraints ————————————————————————————————————————————————
?0 (j = i0) = a : A
?0 (j = i1) = a' : A
?1 (j = i0) = b : A
?1 (j = i1) = b' : A

In addition, there shouldn’t be any yellow in this file.

Activity

  1. added
    type: enhancement
    ux: error reporting
    cubical
    on Mar 4, 2019
  2. Saizan commented on Mar 4, 2019

    @Saizan
    Collaborator

    In addition, there shouldn’t be any yellow in this file.

    How so? There's plenty of unsatisfied constraints around.

    I mean, I agree that it's annoying to have so much yellow around, but yellow for unsolved constraints is a fairly expected UI principle of agda.

  3. guillaumebrunerie commented on Mar 4, 2019

    @guillaumebrunerie
    MemberAuthor

    Maybe I’m using the word "constraints" in a wrong way here, but I thought that yellow meant unsolved metas, not unsolved constraints.
    For instance

    u : A
    u = ?

    has an unsolved "constraint", namely that ?0 : A, yet there shouldn’t be any yellow.

  4. jespercockx commented on Mar 4, 2019

    @jespercockx
    Member

    Agda uses yellow for both unsolved metas and unsolved constraints. Originally 'constraint' meant 'equality constraint' but a lot of other constraints have been added since, including postponed typechecking problem 'constraints' x : A.

    [...] has an unsolved "constraint", namely that ?0 : A, yet there shouldn’t be any yellow.

    Actually I think there is yellow but it's hidden by the hole.

  5. guillaumebrunerie commented on Mar 4, 2019

    @guillaumebrunerie
    MemberAuthor

    Ah ok. So then maybe that the two constraints ?0 (j = i0) = a and ?0 (j = i1) = a' should be considered to be constraints about ?0 and therefore be hidden by the hole as well, and similarly for ?1?

  6. jespercockx commented on Mar 4, 2019

    @jespercockx
    Member

    I feel like for unsolved constraints that are blocked on an interaction meta, the yellow is often not very helpful. OTOH if there are no more interaction holes but still unsolved constraints then I really want to see the highlighting. So maybe we should try to keep track of which meta a constraint is blocked on (I think in principle we do already but it's not very accurate) and wait with displaying constraints blocked on interaction metas.

  7. jespercockx commented on Mar 4, 2019

    @jespercockx
    Member

    Or we could even only highlight constraints that are not blocked on any meta (but still unsolved). After all, if there are unsolved metas they will be highlighted already and this will often give you a better idea of the location where to insert the implicit argument.

  8. gallais commented on Mar 4, 2019

    @gallais
    Member

    Actually I think there is yellow but it's hidden by the hole.

    Technically we actively remove interaction metas from the set of metas that should
    be highlighted. But the result is the same: they are not displayed.

  9. guillaumebrunerie commented on Mar 4, 2019

    @guillaumebrunerie
    MemberAuthor

    In any case, in addition to the issue about the yellow:

    • there shouldn’t be any unsolved metas except for the two goals (where do _15 and _16 come from?)
    • the word "error" should not be used, there is no error, only yet-to-be-satisfied constraints
  10. guillaumebrunerie commented on Mar 4, 2019

    @guillaumebrunerie
    MemberAuthor

    I feel like for unsolved constraints that are blocked on an interaction meta, the yellow is often not very helpful. OTOH if there are no more interaction holes but still unsolved constraints then I really want to see the highlighting. So maybe we should try to keep track of which meta a constraint is blocked on (I think in principle we do already but it's not very accurate) and wait with displaying constraints blocked on interaction metas.

    Do you have an example of code with no interaction metas and no unsolved metas, but still unsolved constraints? I had the impression that because type-checking and conversion are decidable, if there is no unsolved metas then all type-checking/equality constraints are either provably true or provably false, so I do not see when it is needed to have yellow for unsolved constraints.

  11. Saizan commented on Mar 4, 2019

    @Saizan
    Collaborator

    @guillaumebrunerie As far as I understand there has to be an unsolved meta, but what gets highlighted is the code which depends on the constraint being satisfied to successfully typecheck.

    Also the "_15" and "_16" metas are generated because some terms are blocked on the resolution of a constraint. Agda replaces those terms by metas (storing what they should eventually be), so that it doesn't have to deal with ill-typed terms internally. I agree it's not something (most) users want to see though.

  12. guillaumebrunerie commented on Mar 4, 2019

    @guillaumebrunerie
    MemberAuthor

    @Saizan Ah, that makes sense.

    The _15 and _16 and the "error" are actually not related to cubical, so I filed #3606 (although it does come up very often when using hcomp).

  13. added this to the 2.6.1 milestone on Mar 4, 2019
  14. added a commit that references this issue on Mar 4, 2019
  15. Saizan commented on Mar 5, 2019

    @Saizan
    Collaborator

    @guillaumebrunerie My last commit should have improved the situation with hcomp and friends.

    At least the constraints shown are more readable:

    ———— Errors ————————————————————————————————————————————————
    Failed to solve the following constraints:
      a' = ?0 (j = i1) : A
      b' = ?1 (j = i1) : A
      _15 := λ i → p i [blocked on problem 20]
      [20] b = ?1 (j = i0) : A
      [20] a = ?0 (j = i0) : A
    

    I also plan on having something more systematic at least for interaction points in positions like foo .... = ?, but let me know if you have other bad experiences with arguments to hcomp/transp/comp.

  16. Saizan commented on Dec 2, 2019

    @Saizan
    Collaborator

    The original reported example looks fairly good now.

    I'm leaving this up for improvements to the "interaction boundaries" machinery.

    Such as propagating boundaries through introductions and other possible cases.

  17. modified the milestones: 2.6.1, 2.6.2 on Dec 2, 2019
  18. modified the milestones: 2.6.2, 2.6.3 on May 8, 2021
  19. modified the milestones: 2.6.3, Later on Aug 26, 2022
  20. modified the milestones: later, 2.6.4 on Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cubicaltype: enhancementux: error reporting

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions