The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V04. Order and lattices

Mathlib.Order.WellFounded

81 declarations and 9 deprecated aliases. Mathlib docs · Source

Well-founded relations

A relation is well-founded if it can be used for induction: for each x, (∀ y, r y x → P y) → P x implies P x. Well-founded relations can be used for induction and recursion, including construction of fixed points in the space of dependent functions Π x : α, β x.

The predicate WellFounded is defined in the core library. In this file we prove some extra lemmas and provide a few new definitions: WellFounded.min, Function.argmin, and an induction principle WellFounded.induction_bot.

theorem WellFounded.min.congr_simp E1 #

∀ {α : Type u_1} {r r_1 : α → α → Prop} (e_r : r = r_1) (H : WellFounded r) (s s_1 : Set α) (e_s : s = s_1)
  (h : s.Nonempty), H.min s h = ⋯.min s_1 ⋯

theorem acc_def E0 #

∀ {α : Sort u_1} {r : α → α → Prop} {a : α}, Acc r a ↔ ∀ (b : α), r b a → Acc r b

theorem exists_not_acc_lt_of_not_acc E1 #

∀ {α : Sort u_1} {a : α} {r : α → α → Prop}, ¬Acc r a → ∃ b, ¬Acc r b ∧ r b a

theorem not_acc_iff_exists_descending_chain E1 #

∀ {α : Sort u_1} {r : α → α → Prop} {x : α}, ¬Acc r x ↔ ∃ f, f 0 = x ∧ ∀ (n : ℕ), r (f (n + 1)) (f n)

theorem acc_iff_isEmpty_descending_chain E1 #

∀ {α : Sort u_1} {r : α → α → Prop} {x : α}, Acc r x ↔ IsEmpty { f // f 0 = x ∧ ∀ (n : ℕ), r (f (n + 1)) (f n) }

theorem wellFounded_iff_isEmpty_descending_chain E1 #

∀ {α : Sort u_1} {r : α → α → Prop}, WellFounded r ↔ IsEmpty { f // ∀ (n : ℕ), r (f (n + 1)) (f n) }

A relation is well-founded iff it doesn't have any infinite descending chain.

See RelEmbedding.wellFounded_iff_isEmpty for a version in terms of relation embeddings.

theorem WellFounded.asymm E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded r → Std.Asymm r

theorem WellFounded.irrefl E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded r → Std.Irrefl r

instance WellFounded.instAsymmRel_mathlib E0 #

∀ {α : Type u_1} [inst : WellFoundedRelation α], Std.Asymm WellFoundedRelation.rel

theorem WellFounded.mono E1 #

∀ {α : Type u_1} {r r' : α → α → Prop}, WellFounded r → (∀ (a b : α), r' a b → r a b) → WellFounded r'

theorem WellFounded.onFun E1 #

∀ {α : Sort u_4} {β : Sort u_5} {r : β → β → Prop} {f : α → β}, WellFounded r → WellFounded (Function.onFun r f)

instance WellFounded.instOnFun E0 #

∀ {α : Type u_1} {β : Type u_2} (r : β → β → Prop) (f : α → β) [H : WellFounded r], WellFounded (Function.onFun r f)

theorem Function.Injective.isWellOrder E1 #

∀ {α : Type u_1} {β : Type u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [IsWellOrder β r], IsWellOrder α (Function.onFun r f)

theorem WellFounded.of_map E1 #

∀ {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {f : α → β}, WellFounded (Relation.Map r f f) → WellFounded r

theorem Function.Injective.wellFounded_map_iff E0 #

∀ {α : Type u_1} {β : Type u_2} {r : α → α → Prop} {f : α → β},
  Function.Injective f → (WellFounded (Relation.Map r f f) ↔ WellFounded r)

theorem WellFounded.has_min E1 #

∀ {α : Type u_4} {r : α → α → Prop}, WellFounded r → ∀ (s : Set α), s.Nonempty → ∃ a ∈ s, ∀ x ∈ s, ¬r x a

If r is a well-founded relation, then any nonempty set has a minimal element with respect to r.

theorem WellFounded.not_rightTotal E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded r → ∀ [Nonempty α], ¬Relator.RightTotal r

theorem WellFounded.not_leftTotal E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded (Function.swap r) → ∀ [Nonempty α], ¬Relator.LeftTotal r

def WellFounded.min E1 #

{α : Type u_1} → {r : α → α → Prop} → WellFounded r → (s : Set α) → s.Nonempty → α

A minimal element of a nonempty set in a well-founded order.

If you're working with a nonempty linear order, consider defining a ConditionallyCompleteLinearOrderBot instance via WellFoundedLT.conditionallyCompleteLinearOrderBot and using Inf instead.

abbrev WellFoundedLT.min E1 #

{α : Type u_1} → [inst : LT α] → [WellFoundedLT α] → (s : Set α) → s.Nonempty → α

A minimal element of a nonempty set of a type with a well-founded <.

abbrev WellFoundedGT.max E1 #

{α : Type u_1} → [inst : LT α] → [WellFoundedGT α] → (s : Set α) → s.Nonempty → α

A maximal element of a nonempty set of a type with a well-founded >.

theorem WellFounded.min_mem E1 #

∀ {α : Type u_1} {r : α → α → Prop} (H : WellFounded r) (s : Set α) (h : s.Nonempty), H.min s h ∈ s

theorem WellFounded.prop_min E1 #

∀ {α : Type u_1} {r : α → α → Prop} (H : WellFounded r) {p : α → Prop} (h : ∃ a, p a), p (H.min {a | p a} h)

theorem WellFounded.not_lt_min E1 #

∀ {α : Type u_1} {r : α → α → Prop} (H : WellFounded r) (s : Set α) {x : α} (hx : x ∈ s), ¬r x (H.min s ⋯)

theorem WellFounded.min_eq_of_forall_not_lt E1 #

∀ {α : Type u_1} {r : α → α → Prop} [Std.Trichotomous r] (wf : WellFounded r) {s : Set α} {m : α} (hms : m ∈ s),
  (∀ x ∈ s, ¬r x m) → wf.min s ⋯ = m

The minimal element of a trichotomous well-founded order is unique

theorem WellFounded.notMem_of_lt_min E1 #

∀ {α : Type u_1} {r : α → α → Prop} {wf : WellFounded r} {s : Set α} {hs : s.Nonempty} {x : α},
  r x (wf.min s hs) → x ∉ s

theorem WellFounded.mem_of_lt_min_compl E0 #

∀ {α : Type u_1} {r : α → α → Prop} {wf : WellFounded r} {s : Set α} {hs : sᶜ.Nonempty} {x : α},
  r x (wf.min sᶜ hs) → x ∈ s

theorem WellFounded.wellFounded_iff_has_min E1 #

∀ {α : Type u_1} {r : α → α → Prop}, WellFounded r ↔ ∀ (s : Set α), s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m

theorem WellFounded.wellFoundedLT_iff_exists_minimal E1 #

∀ {α : Type u_1} [inst : Preorder α], WellFoundedLT α ↔ ∀ (s : Set α), s.Nonempty → ∃ m, Minimal (fun x ↦ x ∈ s) m

theorem WellFounded.wellFoundedGT_iff_exists_maximal E1 #

∀ {α : Type u_1} [inst : Preorder α], WellFoundedGT α ↔ ∀ (s : Set α), s.Nonempty → ∃ m, Maximal (fun x ↦ x ∈ s) m

theorem WellFoundedGT.exists_maximal E1 #

∀ {α : Type u_1} [inst : Preorder α], WellFoundedGT α → ∀ (s : Set α), s.Nonempty → ∃ m, Maximal (fun x ↦ x ∈ s) m

Alias of the forward direction of WellFounded.wellFoundedGT_iff_exists_maximal.

theorem WellFoundedLT.exists_minimal E1 #

∀ {α : Type u_1} [inst : Preorder α], WellFoundedLT α → ∀ (s : Set α), s.Nonempty → ∃ m, Minimal (fun x ↦ x ∈ s) m

Alias of the forward direction of WellFounded.wellFoundedLT_iff_exists_minimal.

theorem WellFounded.maximal_wellFounded_lt_max E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : WellFoundedGT α] {s : Set α} (h : s.Nonempty),
  Maximal (fun x ↦ x ∈ s) (⋯.min s h)

theorem WellFounded.minimal_wellFounded_lt_min E1 #

∀ {α : Type u_1} [inst : Preorder α] [inst_1 : WellFoundedLT α] {s : Set α} (h : s.Nonempty),
  Minimal (fun x ↦ x ∈ s) (⋯.min s h)

theorem WellFounded.isWellOrder_iff_exists_not_lt_and_eq_or_gt E1 #

∀ {α : Type u_1} {r : α → α → Prop},
  IsWellOrder α r ↔ ∀ (s : Set α), s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m ∧ (m = x ∨ r m x)

theorem WellFounded.min_image E1 #

∀ {α : Type u_1} {β : Type u_2} {r : β → β → Prop} [Std.Trichotomous r] (wf : WellFounded r) (f : α → β) {s : Set α}
  (hne : s.Nonempty), wf.min (f '' s) ⋯ = f (⋯.min s hne)

The minimum of f '' s is f applied to the minimum of s.

theorem WellFounded.not_rel_apply_succ E1 #

∀ {α : Type u_1} {r : α → α → Prop} [h : WellFounded r] (f : ℕ → α), ∃ n, ¬r (f (n + 1)) (f n)

theorem WellFoundedGT.le_max E1 #

∀ {β : Type u_2} [inst : LinearOrder β] [inst_1 : WellFoundedGT β] {x : β} {s : Set β} (hx : x ∈ s),
  x ≤ WellFoundedGT.max s ⋯

theorem WellFoundedLT.min_le E1 #

∀ {β : Type u_2} [inst : LinearOrder β] [inst_1 : WellFoundedLT β] {x : β} {s : Set β} (hx : x ∈ s),
  WellFoundedLT.min s ⋯ ≤ x

theorem Set.range_injOn_strictMono_of_wellFoundedLT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedLT β],
  Set.InjOn Set.range {f | StrictMono f}

theorem Set.range_injOn_strictMono_of_wellFoundedGT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedGT β],
  Set.InjOn Set.range {f | StrictMono f}

theorem Set.range_injOn_strictAnti_of_wellFoundedLT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedLT β],
  Set.InjOn Set.range {f | StrictAnti f}

theorem Set.range_injOn_strictAnti_of_wellFoundedGT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedGT β],
  Set.InjOn Set.range {f | StrictAnti f}

theorem StrictMono.range_inj_of_wellFoundedGT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedGT β] {f g : β → γ},
  StrictMono f → StrictMono g → (Set.range f = Set.range g ↔ f = g)

theorem StrictMono.range_inj_of_wellFoundedLT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedLT β] {f g : β → γ},
  StrictMono f → StrictMono g → (Set.range f = Set.range g ↔ f = g)

theorem StrictAnti.range_inj_of_wellFoundedGT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedGT β] {f g : β → γ},
  StrictAnti f → StrictAnti g → (Set.range f = Set.range g ↔ f = g)

theorem StrictAnti.range_inj_of_wellFoundedLT E1 #

∀ {β : Type u_2} {γ : Type u_3} [inst : LinearOrder β] [inst_1 : Preorder γ] [WellFoundedLT β] {f g : β → γ},
  StrictAnti f → StrictAnti g → (Set.range f = Set.range g ↔ f = g)

theorem StrictMono.id_le E1 #

∀ {β : Type u_2} [inst : LinearOrder β] [WellFoundedLT β] {f : β → β}, StrictMono f → id ≤ f

A strictly monotone function f on a well-order satisfies x ≤ f x for all x.

theorem StrictMono.le_id E1 #

∀ {β : Type u_2} [inst : LinearOrder β] [WellFoundedGT β] {f : β → β}, StrictMono f → f ≤ id

A strictly monotone function f on a co-well-order satisfies f x ≤ x for all x.

theorem StrictMono.le_apply E0 #

∀ {β : Type u_2} [inst : LinearOrder β] [WellFoundedLT β] {f : β → β}, StrictMono f → ∀ {x : β}, x ≤ f x

theorem StrictMono.apply_le E1 #

∀ {β : Type u_2} [inst : LinearOrder β] [WellFoundedGT β] {f : β → β}, StrictMono f → ∀ {x : β}, f x ≤ x

theorem StrictMono.isCoinitial_range_of_wellFoundedGT E1 #

∀ {β : Type u_2} [inst : LinearOrder β] {f : β → β} [WellFoundedGT β], StrictMono f → IsCoinitial (Set.range f)

theorem StrictMono.isCofinal_range_of_wellFoundedLT E1 #

∀ {β : Type u_2} [inst : LinearOrder β] {f : β → β} [WellFoundedLT β], StrictMono f → IsCofinal (Set.range f)

theorem StrictMono.not_bddAbove_range_of_wellFoundedLT E1 #

∀ {β : Type u_2} [inst : LinearOrder β] {f : β → β} [WellFoundedLT β] [NoMaxOrder β],
  StrictMono f → ¬BddAbove (Set.range f)

theorem StrictMono.not_bddBelow_range_of_wellFoundedGT E1 #

∀ {β : Type u_2} [inst : LinearOrder β] {f : β → β} [WellFoundedGT β] [NoMinOrder β],
  StrictMono f → ¬BddBelow (Set.range f)

def Function.argmin E1 #

{α : Type u_1} → {β : Type u_2} → (α → β) → [inst : LT β] → [WellFoundedLT β] → [Nonempty α] → α

Given a function f : α → β where β carries a well-founded <, this is an element of α whose image under f is minimal in the sense of Function.not_lt_argmin.

See also Set.Finite.exists_minimalFor and related lemmas for the case when α is finite.

def Function.argmax E1 #

{α : Type u_1} → {β : Type u_2} → (α → β) → [inst : LT β] → [WellFoundedGT β] → [Nonempty α] → α

Given a function f : α → β where β carries a well-founded >, this is an element of α whose image under f is maximal in the sense of Function.not_argmax_lt.

See also Set.Finite.exists_maximalFor and related lemmas for the case when α is finite.

theorem Function.not_argmax_lt E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedGT β] [inst_2 : Nonempty α] (a : α),
  ¬f (Function.argmax f) < f a

theorem Function.not_lt_argmin E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedLT β] [inst_2 : Nonempty α] (a : α),
  ¬f a < f (Function.argmin f)

def Function.argminOn E1 #

{α : Type u_1} → {β : Type u_2} → (α → β) → [inst : LT β] → [WellFoundedLT β] → (s : Set α) → s.Nonempty → α

Given a function f : α → β where β carries a well-founded <, and a non-empty subset s of α, this is an element of s whose image under f is minimal in the sense of Function.not_lt_argminOn.

See also Set.Finite.exists_minimalFor and related lemmas for the case when α or s is finite.

TODO Consider removing this definition in favour of exists_minimalFor_of_wellFoundedLT.

def Function.argmaxOn E1 #

{α : Type u_1} → {β : Type u_2} → (α → β) → [inst : LT β] → [WellFoundedGT β] → (s : Set α) → s.Nonempty → α

Given a function f : α → β where β carries a well-founded >, and a non-empty subset s of α, this is an element of s whose image under f is maximal in the sense of Function.not_argmaxOn_lt.

See also Set.Finite.exists_maximalFor and related lemmas for the case when α or s is finite.

theorem Function.argmaxOn_mem E0 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedGT β] (s : Set α) (hs : s.Nonempty),
  Function.argmaxOn f s hs ∈ s

theorem Function.argminOn_mem E0 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedLT β] (s : Set α) (hs : s.Nonempty),
  Function.argminOn f s hs ∈ s

theorem Function.not_argmaxOn_lt E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedGT β] (s : Set α) {a : α} (ha : a ∈ s),
  ¬f (Function.argmaxOn f s ⋯) < f a

theorem Function.not_lt_argminOn E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LT β] [inst_1 : WellFoundedLT β] (s : Set α) {a : α} (ha : a ∈ s),
  ¬f a < f (Function.argminOn f s ⋯)

theorem Function.le_argmax E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedGT β] (a : α)
  [inst_2 : Nonempty α], f a ≤ f (Function.argmax f)

theorem Function.argmin_le E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedLT β] (a : α)
  [inst_2 : Nonempty α], f (Function.argmin f) ≤ f a

theorem Function.minimalFor_argmin E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedLT β] [inst_2 : Nonempty α],
  MinimalFor (fun x ↦ True) f (Function.argmin f)

theorem Function.maximalFor_argmax E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedGT β] [inst_2 : Nonempty α],
  MaximalFor (fun x ↦ True) f (Function.argmax f)

theorem Function.le_argmaxOn E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedGT β] (s : Set α) {a : α}
  (ha : a ∈ s), f a ≤ f (Function.argmaxOn f s ⋯)

theorem Function.argminOn_le E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedLT β] (s : Set α) {a : α}
  (ha : a ∈ s), f (Function.argminOn f s ⋯) ≤ f a

theorem Function.maximalFor_argmaxOn E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedGT β] (s : Set α)
  (hs : s.Nonempty), MaximalFor (fun x ↦ x ∈ s) f (Function.argmaxOn f s hs)

theorem Function.minimalFor_argminOn E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) [inst : LinearOrder β] [inst_1 : WellFoundedLT β] (s : Set α)
  (hs : s.Nonempty), MinimalFor (fun x ↦ x ∈ s) f (Function.argminOn f s hs)

theorem Acc.induction_bot' E1 #

∀ {α : Sort u_4} {β : Sort u_5} {r : α → α → Prop} {a bot : α},
  Acc r a →
    ∀ {C : β → Prop} {f : α → β}, (∀ (b : α), f b ≠ f bot → C (f b) → ∃ c, r c b ∧ C (f c)) → C (f a) → C (f bot)

Let r be a relation on α, let f : α → β be a function, let C : β → Prop, and let bot : α. This induction principle shows that C (f bot) holds, given that

  • some a that is accessible by r satisfies C (f a), and
  • for each b such that f b ≠ f bot and C (f b) holds, there is c satisfying r c b and C (f c).

theorem Acc.induction_bot E1 #

∀ {α : Sort u_4} {r : α → α → Prop} {a bot : α},
  Acc r a → ∀ {C : α → Prop}, (∀ (b : α), b ≠ bot → C b → ∃ c, r c b ∧ C c) → C a → C bot

Let r be a relation on α, let C : α → Prop and let bot : α. This induction principle shows that C bot holds, given that

  • some a that is accessible by r satisfies C a, and
  • for each b ≠ bot such that C b holds, there is c satisfying r c b and C c.

theorem WellFounded.induction_bot' E1 #

∀ {α : Sort u_4} {β : Sort u_5} {r : α → α → Prop},
  WellFounded r →
    ∀ {a bot : α} {C : β → Prop} {f : α → β},
      (∀ (b : α), f b ≠ f bot → C (f b) → ∃ c, r c b ∧ C (f c)) → C (f a) → C (f bot)

Let r be a well-founded relation on α, let f : α → β be a function, let C : β → Prop, and let bot : α. This induction principle shows that C (f bot) holds, given that

  • some a satisfies C (f a), and
  • for each b such that f b ≠ f bot and C (f b) holds, there is c satisfying r c b and C (f c).

theorem WellFounded.induction_bot E1 #

∀ {α : Sort u_4} {r : α → α → Prop},
  WellFounded r → ∀ {a bot : α} {C : α → Prop}, (∀ (b : α), b ≠ bot → C b → ∃ c, r c b ∧ C c) → C a → C bot

Let r be a well-founded relation on α, let C : α → Prop, and let bot : α. This induction principle shows that C bot holds, given that

  • some a satisfies C a, and
  • for each b that satisfies C b, there is c satisfying r c b and C c.

The naming is inspired by the fact that when r is transitive, it follows that bot is the smallest element w.r.t. r that satisfies C.

def WellFoundedLT.toOrderBot E1 #

(α : Type u_4) → [inst : LinearOrder α] → [Nonempty α] → [h : WellFoundedLT α] → OrderBot α

A nonempty linear order with well-founded < has a bottom element.

def WellFoundedGT.toOrderTop E1 #

(α : Type u_4) → [inst : LinearOrder α] → [Nonempty α] → [h : WellFoundedGT α] → OrderTop α

A nonempty linear order with well-founded > has a top element.

instance instWellFoundedGTULift E0 #

∀ {α : Type u_1} [inst : LT α] [h : WellFoundedGT α], WellFoundedGT (ULift.{u_4, u_1} α)

instance instWellFoundedLTULift E0 #

∀ {α : Type u_1} [inst : LT α] [h : WellFoundedLT α], WellFoundedLT (ULift.{u_4, u_1} α)

Deprecated aliases

NameNew nameSince
Function.isMinimalFor_argminFunction.minimalFor_argmin2026-08-13
Function.isMinimalFor_argminOnFunction.minimalFor_argminOn2026-08-13
Set.range_injOn_strictAntiSet.range_injOn_strictAnti_of_wellFoundedGT2026-08-13
Set.range_injOn_strictMonoSet.range_injOn_strictMono_of_wellFoundedLT2026-08-13
StrictAnti.range_injStrictAnti.range_inj_of_wellFoundedGT2026-08-13
StrictMono.range_injStrictMono.range_inj_of_wellFoundedLT2026-08-13
WellFounded.lt_sup2026-09-14
WellFounded.min_leWellFoundedLT.min_le2026-08-16
WellFounded.sup2026-09-14