Zulip Chat Archive

Stream: Is there code for X?

Topic: lambda body


Aaron Liu (May 19 2025 at 14:31):

Like docs#Lean.Expr.getForallBody but for lambda expressions (I'm not in MetaM)

Eric Wieser (May 19 2025 at 14:43):

if let .lam _ _ _ _ := e then _ else _?

Edward van de Meent (May 19 2025 at 14:53):

i have noticed that a bunch of these meta functions only have forall and let versions, but never lambda...

Edward van de Meent (May 19 2025 at 14:54):

depending on your usecase, there can be different ways around this.

Aaron Liu (May 19 2025 at 15:10):

Eric Wieser said:

if let .lam _ _ _ _ := e then _ else _?

If you have a fun a b => body this gives fun b => body but I want body

Kyle Miller (May 19 2025 at 15:24):

I think there used to be a function like that hanging around in Lean.Elab.Structure/StructInst, but it got refactored away. It's easy enough to make a custom one for your own metaprogram.

(Can I ask what you're wanting this for?)

Kyle Miller (May 19 2025 at 15:24):

Oh right, I saw another copy of this function recently, docs#Lean.Meta.AbstractNestedProofs.getLambdaBody

Kyle Miller (May 19 2025 at 15:25):

I'd imagine a PR moving this function into Lean.Expr wouldn't be unwelcome.


Last updated: Dec 20 2025 at 21:32 UTC