Closed JasonGross closed 11 years ago
That one's tricky and already exists in the trunk. It is due to [apply]'s unification treating evar assignments in the wrong order, so it tries to retypecheck [fun x : ?5 => ... forall t : x, ...] before assigning [5 := Type]. The retyping of the forall fails as it cannot see that the type of x, ?5 is indeed a sort. I'm trying a heuristic fix by reversing the order of assignments, but this feels really hackish. [refine] does not have this problem.
Thanks for the fix! Could retypechecking be made to trigger further evar unification in this case, or would that break some no-side-effects invariant or significantly complicate code?
In principle, this could be done, but I can't speculate what the side effects of this would be. Also, it would require a significant change in code. The clean solution is to use solely the unification algorithm used by refine and type-checking, which does not have this problem: starting from two well-typed terms with existentials, that unification algorithm can't produce (even temporarily) ill-typed instantiations.
As a side note, we're still waiting for the new proof engine of Coq to be merged in trunk, which will hopefully allow us to get rid of this other, badly behaved unification.
This change breaks HoTT/HoTT. Most of the fixes are small (changing apply
to refine
), but there's one place where it breaks argument inference for refine
, another place where it breaks argument inference for rewrite
, and another place where I had to add an extra simpl
. See https://github.com/HoTT/HoTT/pull/153.
I'm running into a bunch of problems in rewrite
ing with lemmas like ap_pp
and ap10_pp
, which I suspect might be caused by this change; the type of ap_pp
is ap_pp : forall (A B : Type) (f : forall _ : A, B) (x y z : A) (p : @paths A x y) (q : @paths A y z), @paths (@paths B (f x) (f z)) (@ap A B f x z (@concat A x y z p q)) (@concat B (f x) (f y) (f z) (@ap A B f x y p) (@ap A B f y z q))
, and sometimes I have to explicitly give the arguments. Is it possible that a side-effect of this change is that unification fails on f x
, because it happens before f
is instantiated?
It could be, I think for now the best option is to fallback to the old behavior (but raising an error instead of an anomaly for the funext example). I'm going away for a while and couldn't find a better quick fix.
Le 27 juil. 2013 à 21:08, Jason Gross notifications@github.com a écrit :
I'm running into a bunch of problems in rewriteing with lemmas like ap_pp and ap10_pp, which I suspect might be caused by this change; the type of ap_pp is appp : forall (A B : Type) (f : forall : A, B) (x y z : A) (p : @paths A x y) (q : @paths A y z), @paths (@paths B (f x) (f z)) (@ap A B f x z (@concat A x y z p q)) (@concat B (f x) (f y) (f z) (@ap A B f x y p) (@ap A B f y z q)), and sometimes I have to explicitly give the arguments. Is it possible that a side-effect of this change is that unification fails on f x, because it happens before f is instantiated?
— Reply to this email directly or view it on GitHub.
Note: This gives "Ill-typed evar instance" in HoTT/coq trunk, but is fixed in trunk-polyproj.
The code
causes
If I manually instantiate the first parameter (if I do
apply (@functional_extensionality_dep Type).
), then it works fine.