Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Finite.lean   Sprache: Lean

 

/-
Copyright (c) 2025 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/

module

public import Mathlib.Data.Set.Finite.Basic
public import Mathlib.Order.Minimal

import Mathlib.Order.Hom.Set

set_option doc.verso true
set_option doc.verso.suggestions false

/-!
# Finite preorders and finite sets in a preorder

This file shows that non-empty finite sets in a preorder have minimal/maximal elements, and
contrapositively that non-empty sets without minimal or maximal elements are infinite.

It also provides uniqueness results for order embeddings and order homomorphisms on finite linear
orders.
-/


public section

variable {ι α β : Type*}

namespace Finset
section IsTrans
variable [LE α] [IsTrans α LE.le] {s : Finset α} {a : α}

@[to_dual]
lemma exists_maximalFor (f : ι → α) (s : Finset ι) (hs : s.Nonempty) :
    ∃ i, MaximalFor (· ∈ s) f i := by
  induction hs using Finset.Nonempty.cons_induction with
  | singleton i => exact ⟨i, by simp⟩
  | @cons i s hi hs ih =>
    obtain ⟨j, hj⟩ := ih
    by_cases hji : f j ≤ f i
    · refine ⟨i, mem_cons_self .., ?_⟩
      simp only [mem_cons, forall_eq_or_imp, imp_self, true_and]
      exact fun k hk hik ↦ _root_.trans (hj.2 hk <| _root_.trans hji hik) hji
    · exact ⟨j, mem_cons_of_mem hj.1, by simpa [hji] using hj.2⟩

@[to_dual]
lemma exists_maximal (hs : s.Nonempty) : ∃ i, Maximal (· ∈ s) i := s.exists_maximalFor id hs

end IsTrans

section Preorder
variable [Preorder α] {s : Finset α} {a : α}

@[to_dual]
lemma exists_le_maximal (s : Finset α) (ha : a ∈ s) : ∃ b, a ≤ b ∧ Maximal (· ∈ s) b := by
  classical
  obtain ⟨b, hb, hab, hbmin⟩ : ∃ b ∈ s, a ≤ b ∧ _ := by
    simpa [Maximal, and_assoc] using {x ∈ s | a ≤ x}.exists_maximal ⟨a, mem_filter.2 ⟨ha, le_rfl⟩⟩
  exact ⟨b, hab, hb, fun c hc hbc ↦ hbmin hc (hab.trans hbc) hbc⟩

end Preorder
end Finset

namespace Set
section IsTrans
variable [LE α] [IsTrans α LE.le] {s : Set α} {a : α}

@[to_dual]
lemma Finite.exists_maximalFor (f : ι → α) (s : Set ι) (h : s.Finite) (hs : s.Nonempty) :
    ∃ i, MaximalFor (· ∈ s) f i := by
  lift s to Finset ι using h; exact s.exists_maximalFor f hs

@[to_dual]
lemma Finite.exists_maximal (h : s.Finite) (hs : s.Nonempty) : ∃ i, Maximal (· ∈ s) i :=
  h.exists_maximalFor id _ hs

/-- A version of `Finite.exists_maximalFor` with the (weaker) hypothesis that the image of `s`
is finite rather than `s` itself. -/

@[to_dual /- A version of `Finite.exists_minimalFor` with the (weaker) hypothesis that the image of
`s` is finite rather than `s` itself.-/
]
lemma Finite.exists_maximalFor' (f : ι → α) (s : Set ι) (h : (f '' s).Finite) (hs : s.Nonempty) :
    ∃ i, MaximalFor (· ∈ s) f i := by
  obtain ⟨_, ⟨a, ha, rfl⟩, hmax⟩ := Finite.exists_maximalFor id (f '' s) h (hs.image f)
  exact ⟨a, ha, fun a' ha' hf ↦ hmax (mem_image_of_mem f ha') hf⟩

end IsTrans

section Preorder
variable [Preorder α] {s : Set α} {a : α}

@[to_dual]
lemma Finite.exists_le_maximal (hs : s.Finite) (ha : a ∈ s) : ∃ b, a ≤ b ∧ Maximal (· ∈ s) b := by
  lift s to Finset α using hs; exact s.exists_le_maximal ha

variable [Nonempty α]

lemma infinite_of_forall_exists_gt (h : ∀ a, ∃ b ∈ s, a < b) : s.Infinite := by
  inhabit α
  let f (n : ℕ) : α := Nat.recOn n (h default).choose fun _ a ↦ (h a).choose
  have hf : ∀ n, f n ∈ s := by rintro (_ | _) <;> exact (h _).choose_spec.1
  exact infinite_of_injective_forall_mem
    (strictMono_nat_of_lt_succ fun n => (h _).choose_spec.2).injective hf

@[to_dual existing infinite_of_forall_exists_gt]
lemma infinite_of_forall_exists_lt (h : ∀ a, ∃ b ∈ s, b < a) : s.Infinite :=
  infinite_of_forall_exists_gt (α := αᵒᵈ) h

end Preorder

section PartialOrder
variable (α) [PartialOrder α]

@[to_dual]
lemma finite_isTop : {a : α | IsTop a}.Finite := (subsingleton_isTop α).finite

end PartialOrder

section LinearOrder
variable [LinearOrder α] {s : Set α} {t : Set β} {f : α → β}

lemma Infinite.exists_lt_map_eq_of_mapsTo (hs : s.Infinite) (hf : MapsTo f s t) (ht : t.Finite) :
    ∃ x ∈ s, ∃ y ∈ s, x < y ∧ f x = f y :=
  let ⟨x, hx, y, hy, hxy, hf⟩ := hs.exists_ne_map_eq_of_mapsTo hf ht
  hxy.lt_or_gt.elim (fun hxy => ⟨x, hx, y, hy, hxy, hf⟩) fun hyx => ⟨y, hy, x, hx, hyx, hf.symm⟩

lemma Finite.exists_lt_map_eq_of_forall_mem [Infinite α] (hf : ∀ a, f a ∈ t) (ht : t.Finite) :
    ∃ a b, a < b ∧ f a = f b := by
  rw [← mapsTo_univ_iff] at hf
  obtain ⟨a, -, b, -, h⟩ := infinite_univ.exists_lt_map_eq_of_mapsTo hf ht
  exact ⟨a, b, h⟩

/-- If the cofinality of a linear order is finite, it's at most one. -/
theorem Finite.exists_subsingleton_isCofinal {s : Set α} (hs : s.Finite) (hs' : IsCofinal s) :
    ∃ t : Set α, t.Subsingleton ∧ IsCofinal t := by
  obtain rfl | hn := s.eq_empty_or_nonempty
  · use ∅; simpa
  · obtain ⟨a, ha⟩ := hs.exists_maximal hn
    use {a}
    suffices IsTop a by simpa [IsCofinal]
    intro b
    obtain ⟨c, hc, hbc⟩ := hs' b
    exact hbc.trans (ha.le hc)

end LinearOrder
end Set

section Preorder
variable [Preorder α] [Finite α] {p : α → Prop} {a : α}

@[to_dual]
lemma Finite.exists_le_maximal (h : p a) : ∃ b, a ≤ b ∧ Maximal p b :=
  {x | p x}.toFinite.exists_le_maximal h

end Preorder

lemma OrderEmbedding.range_eq_iff
    {α β : Type*} [LinearOrder α] [PartialOrder β] [Finite α]
    {f g : α ↪o β} :
    Set.range f = Set.range g ↔ f = g := by
  refine ⟨fun h ↦ ?_, by rintro rfl; rfl⟩
  let ef := (f.strictMono.strictMonoOn .univ).orderIso
  let eg := (g.strictMono.strictMonoOn .univ).orderIso
  let i : f '' .univ ≃o g '' .univ :=
    { __ := Set.equivOfEq (by simpa using! h)
      map_rel_iff' := by rfl }
  have : (ef.trans i).trans eg.symm = .refl _ := by
    exact Subsingleton.elim _ _
  ext x
  simpa only [OrderIso.trans_apply, OrderIso.apply_symm_apply, OrderIso.refl_apply, Subtype.ext_iff]
    using! congr(eg ($this ⟨x, Set.mem_univ x⟩))

lemma OrderHom.range_eq_iff {α β : Type*} [LinearOrder α] [PartialOrder β]
    [Finite α] {f g : α →o β}
    (hf : Function.Injective f) (hg : Function.Injective g) :
    Set.range f = Set.range g ↔ f = g := by
  refine ⟨fun h ↦ ?_, by rintro rfl; rfl⟩
  ext : 2
  congrm $((OrderEmbedding.range_eq_iff
   (f := .ofStrictMono f (f.monotone.strictMono_of_injective hf))
   (g := .ofStrictMono g (g.monotone.strictMono_of_injective hg))).1 (by simpa)) _

lemma OrderHom.eq_id_of_injective {α : Type*} [LinearOrder α] [Finite α] (f : α →o α)
    (hf : Function.Injective f) :
    f = .id :=
  (range_eq_iff hf Function.injective_id).1 (by
    simpa [Set.range_eq_univ] using Finite.surjective_of_injective hf)

/-- A strictly monotone self-map of a finite linear order is the identity. -/
theorem StrictMono.eq_id {α : Type*} [LinearOrder α] [Finite α] {f : α → α}
    (hf : StrictMono f) : f = id :=
  le_antisymm hf.le_id hf.id_le

/-- A strictly monotone self-map of a finite linear order fixes every point. -/
theorem StrictMono.apply_eq {α : Type*} [LinearOrder α] [Finite α] {f : α → α}
    {x : α} (hf : StrictMono f) : f x = x :=
  congr($hf.eq_id x)

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,109
#Domains=862,992