Zulip Chat Archive

Stream: new members

Topic: How to check definitional equality?


Thomas Brooks (Feb 27 2022 at 13:33):

Is there an simple way in Lean to check if two expressions are definitionally equal? I'm trying to check my understanding of what is definitionally equal in Lean and am not sure how to do this (I'm probably overlooking something very simple).

Riccardo Brasca (Feb 27 2022 at 13:35):

You can just check if example foo = bar := rfl works

Thomas Brooks (Feb 27 2022 at 13:50):

What am I doing wrong when I try something trivial like example (Prop = Prop) := rfl I get several errors:

exercises.lean:4:8
don't know how to synthesize placeholder
context:
 Sort ?
exercises.lean:4:9
invalid binder, identifier expected
exercises.lean:4:9
command expected

Mario Carneiro (Feb 27 2022 at 13:50):

use triple backtick for multiline code blocks

Riccardo Brasca (Feb 27 2022 at 13:51):

First of all I forgot the : in my example, sorry.

Mario Carneiro (Feb 27 2022 at 13:51):

you are missing a colon: example: (Prop = Prop) := rfl

Riccardo Brasca (Feb 27 2022 at 13:51):

Then refl is a tactic, you should use rfl (without the e).

Thomas Brooks (Feb 27 2022 at 13:52):

Okay thank you, that has fixed it! Oddly, I am using triple-backticking in my message but it still displays incorrectly.

Mario Carneiro (Feb 27 2022 at 13:53):

the triple backtick has to be on its own line (both the beginning and the end one)

Riccardo Brasca (Feb 27 2022 at 13:53):

And pay attention that you are proving equality of types, that is something a little odd (even if in this case it works). If you want to try something mathematically meaningful you can prove 1+1=2.

Thomas Brooks (Feb 27 2022 at 13:57):

Yes, I was trying the most trivial statement I could think of since I was getting errors on more meaningful propositions too (due to these mistakes). @Mario Carneiro Even on separate lines for both, it doesn't seem to display properly. (By the way, I find your Type Theory of Lean paper very helpful.)

Mario Carneiro (Feb 27 2022 at 13:57):

there is a space before the first triple-backtick

Thomas Brooks (Feb 27 2022 at 13:58):

Oops. Not my day for noticing trivial errors. Thanks


Last updated: Dec 20 2023 at 11:08 UTC