Zulip Chat Archive

Stream: Is there code for X?

Topic: Checking Expr equality


Adam Topaz (Oct 07 2024 at 14:29):

Do we have a variant of docs#Lean.Expr.equal that checks for equality of binder kinds (i.e. default vs implicit etc), but ignores equality of binder names?

Kyle Miller (Oct 07 2024 at 16:21):

Not that I know of, but you could at least normalize all binder names to, say, a, and then use Lean.Expr.equal.

Adam Topaz (Oct 07 2024 at 16:24):

Do we have any convenient way to normalize all names, or do I have to dig into the Expr manually?

Kyle Miller (Oct 07 2024 at 16:26):

I expect you'd have to dig (and also might want to use caching to make sure subexpressions are shared, in case that sort of performance consideration matters!)

Adam Topaz (Oct 07 2024 at 16:28):

Do you know of any code that does such caching for me to look at as an example?

Kyle Miller (Oct 07 2024 at 16:38):

If you use docs#Lean.Core.transform to do this renaming, it'll use caching automatically.

Adam Topaz (Oct 07 2024 at 16:39):

Awesome. Thanks Kyle!

Kyle Miller (Oct 07 2024 at 16:40):

You can use a post method for that, and you can return .continue with the updated expression (or .done, it doesn't matter for post)


Last updated: May 02 2025 at 03:31 UTC