Zulip Chat Archive

Stream: mathlib4

Topic: Measurability of entries of matrix and fun_prop


Fred Rajasekaran (Sep 16 2025 at 19:08):

I am trying add the fun_prop attribute to the following lemma:

@[fun_prop]
lemma measurable_entry {m n : } (X : Ω  Matrix (Fin m) (Fin n) α) (hX : Measurable X) :
 (i : Fin m) (j : Fin n), Measurable (fun ω  X ω i j) := by
  intros i j
  fun_prop

(the MeasurableSpace structure on Matrix (Fin m) (Fin n) α is the product one where α is a MeasurableSpace). However, I get an error Not a valid `fun_prop` theorem!. I believe it has to do with the ∀ (i : Fin m) (j : Fin n) part (correct me if I'm wrong please). What's the correct way to state this and still have a lemma with the fun_prop attribute that states that the entries are measurable functions?

Ruben Van de Velde (Sep 16 2025 at 19:12):

It would be helpful to make your code a #mwe

Michael Rothgang (Sep 16 2025 at 19:20):

A #mwe would be helpful: barring that, here's my guess how to rephrase your code:

@[fun_prop]
lemma measurable_entry {m n : } (X : Ω  Matrix (Fin m) (Fin n) α) (hX : Measurable X) (i : Fin m) (j : Fin n) :
Measurable (fun ω  X ω i j) := by
  fun_prop

Michael Rothgang (Sep 16 2025 at 19:20):

The mathlib style guide https://leanprover-community.github.io/contribute/style.html has a section "hypotheses left of colon", which tells you to do exactly this.

Michael Rothgang (Sep 16 2025 at 19:21):

If fun_prop can prove your goal, you need not (but still can) mark your lemma as fun_prop.

Eric Wieser (Sep 16 2025 at 20:42):

I would not expect fun_prop to prove this unless the lemma already exists

Etienne Marion (Sep 16 2025 at 20:43):

fun_prop does work, although the error is still here:

import Mathlib

variable (α Ω : Type*) [MeasurableSpace α] [MeasurableSpace Ω]

instance (m n : ) : MeasurableSpace (Matrix (Fin m) (Fin n) α) := inferInstanceAs <| MeasurableSpace <| (Fin m)  (Fin n)  α

@[fun_prop]
lemma measurable_entry {m n : } (X : Ω  Matrix (Fin m) (Fin n) α) (hX : Measurable X) (i : Fin m) (j : Fin n) :
    Measurable (fun ω  X ω i j) := by
  fun_prop

David Ledvinka (Sep 16 2025 at 21:18):

I believe this can't be a fun_prop lemma because fun_prop does not allow the head of a function body to be a free variable unless its in the form of one of the lambda theorems listed here. Its not really a problem here though since fun_prop can prove it (its just a composition of lambda theorems as show_term fun_prop reveals)

Tomas Skrivan (Sep 17 2025 at 19:52):

David Ledvinka said:

I believe this can't be a fun_prop lemma because fun_prop does not allow the head of a function body to be a free variable unless its in the form of one of the lambda theorems listed here. Its not really a problem here though since fun_prop can prove it (its just a composition of lambda theorems as show_term fun_prop reveals)

It is exactly as you say. fun_prop can figure out that the theorem is just a consequence of Measurable.comp' and measurable_pi_apply. Therefore there is not need to mark this theorem with fun_prop.

Tomas Skrivan (Sep 17 2025 at 20:03):

Just few thoughts on this. In a way, for A : Matrix m n R and i : m, j : n the expression A i j is defeq abuse. Similar, for x : WithLp 2 (Fin n → ℝ) and i : Fin n we could consider x i a defeq abuse.

If Matrix would be one field structure

structure Matrix (m n R : Type*) where
  data : m  n  R

then evaluation for A : Matrix m n R, i : m, j : n would be A.data i j and

lemma measurable_entry {m n : } (X : Ω  Matrix (Fin m) (Fin n) α) (hX : Measurable X) :
 (i : Fin m) (j : Fin n), Measurable (fun ω  (X ω).data i j) := ...

would be a valid fun_prop theorem as the head of the function body is Matrix.data.

Eric Wieser (Sep 18 2025 at 01:17):

I guess we could even call data row, and have a delaborator for A.row i j


Last updated: Dec 20 2025 at 21:32 UTC