Zulip Chat Archive
Stream: lean4
Topic: LawfulBEq instance
Ben Selfridge (Mar 22 2025 at 04:30):
Hi all,
I have this data type:
inductive Term
| Var : Nat → Term
deriving BEq, Repr
And I am trying to fill in the sorry
here:
instance instLawfulBEq : LawfulBEq Term := sorry
Can anyone point me in the right direction?
Andrés Goens (Mar 22 2025 at 07:55):
this is not quite trying to fill in the sorry
explicitly, but you can get a LawfulBEq
instance directly from a DecidableEq
instanc. I'd argue DecidableEq
is usually a better instance if you want to reason about equality than BEq, but you get BEq derived from it.
inductive Term
| Var : Nat → Term
deriving DecidableEq, Repr
#synth LawfulBEq Term -- instLawfulBEq
Andrés Goens (Mar 22 2025 at 08:00):
(the problem with your version is that the deriving
machinery builds the instance under the hood, and so it's going to be hard to look into its definition when proving its lawfulness)
Last updated: May 02 2025 at 03:31 UTC