Zulip Chat Archive

Stream: new members

Topic: working with sigma-compact spaces - stuck at syntax


Michael Rothgang (Sep 09 2023 at 21:48):

Hi! Given a σ\sigma-compact topological space, I'm trying to extract the covering by compacts from it --- but am stuck. (I found the items in the documentation, but everything I tried was invalid syntax...) Pretty sure I'm just missing a trick. Advice would be welcome.

import Mathlib.MeasureTheory.Measure.Hausdorff
import Mathlib.Topology.MetricSpace.Lipschitz
lemma dummy { X Y : Type }
    [MetricSpace X] [SigmaCompactSpace X] [MetricSpace Y] { d :  } : True := by
  -- Choose a cover of X by compact sets K_i.
  -- Question: fill in the sorries: how to use these theorems?
  let cov :   Set X := sorry -- mumble mumble SigmaCompactSpace.compact_covering X
  have hcov :  (n : ), cov n = Set.univ := by sorry -- mumble mumble iUnion_compactCovering
  have hcompact :  n : , IsCompact (cov n) := by sorry -- mumble mumble isCompact_compactCovering
  sorry

Michael Rothgang (Sep 09 2023 at 21:49):

Meta: it seems LaTeX in the topic name doesn't work? Ok, point taken.

Anatole Dedecker (Sep 09 2023 at 21:49):

Yes you can't do LaTeX in the title

Anatole Dedecker (Sep 09 2023 at 21:52):

This works:

import Mathlib.MeasureTheory.Measure.Hausdorff
import Mathlib.Topology.MetricSpace.Lipschitz

lemma dummy { X Y : Type }
    [MetricSpace X] [SigmaCompactSpace X] [MetricSpace Y] { d :  } : True := by
  -- Choose a cover of X by compact sets K_i.
  -- Question: fill in the sorries: how to use these theorems?
  let cov :   Set X := compactCovering X
  have hcov :  (n : ), cov n = Set.univ := iUnion_compactCovering X
  have hcompact :  n : , IsCompact (cov n) := isCompact_compactCovering X
  sorry

Anatole Dedecker (Sep 09 2023 at 21:53):

For the first one, note that docs#compactCovering is (perhaps surprisingly) not called SigmaCompactSpace.compactCovering

Anatole Dedecker (Sep 09 2023 at 21:54):

For the second and third ones, you have to specify the right amount of explicit arguments (or you could also do by apply iUnion_compactCovering, which inserts arguments if needed)

Damiano Testa (Sep 09 2023 at 21:55):

There is also the .. syntax that includes the right number of trailing _.

Anatole Dedecker (Sep 09 2023 at 21:56):

Oh that's a nice trick, I did not know about that

Anatole Dedecker (Sep 09 2023 at 21:57):

Michael, do you know the distinction between tactic mode and term mode? I'm asking since you mentioned syntax errors, and by the look of your code I was wondering wether you were trying to mix the two

Michael Rothgang (Sep 09 2023 at 22:32):

Anatole Dedecker said:

Michael, do you know the distinction between tactic mode and term mode? I'm asking since you mentioned syntax errors, and by the look of your code I was wondering wether you were trying to mix the two

I do! I know sorry can act both as a proof term and as a tactic. :-)

Michael Rothgang (Sep 09 2023 at 22:34):

Anatole Dedecker said:

For the first one, note that docs#compactCovering is (perhaps surprisingly) not called SigmaCompactSpace.compactCovering

Thanks, that helps. I guess I was confused by the description in the docstring: "The sequence can be extracted using topological_space.compact_covering." I interpreted, guessing, this as some expression X.compact_covering - I presume that was a typo instead and should read TopologicalSpace.compactCovering instead?

Ruben Van de Velde (Sep 09 2023 at 22:37):

That sounds like an accidental leftover from lean 3; can you link to the place where you read that?

Kevin Buzzard (Sep 09 2023 at 22:40):

This also looks wrong -- topological_space is Lean 3 speak.

Patrick Massot (Sep 09 2023 at 22:41):

Docstrings mentioning declaration are tricky. They were easy to miss while porting.

Anatole Dedecker (Sep 09 2023 at 22:48):

Fixed in #7065

Anatole Dedecker (Sep 09 2023 at 22:52):

"The sequence can be extracted using topological_space.compact_covering." I interpreted, guessing, this as some expression X.compact_covering - I presume that was a typo instead and should read TopologicalSpace.compactCovering instead?

Not quite: the right name is just compactCovering with no namespace (and it wasn't in a namespace in Lean3 either, so the docstring was already wrong). Besides, not all lemmas in a namespace can be used with dot notation, sometimes it's just a matter of organizing lemmas. So you wouldn't have been able to do X.compactCovering anyways. Note that dot notation is a very handy feature but it's never necessary, so if you are fighting syntax errors you should try referring to lemmas by their full name and not use dot notation.

Michael Rothgang (Sep 09 2023 at 22:57):

Thanks for the advice, I'll keep that in mind.


Last updated: Dec 20 2023 at 11:08 UTC