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
Do not create/display superfluous metas and show constraints in a readable way #3606
constraintsConstraints (postponed type checking problems, postponed unification problems, instance constraints)metaMetavariables, insertion of implicit arguments, etctype: enhancementIssues and pull requests about possible improvementsux: error reportingIssues to do with how Agda reports errors
(related to #3605, but without cubical features)
When loading the code below, it gives two unsolved metas and an "error" about some constraint not being solved. Yet the hole can simply be filled with x and it works. From a user point of view, I don’t see why there should be unsolved metas, it’s confusing that Agda reports an error, and the whole thing is not very readable.
postulateA :SetP : A →SetrecordΣAP:Setwhereno-eta-equalityfieldfst : A
snd : P fst
openΣAPtest : (x : ΣAP) → P (fst x)
test x = snd {!!}
Output of C-c C-l:
?0 : ΣAP
_6 : P (fst x) [ at […]:13,10-18 ]
_7 : P (fst x) [ at […]:13,10-18 ]
———— Errors ————————————————————————————————————————————————
Failed to solve the following constraints:
_6 := λ x → snd (?0 (x = x)) [blocked on problem 9]
[9, 10] fst ?0 = fst x : A
Expected result:
?0 : ΣAP
———— Constraints ————————————————————————————————————————————————
fst ?0 = fst x : A
Reacted by Jesper Cockx and Apostolis Xekoukoulotakis
I would guess that one reason for showing these blocking metas _8, _9, .. is so that you do not expect some reduction that won't happen.
For example in the following you have ?1 of type isTrue _9. We have that isTrue _9 is not definitionally ⊤ until we have given a sensible definition to A. So showing ?1 : isTrue x would be misleading as well.
However, we can probably find a better way to convey this?
It's also puzzling why we do not get a definition for _9 displayed.
open importAgda.Builtin.Boolopen importAgda.Builtin.Unitdata⊥:SetwhereisTrue : Bool →Set
isTrue true = ⊤
isTrue false = ⊤
A : Bool →Set
A = { }0x : A true
x = true
test : isTrue x
test = { }1
Information buffer:
?0 : Bool → Set
?1 : isTrue _9
_5 : ?0 true [ at Issue3606.agda:16,5-9 ]
_6 : ?0 true [ at Issue3606.agda:16,5-9 ]
_8 : Bool [ at Issue3606.agda:18,15-16 ]
_9 : Bool [ at Issue3606.agda:18,15-16 ]
———— Errors ————————————————————————————————————————————————
Failed to solve the following constraints:
_8 := x [blocked on problem 12]
[12] ?0 true =< Bool : Set
_5 := true [blocked on problem 11]
[11] Bool =< ?0 true : Set
I don’t really understand your example, it seems to me that the only constraint here is
?0 true == Bool : Set
And whatever (sensible) definition you give for A, you will always have that ?1 : isTrue x and that isTrue x reduces to ⊤.
But we don’t know yet that isTrue x is well-typed (it depends on the constraint being satisfied), so maybe this is what prevents Agda from reducing it anyway? I’m not familiar with the way Agda handles constraints and not-yet-well-typed terms.
As a variant of your example, I tried to replace the definition of A by
A : Bool →Set
A true ={!!}
A false ={!!}
but it still gives essentially the same thing. Why can’t Agda figure out that the goal in A true = ? must be Bool?
In particular in my example we don't know that the definition of x is well-typed, so x will not reduce to true. The way I see it is that Agda is trying to enforce that both type preservation and typing inversion lemmas hold at all times, without assuming that the outstanding constraints are true.
In your variation where A is defined by cases there's the additional complication that metas created as part of a mutual block are frozen at the end of it. This was a design choice taken to avoid code much later in the file determining what an earlier meta should be.
The following does allow Agda to determine that ?2 should be Bool
mutualA : Bool →Set
A true = { }2
A false = { }3x : A true
x = true
I did some digging and discovered why we get some metas like _9 above, with no constrains displayed. Tracing it back to commit adf9065 .
In particular there's a comment motivating the behavior: adf9065#diff-32adfcdd487db3ba46f6896d55c5ae44R266
Whenever a term is blocked into a meta m such meta m is not passed around, instead another meta m1 is generated and returned as the actual term so that m1 will accumulate further unification constrains and possibly get solved. Whenever m gets unblocked Agda constraints m and m1 to be equal, keeping everything in sync.
So in a situation where m is still blocked and m1 did not get solved we get things like _9 above, which seem disconnected from anything else.
constraintsConstraints (postponed type checking problems, postponed unification problems, instance constraints)metaMetavariables, insertion of implicit arguments, etctype: enhancementIssues and pull requests about possible improvementsux: error reportingIssues to do with how Agda reports errors
Activity
jespercockx commentedon Mar 4, 2019
I expect this would greatly improve the readability of many of the eldritch invocations that Agda regularly spews at the user.
Saizan commentedon Mar 12, 2019
I would guess that one reason for showing these blocking metas
_8, _9, ..is so that you do not expect some reduction that won't happen.For example in the following you have
?1of typeisTrue _9. We have thatisTrue _9is not definitionally⊤until we have given a sensible definition toA. So showing?1 : isTrue xwould be misleading as well.However, we can probably find a better way to convey this?
It's also puzzling why we do not get a definition for
_9displayed.Information buffer:
guillaumebrunerie commentedon Mar 12, 2019
I don’t really understand your example, it seems to me that the only constraint here is
And whatever (sensible) definition you give for
A, you will always have that?1 : isTrue xand thatisTrue xreduces to⊤.But we don’t know yet that
isTrue xis well-typed (it depends on the constraint being satisfied), so maybe this is what prevents Agda from reducing it anyway? I’m not familiar with the way Agda handles constraints and not-yet-well-typed terms.As a variant of your example, I tried to replace the definition of
Abybut it still gives essentially the same thing. Why can’t Agda figure out that the goal in
A true = ?must beBool?Saizan commentedon Mar 12, 2019
In particular in my example we don't know that the definition of
xis well-typed, soxwill not reduce totrue. The way I see it is that Agda is trying to enforce that both type preservation and typing inversion lemmas hold at all times, without assuming that the outstanding constraints are true.In your variation where
Ais defined by cases there's the additional complication that metas created as part of a mutual block arefrozenat the end of it. This was a design choice taken to avoid code much later in the file determining what an earlier meta should be.The following does allow Agda to determine that
?2should beBoolSaizan commentedon Mar 13, 2019
I did some digging and discovered why we get some metas like
_9above, with no constrains displayed. Tracing it back to commit adf9065 .In particular there's a comment motivating the behavior: adf9065#diff-32adfcdd487db3ba46f6896d55c5ae44R266
Whenever a term is blocked into a meta
msuch metamis not passed around, instead another metam1is generated and returned as the actual term so thatm1will accumulate further unification constrains and possibly get solved. Whenevermgets unblocked Agda constraintsmandm1to be equal, keeping everything in sync.So in a situation where
mis still blocked andm1did not get solved we get things like_9above, which seem disconnected from anything else.Saizan commentedon Apr 12, 2019
@UlfNorell @andreasabel @jespercockx @nad Anyone opposed to instantiating away blocking metas when printing out constraints?
xekoukou commentedon Apr 16, 2019
Here is one error message I get because it can not find 3 implicit arguments on a SINGLE function. Error messages do not help at all.
[ Re agda#3606 ] instantiate blocking metas in unsolved constraints w…
[ Re agda#3606 ] Do not list blocking metas nor "UnBlock" constraints
[ Re agda#3606 ] instantiate blocking when showing types of open metas
12 remaining items
[ Re agda#3606 ] reifyUnblocked when showing goal and context types
[ Re agda#3606 ] "reifyUnblocked" for unsolved constraints warnings
[ Re agda#3606 ] Do not list blocking metas nor "UnBlock" constraints
[ testsuite agda#3606 ] Updated error messages in the testsuite
[ Re agda#3606 ] Goal Constraints: instantiate blocking metas too.
[ Re agda#3606 ] Do not show "Failed .." if no constraints are showing
[ Re agda#3606 ] Do not crash on underapplied constructors.
Merge pull request #3723 from Saizan/instantiate-blocking
Saizan commentedon Nov 20, 2019
For the original code example we now get the following, which is much closer to the expected.
Things to consider:
[9,10]?Errorsheader or turn it intoConstraints?[ fix #3606 ] don't print problem ids in constraints unless they bloc…
[ fix #3606 ] don't print problem ids in constraints unless they bloc…
Merge pull request #4227 from agda/issue3606