Zulip Chat Archive
Stream: general
Topic: Showing automatically obtained typeclass instances
Seul Baek (May 28 2018 at 23:40):
Is it possible to show which instance Lean is using when it successfully performs a typeclass inference?
For instance, I know from the fact that I can use neg_le_neg
with integers that Lean has silently performed a typeclass inference and found an instance of type ordered_comm_group int
. But I don't know exactly which instance Lean has found. Is there a way to display this information, similar to how I can jump to definitions using f12?
Kenny Lau (May 28 2018 at 23:43):
you can print the proof of your theorem
Kenny Lau (May 28 2018 at 23:43):
using #print
Kenny Lau (May 28 2018 at 23:44):
and you can set pp.implicit true
(there may be a better option) to see the implicit arguments, including the proof of the typeclass inference
Scott Morrison (May 28 2018 at 23:44):
set_option trace.class_instances true
Kenny Lau (May 28 2018 at 23:44):
well that displays too much information
Seul Baek (May 28 2018 at 23:50):
Thanks!
Mario Carneiro (May 29 2018 at 01:13):
you can also test instance problems with
theorem T : ordered_comm_group int := by apply_instance #print T
Kenny Lau (May 29 2018 at 01:13):
#check (by apply_instance : ordered_comm_group int)
Kenny Lau (May 29 2018 at 01:13):
do I win?
Mario Carneiro (May 29 2018 at 01:14):
clever
Last updated: Dec 20 2023 at 11:08 UTC