Skip to content

Commit

Permalink
feat: missing WellFoundedLT instances (#5899)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
  • Loading branch information
semorrison and semorrison committed Jul 19, 2023
1 parent a9956b6 commit 1c8e790
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Mathlib/Data/DFinsupp/WellFounded.lean
Expand Up @@ -235,10 +235,10 @@ protected theorem DFinsupp.wellFoundedLT [∀ i, Zero (α i)] [∀ i, Preorder (
exact ⟨i, fun j hj ↦ Quot.sound (he j hj), hl⟩⟩
#align dfinsupp.well_founded_lt DFinsupp.wellFoundedLT

instance DFinsupp.well_founded_lt' [∀ i, CanonicallyOrderedAddMonoid (α i)]
instance DFinsupp.wellFoundedLT' [∀ i, CanonicallyOrderedAddMonoid (α i)]
[∀ i, WellFoundedLT (α i)] : WellFoundedLT (Π₀ i, α i) :=
DFinsupp.wellFoundedLT fun _i a => (zero_le a).not_lt
#align dfinsupp.well_founded_lt' DFinsupp.well_founded_lt'
#align dfinsupp.well_founded_lt' DFinsupp.wellFoundedLT'

instance Pi.wellFoundedLT [Finite ι] [∀ i, Preorder (α i)] [hw : ∀ i, WellFoundedLT (α i)] :
WellFoundedLT (∀ i, α i) :=
Expand All @@ -261,4 +261,3 @@ instance DFinsupp.wellFoundedLT_of_finite [Finite ι] [∀ i, Zero (α i)] [∀
have := Fintype.ofFinite ι
⟨InvImage.wf equivFunOnFintype Pi.wellFoundedLT.wf⟩
#align dfinsupp.well_founded_lt_of_finite DFinsupp.wellFoundedLT_of_finite

9 changes: 9 additions & 0 deletions Mathlib/Order/Hom/Basic.lean
Expand Up @@ -687,6 +687,15 @@ protected def dual : αᵒᵈ ↪o βᵒᵈ :=
⟨f.toEmbedding, f.map_rel_iff⟩
#align order_embedding.dual OrderEmbedding.dual

/-- A preorder which embeds into a well-founded preorder is itself well-founded. -/
protected theorem wellFoundedLT [WellFoundedLT β] : WellFoundedLT α where
wf := f.wellFounded IsWellFounded.wf

/-- A preorder which embeds into a preorder in which `(· > ·)` is well-founded
also has `(· > ·)` well-founded. -/
protected theorem wellFoundedGT [WellFoundedGT β] : WellFoundedGT α :=
@OrderEmbedding.wellFoundedLT αᵒᵈ _ _ _ f.dual _

/-- A version of `WithBot.map` for order embeddings. -/
@[simps (config := { fullyApplied := false })]
protected def withBotMap (f : α ↪o β) : WithBot α ↪o WithBot β :=
Expand Down
18 changes: 18 additions & 0 deletions Mathlib/Order/RelClasses.lean
Expand Up @@ -521,6 +521,24 @@ theorem Subrelation.isWellFounded (r : α → α → Prop) [IsWellFounded α r]
⟨h.wf IsWellFounded.wf⟩
#align subrelation.is_well_founded Subrelation.isWellFounded

instance Prod.wellFoundedLT [PartialOrder α] [WellFoundedLT α] [Preorder β] [WellFoundedLT β] :
WellFoundedLT (α × β) where
wf := by
refine @Subrelation.wf (α × β) (Prod.Lex (· < ·) (· < ·)) (· < ·) ?_ IsWellFounded.wf
rintro ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ w
simp only [Prod.mk_lt_mk] at w
rcases eq_or_ne a₁ a₂ with rfl | ha
· right
simpa using w
· left
rcases w with ⟨a_lt, _⟩ | ⟨a_le, _⟩
· assumption
· exact Ne.lt_of_le ha a_le

instance Prod.wellFoundedGT [PartialOrder α] [WellFoundedGT α] [Preorder β] [WellFoundedGT β] :
WellFoundedGT (α × β) :=
@Prod.wellFoundedLT αᵒᵈ βᵒᵈ _ _ _ _

namespace Set

/-- An unbounded or cofinal set. -/
Expand Down

0 comments on commit 1c8e790

Please sign in to comment.