Zulip Chat Archive

Stream: mathlib4

Topic: How much tfae


Aaron Liu (May 02 2025 at 15:00):

What's a reasonable amount of lemmas to have for a TFAE? I'm assuming 17 is too many. Which ones should I keep?

import Mathlib.Topology.Coherent
import Mathlib.Topology.Specialization

theorem alexandrovDiscrete_tfae {X : Type*} [tX : TopologicalSpace X] :
    [
      AlexandrovDiscrete X,
       (S : Set (Set X)), ( s  S, IsOpen s)  IsOpen (⋂₀ S),
       (S : Set (Set X)), ( s  S, IsClosed s)  IsClosed (⋃₀ S),
       (x : X) (S : Set (Set X)), ( s  S, s  nhds x)  ⋂₀ S  nhds x,
       (x : X), (nhds x).ker  nhds x,
       (x : X), IsOpen (exterior {x}),
       (s : Set X), IsOpen (exterior s),
      tX = @Topology.upperSet X (specializationPreorder X),
       (p : Preorder X), tX = @Topology.upperSet X p,
       (p : Preorder X), tX = @Topology.lowerSet X p,
       (S : Set (Set X)), interior (⋂₀ S) =  s  S, interior s,
       (S : Set (Set X)), closure (⋃₀ S) =  s  S, closure s,
       (x : X) (S : Set X), x  closure S   (f : Finset X), f.toSet  S  x  closure f,
       (x : X) (S : Set X), x  closure S   y  S, y  x,
       (s : Set X), IsOpen s   (x y : X), x  y  y  s  x  s,
      @Topology.IsCoherentWith X tX (setOf Set.Finite),
       (s : Set X), IsOpen s   (f : Finset X), IsOpen (() ⁻¹' s : Set f)
    ].TFAE := by
  -- proof omitted
  sorry

Ruben Van de Velde (May 02 2025 at 15:26):

Why is it too many?

Eric Wieser (May 02 2025 at 15:29):

Hot take: you should not use a TFAE here at all

Eric Wieser (May 02 2025 at 15:29):

This should be a series of lemmas of the form alexandrovDiscrete_iff_foo

Eric Wieser (May 02 2025 at 15:30):

(you can use a private tfae internally if it helps you set up the API, but it's not a good interface for referring to the result later)

Junyan Xu (May 02 2025 at 15:31):

Not sure it should be private, it's nice to have it show up in the docs (like it would appear in books)
The tfae tactics are definitely very useful in proving TFAEs.

Junyan Xu (May 02 2025 at 15:32):

I have an issue with putting TFAE at the end; wouldn't that be TAAE instead? If you don't want the List. you can open List (TFAE).

Aaron Liu (May 02 2025 at 15:49):

Eric Wieser said:

Hot take: you should not use a TFAE here at all

It's so I can prove the result without pain, eg. I have a loop 1 → 15 → 8 → 14 → 17 → 2 ↔ 1, so it's easier to get the iff by having the TFAE.

Eric Wieser (May 02 2025 at 15:55):

RIght, that's what I mean by "internally if it helps set things up"

Ruben Van de Velde (May 02 2025 at 15:55):

I think it's worth having, but probably also to have iffs for each with the preferred spelling (which is probably AlexandrovDiscrete X)

Eric Wieser (May 02 2025 at 15:55):

But only put the things in it that actually help, the goal is not to try and make the tfae exhaustive, as that's what the API is for

Aaron Liu (May 02 2025 at 15:58):

Eric Wieser said:

But only put the things in it that actually help, the goal is not to try and make the tfae exhaustive, as that's what the API is for

How do I know what helps?

Yakov Pechersky (May 02 2025 at 17:36):

Make the TFAE be 1 → 15 → 8 → 14 → 17 → 2 ↔ 1, expose 15 ↔ 1, 8 ↔ 1, 14 ↔ 1, 17 ↔ 1, 2 ↔ 1 as separate lemmas, use those separate lemmas for the remainder of the statements you have in your list.

Aaron Liu (May 02 2025 at 17:41):

ok let me collect all my tfae lemmas here so you can see why I don't know which ones are "necessary"

  • 1 ↔ 2
  • 8 → 9
  • 1 → 15
  • 1 → 11
  • 1 → 12
  • 1 → 3
  • 9 ↔ 10
  • 9 → 2
  • 7 → 6
  • 2 → 7
  • 3 → 2
  • 6 → 5
  • 17 → 2
  • 16 → 17
  • 17 → 16
  • 15 → 8
  • 11 → 2
  • 12 → 11
  • 4 → 5
  • 5 → 2
  • 2 → 4
  • 8 → 14
  • 13 ↔ 14
  • 14 → 17

Bolton Bailey (May 02 2025 at 17:43):

Screenshot 2025-05-02 at 10.43.07 AM.png Here is a flowchart if that helps

Aaron Liu (May 02 2025 at 17:43):

Bolton Bailey said:

Screenshot 2025-05-02 at 10.43.07 AM.png

neat

Aaron Liu (May 02 2025 at 17:45):

so to me it's still not very clear which ones are the main results

Aaron Liu (May 02 2025 at 17:46):

and it looks like I can delete 1 → 2 and 1 → 11, making my proof 1 line shorter (it's 200 lines long)

Eric Wieser (May 02 2025 at 18:24):

I'd perhaps suggest making the 1,2,3 loop (since 1 is the canonical spelling) with TFAE, then adding the two API lemmas, then doing a TFAE for the remainder of the graph with those edged contracted.

Eric Wieser (May 02 2025 at 18:25):

10, 13, and 16 could be dropped from it entirely

Aaron Liu (May 02 2025 at 19:08):

I'm thinking I'll just put the tfae in and then add a bunch of alexandrovDiscrete_iff_foo lemmas right after

Andrew Yang (May 02 2025 at 22:02):

I claim that TFAEs, while hard to apply and should definitely have the iff lemmas succeeding it, is a nice way to present the results and is good for discoverability and thus should be kept.

Aaron Liu (May 02 2025 at 22:07):

btw, where should this go? In file#Topology/AlexandrovDiscrete, or in a new file?

Eric Wieser (May 02 2025 at 22:08):

If some of the proofs need more machinery than others, this might be good evidence not to put everything in a TFAE

Eric Wieser (May 02 2025 at 22:11):

Andrew Yang said:

I claim that TFAEs, while hard to apply and should definitely have the iff lemmas succeeding it, is a nice way to present the results and is good for discoverability and thus should be kept.

I'd argue the discoverability mechanism here is @loogle AlexandrovDiscrete _ \iff _

Aaron Liu (May 02 2025 at 22:11):

The problem is that Topology.upperSet, used in the statement, is defined in a later file.

Eric Wieser (May 02 2025 at 22:12):

Then you should definitely prove the 1-2-3 loop separately, in an earlier file

Andrew Yang (May 02 2025 at 22:20):

I don't think it is reasonable to assume that an external tool which requires internet access and requests to online servers should be the main discoverability mechanism.

Eric Wieser (May 02 2025 at 22:22):

Loogle can be used offline, just like the docs can

Eric Wieser (May 02 2025 at 22:22):

And frankly a grep would be equally effective here

Eric Wieser (May 02 2025 at 22:23):

(which is also what you'd do to find the TFAE, but there the grep is more complicated)

Andrew Yang (May 02 2025 at 22:27):

But a bunch of iffs scattered in different places each perhaps with different side conditions that you need to check one by one is less straightforward to users (at least to me) compared to say two big lists of tfaes where one has one side condition and one has the other.

Andrew Yang (May 02 2025 at 22:27):

Eric Wieser said:

Loogle can be used offline, just like the docs can

And (perhaps off topic but) how do I do this?

Eric Wieser (May 02 2025 at 22:29):

I think the reality of mathlib is that it's not wise or even possible to put all the Iffs that you could possibly care about in once place

Eric Wieser (May 02 2025 at 22:30):

(I suggest a new thread for the loogle question)

Andrew Yang (May 02 2025 at 22:36):

Eric Wieser said:

I think the reality of mathlib is that it's not wise or even possible to put all the Iffs that you could possibly care about in once place

So this is why you put a tfae at the end to point to all the iff lemmas proved somewhere in the library.

Yaël Dillies (May 02 2025 at 22:37):

But then the file this TFAE lives in is unimportable, since all its constituent parts have fewer dependencies

Eric Wieser (May 02 2025 at 22:39):

"at the end" here has to mean "at the end of the import (sub)graph" not "at the end of the file"

Eric Wieser (May 02 2025 at 22:39):

At which point, what makes it discoverable?

Andrew Yang (May 02 2025 at 22:40):

As in you don't need to remember all the iff lemmas scattered around the library and you can just remember one declaration and consult that when necessary.

Aaron Liu (May 02 2025 at 23:05):

So what should I do with this proof?

Eric Wieser (May 02 2025 at 23:49):

My vote would be split it

Jireh Loreaux (May 03 2025 at 00:01):

@Thomas Murrills not sure if that extension is still on your radar, but if so, this seems like a good test case.

Aaron Liu (May 03 2025 at 00:20):

Eric Wieser said:

My vote would be split it

What should I split it into?

Thomas Murrills (May 03 2025 at 00:23):

Jireh Loreaux said:

Thomas Murrills not sure if that extension is still on your radar, but if so, this seems like a good test case.

I haven’t worked on it lately, but it still is on my radar! I’ve been lurking in this thread and thinking the same thing… :grinning_face_with_smiling_eyes:

Eric Wieser (May 03 2025 at 04:06):

Aaron Liu said:

Eric Wieser said:

My vote would be split it

What should I split it into?

Put the 1-2-3 cycle (and anything else that fits) into the existing file, and everything else into a new file with heavier imports.


Last updated: Dec 20 2025 at 21:32 UTC