Zulip Chat Archive

Stream: new members

Topic: Confusion about MeasureSpace type inference


Matthew Ho (Feb 07 2026 at 11:35):

Hi, apologies if the answer to this question is very obvious.

So I tried creating a MeasureSpace, and then tried to create a product of iid measures by creating (Fin n → Ω). I was confused by this, because I didn't specify a joint measure, but it seems that this is a MeasureSpace, and from the below my understanding is that Lean found MeasureSpace.pi and constructed it by taking the product measure.

import Mathlib.MeasureTheory.Measure.Map
import Mathlib.Probability.Kernel.CondDistrib

open MeasureTheory

variable {Ω : Type*}
  [MeasureSpace Ω]

variable (n : )
#synth MeasureSpace (Fin n  Ω)

How would I have determined that this would have been the default joint measure? (I suppose from a math perspective this is the only measure that makes sense to use without any more information, but I was surprised that there was even was a default.)

Thanks!

Sébastien Gouëzel (Feb 07 2026 at 11:44):

If you look at the output of your #synth command in the infoview, it tells you that the instance it uses is MeasureSpace.pi. So you can have a look at what this does (for instance by doing #check MeasureSpace.pi and following the symbol)

Matthew Ho (Feb 07 2026 at 11:50):

Ah, ok, thanks for the help! Stylistically, is it generally better to explicitly specify that I am using MeasureSpace.pi, or is it preferable to allow Lean to infer that this is the right instance to use and not state it?

Sébastien Gouëzel (Feb 07 2026 at 12:27):

By design, instances are things that Lean will fetch for you automatically. So you should never specify one yourself by hand.

Matthew Ho (Feb 07 2026 at 12:41):

Thanks very much!


Last updated: Feb 28 2026 at 14:05 UTC