Zulip Chat Archive

Stream: new members

Topic: ofENat


Niclas Kupper (Nov 08 2023 at 17:45):

I am trying to cast a variable of type ℝ≥0∞ to type ℕ∞, but the right coercion does not seem to exist. Am I missing something? For more context I want to create a point measure:

structure PointMeasure (α : Type*) [MeasurableSpace α] extends Measure α where
  measureEnatOf : Set α  
  coeMeasureEnatOf :  s, measureOf s = ENNReal.ofENat (measureEnatOf s)

but there is no ofENat

Notification Bot (Nov 08 2023 at 17:51):

A message was moved here from #new members > Showing group operation is closed on a subset. by Eric Wieser.

Eric Wieser (Nov 08 2023 at 17:51):

Can you use ofNNReal?

Niclas Kupper (Nov 08 2023 at 17:54):

Thanks for moving the message! ofNNReal also does not seem to exist.

Eric Wieser (Nov 08 2023 at 18:07):

~It's called docs#ENNReal.some, but should probably be renamed~ Edit: now it exists, docs#ENNReal.ofNNReal

Eric Wieser (Nov 08 2023 at 18:08):

Can you make your question a #mwe by adding imports?

Niclas Kupper (Nov 08 2023 at 19:05):

This also doesn't work :( ENNReal.some is from ℝ≥0 to ℝ≥0∞. I need from ℕ∞ to ℝ≥0∞.

Niclas Kupper (Nov 08 2023 at 19:08):

There is a workaround by handling the infinity case seperately, but it's kinda ugly.

Eric Wieser (Nov 08 2023 at 19:42):

Ah you're right, I wasn't paying attention

Yakov Pechersky (Nov 08 2023 at 19:45):

WithTop.map (fun n : Nat => (n : NNReal))

?

Eric Wieser (Nov 08 2023 at 19:50):

That would work as an implementation, but is going to have defeq issues unles you wrap it in an API

Eric Wieser (Nov 08 2023 at 20:00):

Eric Wieser said:

It's called docs#ENNReal.some, but should probably be renamed

#8276

Niclas Kupper (Nov 09 2023 at 10:47):

I am now having a very similar issue. How Can I map a function of type Set \alpha -> \nat to Set \alpha -> \enat? I have already tried using WithTop.map or WithTop.some, but could not get those to work. For context:

structure PointMeasure (α : Type*) [MeasurableSpace α] extends Measure α where
  measureEnatOf : Set α  
  coeMeasureEnatOf :  s, measureOf s = WithTop.map (fun n :  => (n : 0)) (measureEnatOf s)

structure FinitePointMeasure (α : Type*) [MeasurableSpace α] extends Measure α where
  measureNatOf : Set α  
  coeMeasureNatOf :  s, measureOf s = (fun n :  => (n : 0)) (measureNatOf s)

lemma FinitePointMeasure_is_PointMeasure {α : Type*} [MeasurableSpace α]
  (μ : FinitePointMeasure α) : PointMeasure α :=
  {
    toOuterMeasure := μ.toOuterMeasure
    m_iUnion := μ.m_iUnion
    trimmed := μ.trimmed
    measureEnatOf := ???
  }

Eric Wieser (Nov 09 2023 at 10:56):

Can you make that a #mwe?

Yakov Pechersky (Nov 09 2023 at 11:45):

That's not a lemma, should be a def, I think. Because measures are data. measureEnatOf s := mu.measureNatOf s
That lets the Nat to ENat coercion take care of it

Yakov Pechersky (Nov 09 2023 at 11:45):

Haven't tested it

Yakov Pechersky (Nov 09 2023 at 11:46):

Also, (\u) \comp mu.measureNatOf could work, for pointfree style

Niclas Kupper (Nov 09 2023 at 14:55):

I got it now, or, at least Lean4 is happy. I guess its not clear yet if these are the best definitions:

structure PointMeasure (α : Type*) [MeasurableSpace α] extends Measure α where
  measureEnatOf : Set α  
  coeMeasureEnatOf :  s, measureOf s = WithTop.map (fun n :  => (n : 0)) (measureEnatOf s)

structure FinitePointMeasure (α : Type*) [MeasurableSpace α] extends Measure α where
  measureNatOf : Set α  
  coeMeasureNatOf :  s, measureOf s = (fun n :  => (n : 0)) (measureNatOf s)

lemma FinitePointMeasure_is_PointMeasure {α : Type*} [MeasurableSpace α]
  (μ : FinitePointMeasure α) : PointMeasure α :=
  {
    toOuterMeasure := μ.toOuterMeasure
    m_iUnion := μ.m_iUnion
    trimmed := μ.trimmed
    measureEnatOf :=  ()  μ.measureNatOf
    coeMeasureEnatOf := by
      intro s
      rw [μ.coeMeasureNatOf]
      rfl
  }

Eric Wieser (Nov 09 2023 at 15:04):

Sorry to sound like a stuck record, but please make this a #mwe!

Eric Wieser (Nov 09 2023 at 15:04):

It's still missing imports and open commands


Last updated: Dec 20 2023 at 11:08 UTC