Zulip Chat Archive
Stream: mathlib4
Topic: data.bitvec.core mathlib4#1731
Shreyas Srinivas (Jan 20 2023 at 17:14):
I encountered an error in the following:
/-- bitwise not -/
def not : Bitvec n → Bitvec n :=
map not
#align bitvec.not Bitvec.not
/-- bitwise and -/
def and : Bitvec n → Bitvec n → Bitvec n :=
map₂ and
#align bitvec.and Bitvec.and
/-- bitwise or -/
def or : Bitvec n → Bitvec n → Bitvec n :=
map₂ or
#align bitvec.or Bitvec.or
/-- bitwise xor -/
def xor : Bitvec n → Bitvec n → Bitvec n :=
map₂ xor
#align bitvec.xor Bitvec.xor
Shreyas Srinivas (Jan 20 2023 at 17:15):
in each instance the boolean operation say not
was being interpreted as Bitvec.not
inside the def. This seems to be an error in the type inference.
Shreyas Srinivas (Jan 20 2023 at 17:17):
I can't fix this by introducing explicit arguments, but if I recall my haskell experience, the type inference algorithm would have taken care of it
Shreyas Srinivas (Jan 20 2023 at 17:18):
Why is this happening?
Shreyas Srinivas (Jan 20 2023 at 17:18):
and what is the lean4 fix?
Reid Barton (Jan 20 2023 at 17:28):
_root_.not
etc should work, or Bool.not
or whatever the right name is
Eric Wieser (Jan 20 2023 at 17:45):
nonrec def
should also fix it
Reid Barton (Jan 20 2023 at 18:56):
Ah nice, I have encountered this also in non-mathlib contexts and that could have been useful to know.
Kevin Buzzard (Jan 20 2023 at 20:09):
Shreyas Srinivas said:
Why is this happening?
It's because his is how Lean 4 works: priority goes to what you're currently defining. Whether that's a good idea is another question.
Notification Bot (Jan 24 2023 at 13:14):
24 messages were moved from this topic to #mathlib4 > nonrec vs _root_ by Eric Wieser.
Last updated: Dec 20 2023 at 11:08 UTC