Zulip Chat Archive

Stream: mathlib4

Topic: Lambda notation for bundled morphisms


Tomas Skrivan (Feb 15 2024 at 17:03):

Now that fun_prop is in mathlib it would be worth considering adopting lambda notation for bundled morphisms e.g. fun x =>L[ℝ] x + 3•x. When we get fun_prop compiled my hope is that the additional overhead of reproving function property would be minimal.

fun_prop can compute derivatives via HasFDerivAt, consider this example:

#check ((by fun_prop (disch:=assumption)) : (@HasFDerivAt  _ _ _ _ _ _ _ (fun x :  => (x+3)*(x*x + 1)⁻¹) _ a))

which results in

(_ : HasFDerivAt (fun y => (y + 3) * (y * y + 1)⁻¹)
  ((a + 3)   ContinuousLinearMap.comp (-((ContinuousLinearMap.mulLeftRight  ) (a * a + 1)⁻¹) (a * a + 1)⁻¹)
    (a  ContinuousLinearMap.id   + a  ContinuousLinearMap.id  ) +  (a * a + 1)⁻¹  ContinuousLinearMap.id  )  a)

using lambda notation for bundled morphisms this would become

(_ : HasFDerivAt (fun y => (y + 3) * (y * y + 1)⁻¹)
     (fun dx =>L[] (((a + 3)  (-(a  dx + a  dx) * (a * a + 1)⁻¹ * (a * a + 1)⁻¹)  +  (a * a + 1)⁻¹  dx)
     a)

I'm curious in people's opinion if this should be pursuit or not. The #2202 would be quite relevant for this, but likely a lot of work.

Geoffrey Irving (Feb 15 2024 at 19:34):

That lambda notation is quite nice. Currently I solve this with a huge number of abbreviation defs, which is way messier.

Tomas Skrivan (Feb 15 2024 at 19:48):

Do you end up with something like APL :) ? Point free notation is nice until it isn't.

Geoffrey Irving (Feb 15 2024 at 20:21):

No, it’s not really point free: https://github.com/girving/ray/blob/48d737369e856f925aa050a317d10ae95726804a/Ray/AnalyticManifold/Inverse.lean#L139

Geoffrey Irving (Feb 15 2024 at 20:22):

Just naming all the intermediate linear maps.

Geoffrey Irving (Feb 15 2024 at 20:23):

I mean, it’s not point-free if you consider “dx” a “point”.

Eric Wieser (Feb 16 2024 at 00:44):

@Geoffrey Irving, are you aware of ∘L notation for composition?

Eric Wieser (Feb 16 2024 at 00:46):

@Tomas Skrivan: is there any hope of this working for bi- or tri-linear maps, perhaps with nested binders?

Tomas Skrivan (Feb 16 2024 at 00:55):

I definitely had it at some point, you could write

fun (x y : K) =>L[K] x * y  :  K L[K] K L[K] K

Tomas Skrivan (Feb 16 2024 at 00:58):

I think it boils down to providing this theorem

@[fun_prop]
theorem clm_mk' (f : X  Y  Z) (hf : Continuous (fun (x,y) => f x y)) (hf₁ :  y, IsLinearMap (f · y)) (hf₁ :  x, IsLinearMap (f x ·)) :
    IsContinuousLinearMap R (fun x => fun y =>L[K] f x y) := sorry

Tomas Skrivan (Feb 16 2024 at 01:07):

On notation side I just used expandExplicitBinders

Patrick Massot (Feb 16 2024 at 03:28):

This looks promising. It only needs to use to become usable.

Tomas Skrivan (Feb 16 2024 at 03:28):

No problem :)

Geoffrey Irving (Feb 16 2024 at 07:16):

Eric Wieser said:

Geoffrey Irving, are you aware of ∘L notation for composition?

I was not! Thank you!


Last updated: May 02 2025 at 03:31 UTC