Zulip Chat Archive

Stream: general

Topic: VSCode underlines wrong position


Kenny Lau (Sep 23 2020 at 09:46):

variables (α : Type) [has_mul α] (f : α  α  α) (n1 n2 n3 : α)
#check by have : f (n1 * n2) n3 = function.uncurry f (n1 * n2)

Kenny Lau (Sep 23 2020 at 09:47):

Kenny Lau (Sep 23 2020 at 09:48):

VSCode highlights the first (n1 * n2) as the error, when it is in fact the second (n1 * n2) that causes the type mismatch

Kevin Buzzard (Sep 23 2020 at 11:29):

+1 for #check by have

Jasmin Blanchette (Sep 23 2020 at 11:37):

I'm not sure it's a bug. Type inference/checking in languages like ML, Haskell, and Lean is done by collecting and solving some constraints. It doesn't work left-to-right, and it often fails to identify the root cause.

Kenny Lau (Sep 23 2020 at 11:39):

it's a bug because if you do this instead:

variables (α : Type) [has_mul α] (f : α  α  α) (n1 n2 n3 : α)
#check f (n1 * n2) n3 = function.uncurry f (n1 * n2)

Kenny Lau (Sep 23 2020 at 11:39):

then the error is on the second n1 * n2 as it should

Jasmin Blanchette (Sep 23 2020 at 11:40):

Maybe it's a bug, but your argument doesn't convince me. ;)

Kenny Lau (Sep 23 2020 at 11:40):

well why can it identify the root cause in term mode but not in tactic mode?

Jasmin Blanchette (Sep 23 2020 at 11:41):

I don't know the procedure, but for all I know it could be nondeterministic and report random results.

Jasmin Blanchette (Sep 23 2020 at 11:42):

(The E prover, for example, compares pointers and is therefore nondetermistic.)

Kevin Buzzard (Sep 23 2020 at 11:43):

Maybe different elaboration strategies are being used for some reason?

Kevin Buzzard (Sep 23 2020 at 11:43):

I believe I've seen proofs of the form := <term> which fail, and then succeed with := by exact <term>

Mario Carneiro (Sep 23 2020 at 14:24):

I get a different error (failed to synthesize type class instance for has_mul (α × α)), but the error reporting is similarly odd. In particular, it reports the first term only when you use the same expression in both places, e.g. if you use n1 * n3 on the left then it reports on the right as you would expect. My guess is that it is hash consing the expressions and associating the error location to that, meaning that when we report the error we've forgotten which n1 * n2 was responsible for the error

Kevin Buzzard (Sep 23 2020 at 14:29):

So then it should be really easy to confuse lean in this way and we probably would have spotted it years ago?

Mario Carneiro (Sep 23 2020 at 14:34):

Indeed. It could be interacting with another feature though, like the have tactic or some other aspect here making it more niche

Gabriel Ebner (Sep 23 2020 at 14:59):

Hash consing is disabled by default IIRC.

Reid Barton (Sep 23 2020 at 15:02):

Is this at all related to rw thinking that it should rewrite every occurrence of whatever expression it decides to rewrite (e.g., x * y)?

Sebastian Ullrich (Sep 23 2020 at 15:16):

No idea what Lean 3 is doing there, but Lean 4 says image.png

Mario Carneiro (Sep 23 2020 at 15:17):

I see CoeT is dependent now :P

Sebastian Ullrich (Sep 23 2020 at 15:20):

The only non-hacky way to have

instance decPropToBool (p : Prop) [Decidable p] : CoeDep Prop p Bool :=
{ coe := decide p }

Mario Carneiro (Sep 23 2020 at 15:26):

:+1:

Eric Wieser (Sep 23 2020 at 16:33):

What's the story behind the change to CamelCase? Is the scope of the change just type classes, or does it extend to lemmas and defs too?

Mario Carneiro (Sep 23 2020 at 16:54):

they thought that lean didn't look enough like java


Last updated: Dec 20 2023 at 11:08 UTC