Skip to content

Commit b79cbba

Browse files
committed
feat(Order): maximal chains are preserved under order isomorphisms (#19471)
From LeanCamCombi
1 parent adcc9a1 commit b79cbba

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

Mathlib/Order/Chain.lean

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ def SuperChain (s t : Set α) : Prop :=
5252
def IsMaxChain (s : Set α) : Prop :=
5353
IsChain r s ∧ ∀ ⦃t⦄, IsChain r t → s ⊆ t → s = t
5454

55-
variable {r} {c c₁ c₂ s t : Set α} {a x y : α}
55+
variable {r} {c c₁ c₂ s t : Set α} {a b x y : α}
5656

57-
theorem isChain_empty : IsChain r ∅ :=
58-
Set.pairwise_empty _
57+
@[simp] lemma IsChain.empty : IsChain r ∅ := pairwise_empty _
58+
@[simp] lemma IsChain.singleton : IsChain r {a} := pairwise_singleton ..
59+
60+
@[deprecated (since := "2024-11-25")] alias isChain_empty := IsChain.empty
5961

6062
theorem Set.Subsingleton.isChain (hs : s.Subsingleton) : IsChain r s :=
6163
hs.pairwise _
@@ -78,6 +80,9 @@ protected theorem IsChain.insert (hs : IsChain r s) (ha : ∀ b ∈ s, a ≠ b
7880
IsChain r (insert a s) :=
7981
hs.insert_of_symmetric (fun _ _ => Or.symm) ha
8082

83+
lemma IsChain.pair (h : r a b) : IsChain r {a, b} :=
84+
IsChain.singleton.insert fun _ hb _ ↦ .inl <| (eq_of_mem_singleton hb).symm.recOn ‹_›
85+
8186
theorem isChain_univ_iff : IsChain r (univ : Set α) ↔ IsTrichotomous α r := by
8287
refine ⟨fun h => ⟨fun a b => ?_⟩, fun h => @isChain_of_trichotomous _ _ h univ⟩
8388
rw [or_left_comm, or_iff_not_imp_left]
@@ -136,6 +141,14 @@ theorem IsMaxChain.bot_mem [LE α] [OrderBot α] (h : IsMaxChain (· ≤ ·) s)
136141
theorem IsMaxChain.top_mem [LE α] [OrderTop α] (h : IsMaxChain (· ≤ ·) s) : ⊤ ∈ s :=
137142
(h.2 (h.1.insert fun _ _ _ => Or.inr le_top) <| subset_insert _ _).symm ▸ mem_insert _ _
138143

144+
lemma IsMaxChain.image {s : β → β → Prop} (e : r ≃r s) {c : Set α} (hc : IsMaxChain r c) :
145+
IsMaxChain s (e '' c) where
146+
left := hc.isChain.image _ _ _ fun _ _ ↦ by exact e.map_rel_iff.2
147+
right t ht hf := by
148+
rw [← e.coe_fn_toEquiv, ← e.toEquiv.eq_preimage_iff_image_eq, preimage_equiv_eq_image_symm]
149+
exact hc.2 (ht.image _ _ _ fun _ _ ↦ by exact e.symm.map_rel_iff.2)
150+
((e.toEquiv.subset_symm_image _ _).2 hf)
151+
139152
open Classical in
140153
/-- Given a set `s`, if there exists a chain `t` strictly including `s`, then `SuccChain s`
141154
is one of these chains. Otherwise it is `s`. -/
@@ -302,11 +315,17 @@ theorem top_mem [OrderTop α] (s : Flag α) : (⊤ : α) ∈ s :=
302315
theorem bot_mem [OrderBot α] (s : Flag α) : (⊥ : α) ∈ s :=
303316
s.maxChain.bot_mem
304317

318+
/-- Reinterpret a maximal chain as a flag. -/
319+
def ofIsMaxChain (c : Set α) (hc : IsMaxChain (· ≤ ·) c) : Flag α := ⟨c, hc.isChain, hc.2
320+
321+
@[simp, norm_cast]
322+
lemma coe_ofIsMaxChain (c : Set α) (hc) : ofIsMaxChain c hc = c := rfl
323+
305324
end LE
306325

307326
section Preorder
308327

309-
variable [Preorder α] {a b : α}
328+
variable [Preorder α] [Preorder β] {a b : α} {s : Flag α}
310329

311330
protected theorem le_or_le (s : Flag α) (ha : a ∈ s) (hb : b ∈ s) : a ≤ b ∨ b ≤ a :=
312331
s.chain_le.total ha hb
@@ -320,6 +339,24 @@ instance [OrderBot α] (s : Flag α) : OrderBot s :=
320339
instance [BoundedOrder α] (s : Flag α) : BoundedOrder s :=
321340
Subtype.boundedOrder s.bot_mem s.top_mem
322341

342+
lemma mem_iff_forall_le_or_ge : a ∈ s ↔ ∀ ⦃b⦄, b ∈ s → a ≤ b ∨ b ≤ a :=
343+
fun ha b => s.le_or_le ha, fun hb =>
344+
of_not_not fun ha =>
345+
Set.ne_insert_of_not_mem _ ‹_› <|
346+
s.maxChain.2 (s.chain_le.insert fun c hc _ => hb hc) <| Set.subset_insert _ _⟩
347+
348+
/-- Flags are preserved under order isomorphisms. -/
349+
def map (e : α ≃o β) : Flag α ≃ Flag β
350+
where
351+
toFun s := ofIsMaxChain _ (s.maxChain.image e)
352+
invFun s := ofIsMaxChain _ (s.maxChain.image e.symm)
353+
left_inv s := ext <| e.symm_image_image s
354+
right_inv s := ext <| e.image_symm_image s
355+
356+
@[simp, norm_cast] lemma coe_map (e : α ≃o β) (s : Flag α) : ↑(map e s) = e '' s := rfl
357+
358+
@[simp] lemma symm_map (e : α ≃o β) : (map e).symm = map e.symm := rfl
359+
323360
end Preorder
324361

325362
section PartialOrder

0 commit comments

Comments
 (0)