You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uninformative error when checking boundaries of functions defined on HITs #6017
cubicalCubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transptype: bugIssues and pull requests about actual bugsux: error reportingIssues to do with how Agda reports errors
{-# OPTIONS --cubical #-}open importCubical.Foundations.PreludedataT: Type wherebase : T
p : base ≡ base
surf : p ∙ p ≡ p
f : (x : T) → x ≡ x
f base = refl
f (p i) = refl
f (surf i j) = refl
produces this error:
(~ i ∨ i) ∨ ~ i₁ ∨ i₁ != ~ i ∨ i of type I
when checking the definition of f
As part of checking IApplyConfluence for the last clause, we encounter this conversion checking problem (I've cleaned up the debug output by hand since the conversion checker doesn't use prettyTCM):
~ i ∨ i ⊢ f (surf i j) = refl
Why? Because the LHS of the clause must equal the RHS of the clause, even under "path reductions" (that's the "IApply" in IApplyConfluence). The face ~ i ∨ i is satisfied when i = i0 and when i= i1. Hence, we must check:
f (surf i0 i) = refl : surf i0 i ≡ surf i0 i
and, cleaning this unification problem up a bit, we see that we have to compare
ap f (p · p) = refl
and that's what goes wrong! The error message is ridiculously uninformative, but f really doesn't commute with path applications. That's why, if you replace refl in the right-hand-side of the definition with a hole, the boundary when i = i0 is terrifying. That's (the normal form of) the hcomp clause for f, specialised for the case p · p. Keeping the CCHM comp instead of reducing it to hcomp + transp, we see that it is:
module _ (i : I) where
_ : f (hcomp (λ { j (i = i0) → base ; j (i = i1) → p j }) (p i))
≡ comp (λ j → hfill (λ { k (i = i0) → base ; k (i = i1) → p k }) (inS (p i)) j
≡ hfill (λ { k (i = i0) → base ; k (i = i1) → p k }) (inS (p i)) j)
(λ { j (i = i0) → f base
; j (i = i1) → f (p j)
})
(f (p i))
_ = refl
and.. that composite is definitely not definitionally refl. So Agda is correctly rejecting this program, but to understand why, you have to poke pretty deep into the implementation.
Reacted by Naïm Camille Favier, favonia and Jon Sterling
I think that, basically everywhere that equalTermOnFace shows up, the resulting error message could use more context. Imagine if it were (this wouldn't even be hard to do; I've been in this part of the code):
(~ i ∨ i) ∨ ~ i₁ ∨ i₁ != ~ i ∨ i of type I
when comparing the terms
f (surf i0 i)
and
refl
which must be equal for this clause to commute with path applications.
The use of "this clause" means that the error's Range would be set to the clause's LHS (we have this handy in IApplyConfluence). Now, annoyingly, it's hard to figure out why each specific interval variable was constrained, hence the generic "commute with path applications" wording. It might be possible to change iApplyVars to tag which variables appeared under a Con pattern; then we might be able to improve the wording to "to respect the (i = i0) face of constructor surf", or whatever.
changed the title [-][cubical] Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/-][+]Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/+]on Aug 14, 2022
changed the title [-]Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/-][+]Uninformative error when checking boundaries of functions defined on HITs[/+]on Aug 14, 2022
cubicalCubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transptype: bugIssues and pull requests about actual bugsux: error reportingIssues to do with how Agda reports errors
Activity
plt-amy commentedon Aug 11, 2022
As part of checking
IApplyConfluencefor the last clause, we encounter this conversion checking problem (I've cleaned up the debug output by hand since the conversion checker doesn't useprettyTCM):Why? Because the LHS of the clause must equal the RHS of the clause, even under "path reductions" (that's the "IApply" in
IApplyConfluence). The face~ i ∨ iis satisfied wheni = i0and wheni= i1. Hence, we must check:and, cleaning this unification problem up a bit, we see that we have to compare
and that's what goes wrong! The error message is ridiculously uninformative, but
freally doesn't commute with path applications. That's why, if you replacereflin the right-hand-side of the definition with a hole, the boundary wheni = i0is terrifying. That's (the normal form of) thehcompclause forf, specialised for the casep · p. Keeping the CCHMcompinstead of reducing it tohcomp+transp, we see that it is:and.. that composite is definitely not definitionally
refl. So Agda is correctly rejecting this program, but to understand why, you have to poke pretty deep into the implementation.plt-amy commentedon Aug 11, 2022
The
(~ i ∨ i) ∨ ~ i₁ ∨ i₁comes from thehfillin thehcompclause forf.plt-amy commentedon Aug 11, 2022
I think that, basically everywhere that
equalTermOnFaceshows up, the resulting error message could use more context. Imagine if it were (this wouldn't even be hard to do; I've been in this part of the code):The use of "this clause" means that the error's
Rangewould be set to the clause's LHS (we have this handy inIApplyConfluence). Now, annoyingly, it's hard to figure out why each specific interval variable was constrained, hence the generic "commute with path applications" wording. It might be possible to changeiApplyVarsto tag which variables appeared under aConpattern; then we might be able to improve the wording to "to respect the (i = i0) face of constructorsurf", or whatever.[-][cubical] Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/-][+]Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/+][-]Weird error when checking boundaries of HITs with paths-between-hcomps constructors[/-][+]Uninformative error when checking boundaries of functions defined on HITs[/+]ncfavier commentedon Aug 18, 2022
Found a similar error on code that doesn't involve HITs:
Uncommenting the lambdas fixes it.
re #6017: add a Call for IApplyConfluence
re #6017: add a Call for IApplyConfluence
re #6017: add a Call for IApplyConfluence (#6218)