Zulip Chat Archive
Stream: general
Topic: when to use abbrev over def?
Lhr (Feb 11 2026 at 11:35):
given
def positive n := n > 0
def negative n := n < 0
which is the better way to define neutral?
def neutral n := ¬(positive n ∨ negative n)
abbrev neutral n := ¬(positive n ∨ negative n)
This is a toy example, I run into this question often
Henrik Böving (Feb 11 2026 at 11:58):
When you want type class instances of the thing on the rhs of your def to be reused for the thing you are defining use abbrev, otherwise don't.
Mirek Olšák (Feb 11 2026 at 12:04):
I don't think it is only about typeclass instances. Also simp can often see through abbrev, and you might not want to create a new set of simp lemmas just for a thin layer above.
Shreyas Srinivas (Feb 11 2026 at 17:43):
Henrik Böving said:
When you want type class instances of the thing on the rhs of your
defto be reused for the thing you are defining useabbrev, otherwise don't.
Or when you are defining a type and don’t want to have to tell lean that the lhs and rhs are equal by definition when a type check fails
Last updated: Feb 28 2026 at 14:05 UTC