Zulip Chat Archive

Stream: mathlib4

Topic: Governing philosophy/guidelines about what to include?


Kent Van Vels (Jan 04 2025 at 19:42):

I am interested to know if I would be welcome to submit a few (almost trivial) propositions to Mathlib.

As an exercise, I tried to find as many propositions equivalent to ABA \subseteq B. I came up with ten of them. Some of these are in Mathlib, but most aren't. I have written and proved the equivalent theorems in the context of a BooleanAlgebra.

Here is what I mean:

import Mathlib.Order.BooleanAlgebra
import Mathlib.Data.Set.Basic

variable {X: Type*}

section boolalg
variable [BooleanAlgebra X]

--already in mathlib
theorem my_sdiff_eq_bot_iff (A B : X) : A \ B =   A  B :=
  sdiff_eq_bot_iff

theorem my_sdiff_le_bot_iff (A B : X) : A \ B    A  B := by
  simp only [le_bot_iff, sdiff_eq_bot_iff]

@[simp]
theorem my_inf_compl_eq_bot_iff (A B : X) : A  B =   A  B := by
  rw [sdiff_eq]
  exact sdiff_eq_bot_iff

--no need for simp
theorem my_inf_compl_le_bot_iff (A B : X) : A  B    A  B := by
  simp only [le_bot_iff, my_inf_compl_eq_bot_iff]

@[simp]
theorem my_compl_inf_eq_bot_iff (A B : X) : A  B =   B  A := by
  rw [inf_comm]
  exact my_inf_compl_eq_bot_iff B A

theorem compl_inf_le_bot_iff (A B : X) : A  B    B  A := by
  simp only [le_bot_iff, my_compl_inf_eq_bot_iff]

@[simp]
theorem my_sup_compl_eq_top_iff (A B : X) : A  B =   B  A:= by
  rw [compl_inj_iff]
  simp only [compl_sup, compl_compl, compl_top, my_compl_inf_eq_bot_iff]

@[simp]
theorem my_compl_sup_eq_top_iff (A B : X) : A  B =   A  B := by
  rw [sup_comm]
  exact my_sup_compl_eq_top_iff B A

theorem my_top_le_sup_compl_iff (A B : X) :   A  B  B  A := by
  simp only [top_le_iff, my_sup_compl_eq_top_iff]

theorem my_top_le_compl_sup_iff (A B : X) :   A  B  A  B := by
  simp only [top_le_iff, my_compl_sup_eq_top_iff]

end boolalg

--already in mathlib
@[simp]
theorem diff_eq_empty (A B : Set X) : A \ B =   A  B := by
  exact Set.diff_eq_empty


theorem diff_subset_empty (A B : Set X) : A \ B    A  B := by
  simp only [Set.subset_empty_iff, Set.diff_eq_empty]

@[simp]
theorem union_compl_eq_empty_iff (A B : Set X) : A  B =   A  B :=
  my_inf_compl_eq_bot_iff A B

theorem union_compl_subset_empty_iff (A B : Set X) : A  B    A  B := by
  simp only [Set.subset_empty_iff, union_compl_eq_empty_iff]

@[simp]
theorem compl_union_eq_emtpy_iff (A B : Set X) : A  B =   B  A :=
  my_compl_inf_eq_bot_iff A B

theorem compl_union_subset_empty_iff (A B : Set X) : A  B    B  A := by
  simp only [Set.subset_empty_iff, compl_union_eq_emtpy_iff]

@[simp]
theorem union_compl_eq_univ_iff(A B : Set X) : A  B = Set.univ  B  A :=
  my_sup_compl_eq_top_iff A B

@[simp]
theorem compl_union_eq_univ_iff (A B : Set X) : A  B = Set.univ  A  B :=
  my_compl_sup_eq_top_iff A B

theorem univ_subset_union_compl_iff (A B : Set X) : Set.univ  A  B  B  A := by
  simp only [Set.univ_subset_iff, union_compl_eq_univ_iff]

theorem univ_subset_compl_union_iff (A B : Set X) : Set.univ  A  B  A  B := by
  simp only [Set.univ_subset_iff, compl_union_eq_univ_iff]

Any recommendations are appreciated. I, of course, would remove the "my_" prefix on the boolean algebra theorems. And I would change everything I could into a "term-wise" proof, instead of a tactic based proof.

Kent Van Vels (Jan 04 2025 at 19:49):

I also had BCACB^\mathrm{C} \subseteq A^\mathrm{C}, but if I remember correctly that is in mathlib in both places.

Edward van de Meent (Jan 04 2025 at 19:50):

I don't think there is any need for changing these to be term-wise? I'd say these proofs are all short enough...

Kent Van Vels (Jan 04 2025 at 19:52):

Is there an issue with term-wise proofs being faster in some way? I think I remember reading that.

Edward van de Meent (Jan 04 2025 at 20:08):

They are, but for these proofs (particularly when they use simp only rather than plain simp) I don't think there is such a large difference

Kent Van Vels (Jan 04 2025 at 20:11):

Is simp only about as slow (fast) as simp with?

Kyle Miller (Jan 04 2025 at 21:11):

I think "simp with" is a typo for "simp only", unless there's some new tactic I don't know about.

Kyle Miller (Jan 04 2025 at 21:12):

I'd say, unless you can tell that the tactic proof is slow, don't worry about creating a term proof.

There's not even a guarantee that term proofs are faster than tactic proofs.

Kyle Miller (Jan 04 2025 at 21:13):

There's guidance to not use simp only if simp will do, if the simp closes the goal (and if simp isn't slow). This is for reasons of maintainability.

Yaël Dillies (Jan 04 2025 at 21:14):

(You'll be forgiven for being unaware of the guidance. It was formally recording in the contributing guidelines only today)

Eric Wieser (Jan 05 2025 at 02:34):

Regarding the lemmas with expressions of the form _ ⊓ _ ≤ ⊥ or _ ⊓ _ = ⊥; Mathlib prefers to spell these as Disjoint _ _, which cuts down on the number of ways to spell the same thing

Eric Wieser (Jan 05 2025 at 02:34):

Similarly for _ ⊔ _ and as docs#Codisjoint

Kent Van Vels (Jan 05 2025 at 02:52):

@Eric Wieser, please check my understanding.

You are saying that we can use disjoint in weaker structure (A type with a partial order imposed on it and not necessarily something with inf and sup defined (a lattice structure)), so we want the lemmas defined on a partial Order and not necessarily on a lattice structure. Or at least have the more specialized theorems inherit from the more-general ones.

Eric Wieser (Jan 05 2025 at 03:01):

I think my comments is more that it's better to pick one spelling (the most general) and write nn lemmas translating it to equivalent concepts, than to write all n(n+1)2\frac{n(n+1)}{2} lemmas translating every concept to every other

Kent Van Vels (Jan 05 2025 at 03:13):

Ah, Ok. That makes sense.

Are there guidelines on what lemmata belong in mathlib? I would be happy to contribute this, but I don't want to waste my or anyone else's time if these aren't useful.


Last updated: May 02 2025 at 03:31 UTC