Skip to content

Commit a9eda3d

Browse files
committed
feat: add characterisation of closed interval for locally-finite conditionally complete linear orders (#23910)
Co-authored-by: Michael Stoll <MichaelStollBayreuth@users.noreply.github.com> Co-authored-by: Kevin Buzzard <k.buzzard@imperial.ac.uk> Co-authored-by: Bhavik Mehta <bhavikmehta8@gmail.com> Co-authored-by: Oliver Nash <7734364+ocfnash@users.noreply.github.com>
1 parent bec8403 commit a9eda3d

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4671,6 +4671,7 @@ import Mathlib.Order.Interval.Set.LinearOrder
46714671
import Mathlib.Order.Interval.Set.Monotone
46724672
import Mathlib.Order.Interval.Set.OrdConnected
46734673
import Mathlib.Order.Interval.Set.OrdConnectedComponent
4674+
import Mathlib.Order.Interval.Set.OrdConnectedLinear
46744675
import Mathlib.Order.Interval.Set.OrderEmbedding
46754676
import Mathlib.Order.Interval.Set.OrderIso
46764677
import Mathlib.Order.Interval.Set.Pi
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/-
2+
Copyright (c) 2025 Oliver Nash. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Kevin Buzzard, Bhavik Mehta, Oliver Nash
5+
-/
6+
import Mathlib.Data.Fintype.Order
7+
import Mathlib.Data.Nat.Lattice
8+
import Mathlib.Data.Int.ConditionallyCompleteOrder
9+
import Mathlib.Data.Int.Interval
10+
import Mathlib.Data.Int.SuccPred
11+
12+
/-!
13+
# Order-connected subsets of linear orders
14+
15+
In this file we provide some results about order-connected subsets of linear orders, together with
16+
some convenience lemmas for characterising closed intervals in certain concrete types such as `ℤ`,
17+
`ℕ`, and `Fin n`.
18+
19+
## Main results:
20+
* `Set.ordConnected_iff_disjoint_Ioo_empty`: a characterisation of `Set.OrdConnected` for
21+
locally-finite linear orders.
22+
* `Set.Nonempty.ordConnected_iff_of_bdd`: a characterisation of closed intervals for locally-finite
23+
conditionally complete linear orders.
24+
* `Set.Nonempty.ordConnected_iff_of_bdd'`: a characterisation of closed intervals for
25+
locally-finite complete linear orders (convenient for `Fin n`).
26+
* `Set.Nonempty.eq_Icc_iff_nat`: characterisation of closed intervals for `ℕ`.
27+
* `Set.Nonempty.eq_Icc_iff_int`: characterisation of closed intervals for `ℤ`.
28+
-/
29+
30+
variable {α : Type*} {I : Set α}
31+
32+
lemma Set.Nonempty.ordConnected_iff_of_bdd
33+
[ConditionallyCompleteLinearOrder α] [LocallyFiniteOrder α]
34+
(h₀ : I.Nonempty) (h₁ : BddBelow I) (h₂ : BddAbove I) :
35+
I.OrdConnected ↔ I = Icc (sInf I) (sSup I) :=
36+
have h₄ : I.Finite := h₁.finite_of_bddAbove h₂
37+
fun _ ↦ le_antisymm (subset_Icc_csInf_csSup h₁ h₂)
38+
(I.Icc_subset (h₀.csInf_mem h₄) (h₀.csSup_mem h₄)), fun h₃ ↦ h₃ ▸ ordConnected_Icc⟩
39+
40+
/-- A version of `Set.Nonempty.ordConnected_iff_of_bdd` for complete linear orders, such as `Fin n`,
41+
in which the explicit boundedness hypotheses are not necessary. -/
42+
lemma Set.Nonempty.ordConnected_iff_of_bdd' [ConditionallyCompleteLinearOrder α]
43+
[OrderTop α] [OrderBot α] [LocallyFiniteOrder α]
44+
(h₀ : I.Nonempty) :
45+
I.OrdConnected ↔ I = Icc (sInf I) (sSup I) :=
46+
h₀.ordConnected_iff_of_bdd (OrderBot.bddBelow I) (OrderTop.bddAbove I)
47+
48+
/- TODO The `LocallyFiniteOrder` assumption here is probably too strong (e.g., it rules out `ℝ`
49+
for which this result holds). However at the time of writing it is not clear what weaker
50+
assumption(s) should replace it. -/
51+
lemma Set.ordConnected_iff_disjoint_Ioo_empty [LinearOrder α] [LocallyFiniteOrder α] :
52+
I.OrdConnected ↔ ∀ᵉ (x ∈ I) (y ∈ I), Disjoint (Ioo x y) I → Ioo x y = ∅ := by
53+
simp_rw [← Set.subset_compl_iff_disjoint_right]
54+
refine ⟨fun h' x hx y hy hxy ↦ ?_, fun h' ↦ ordConnected_of_Ioo fun x hx y hy hxy z hz ↦ ?_⟩
55+
· suffices ∀ z, x < z → y ≤ z by ext z; simpa using this z
56+
intro z hz
57+
suffices z ∉ Ioo x y by aesop
58+
exact fun contra ↦ hxy contra <| h'.out hx hy <| mem_Icc_of_Ioo contra
59+
· by_contra hz'
60+
obtain ⟨x', hx', hx''⟩ :=
61+
((finite_Icc x z).inter_of_right I).exists_le_maximal ⟨hx, le_refl _, hz.1.le⟩
62+
have hxz : x' < z := lt_of_le_of_ne hx''.1.2.2 (ne_of_mem_of_not_mem hx''.1.1 hz')
63+
obtain ⟨y', hy', hy''⟩ :=
64+
((finite_Icc z y).inter_of_right I).exists_minimal_le ⟨hy, hz.2.le, le_refl _⟩
65+
have hzy : z < y' := lt_of_le_of_ne' hy''.1.2.1 (ne_of_mem_of_not_mem hy''.1.1 hz')
66+
have h₃ : Ioc x' z ⊆ Iᶜ := fun t ht ht' ↦ hx''.not_gt (⟨ht', le_trans hx' ht.1.le, ht.2⟩) ht.1
67+
have h₄ : Ico z y' ⊆ Iᶜ := fun t ht ht' ↦ hy''.not_lt (⟨ht', ht.1, le_trans ht.2.le hy'⟩) ht.2
68+
have h₅ : Ioo x' y' ⊆ Iᶜ := by
69+
simp only [← Ioc_union_Ico_eq_Ioo hxz hzy, union_subset_iff, and_true, h₃, h₄]
70+
exact eq_empty_iff_forall_not_mem.1 (h' x' hx''.prop.1 y' hy''.prop.1 h₅) z ⟨hxz, hzy⟩
71+
72+
lemma Set.Nonempty.eq_Icc_iff_nat {I : Set ℕ}
73+
(h₀ : I.Nonempty) (h₂ : BddAbove I) :
74+
I = Icc (sInf I) (sSup I) ↔ ∀ᵉ (x ∈ I) (y ∈ I), Disjoint (Ioo x y) I → y ≤ x + 1 := by
75+
simp [← h₀.ordConnected_iff_of_bdd (OrderBot.bddBelow I) h₂, ordConnected_iff_disjoint_Ioo_empty]
76+
77+
lemma Set.Nonempty.eq_Icc_iff_int {I : Set ℤ}
78+
(h₀ : I.Nonempty) (h₁ : BddBelow I) (h₂ : BddAbove I) :
79+
I = Icc (sInf I) (sSup I) ↔ ∀ᵉ (x ∈ I) (y ∈ I), Disjoint (Ioo x y) I → y ≤ x + 1 := by
80+
simp [← h₀.ordConnected_iff_of_bdd h₁ h₂, ordConnected_iff_disjoint_Ioo_empty, Int.succ]

Mathlib/Order/SuccPred/Basic.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,15 @@ theorem Ico_succ_right_eq_insert (h : a ≤ b) : Ico a (succ b) = insert b (Ico
504504
theorem Ioo_succ_right_eq_insert (h : a < b) : Ioo a (succ b) = insert b (Ioo a b) :=
505505
Ioo_succ_right_eq_insert_of_not_isMax h <| not_isMax b
506506

507+
@[simp]
508+
theorem Ioo_eq_empty_iff_le_succ : Ioo a b = ∅ ↔ b ≤ succ a := by
509+
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
510+
· contrapose! h
511+
exact ⟨succ a, lt_succ_iff_not_isMax.mpr (not_isMax a), h⟩
512+
· ext x
513+
suffices a < x → b ≤ x by simpa
514+
exact fun hx ↦ le_of_lt_succ <| lt_of_le_of_lt h <| succ_strictMono hx
515+
507516
end NoMaxOrder
508517

509518
section OrderBot
@@ -880,6 +889,15 @@ theorem Ico_pred_right_eq_insert (h : a ≤ b) : Ioc (pred a) b = insert a (Ioc
880889
theorem Ioo_pred_right_eq_insert (h : a < b) : Ioo (pred a) b = insert a (Ioo a b) := by
881890
simp_rw [← Ioi_inter_Iio, Ioi_pred_eq_insert, insert_inter_of_mem (mem_Iio.2 h)]
882891

892+
@[simp]
893+
theorem Ioo_eq_empty_iff_pred_le : Ioo a b = ∅ ↔ pred b ≤ a := by
894+
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
895+
· contrapose! h
896+
exact ⟨pred b, h, pred_lt_iff_not_isMin.mpr (not_isMin b)⟩
897+
· ext x
898+
suffices a < x → b ≤ x by simpa
899+
exact fun hx ↦ le_of_pred_lt <| lt_of_le_of_lt h hx
900+
883901
end NoMinOrder
884902

885903
section OrderTop

0 commit comments

Comments
 (0)