Documentation

Mathlib.Order.Defs.Unbundled

Orders #

Defines classes for preorders, partial orders, and linear orders and proves some basic lemmas about them.

Unbundled classes #

@[deprecated emptyRelation (since := "2025-12-22")]
def EmptyRelation {α : Sort u} :
ααProp

An empty relation does not relate any elements.

Equations
    Instances For
      @[reducible, inline, deprecated Std.Irrefl (since := "2026-01-07")]
      abbrev IsIrrefl (α : Sort u_1) (r : ααProp) :

      IsIrrefl X r means the binary relation r on X is irreflexive (that is, r x x never holds).

      Equations
        Instances For
          @[reducible, inline, deprecated Std.Refl (since := "2026-01-08")]
          abbrev IsRefl (α : Sort u_1) (r : ααProp) :

          IsRefl X r means the binary relation r on X is reflexive.

          Equations
            Instances For
              @[reducible, inline, deprecated Std.Symm (since := "2025-12-26")]
              abbrev IsSymm (α : Sort u_1) (r : ααProp) :

              IsSymm X r means the binary relation r on X is symmetric.

              Equations
                Instances For
                  @[reducible, inline, deprecated Std.Asymm (since := "2026-01-03")]
                  abbrev IsAsymm (α : Sort u_1) (r : ααProp) :

                  IsAsymm X r means that the binary relation r on X is asymmetric, that is, r a b → ¬ r b a.

                  Equations
                    Instances For
                      @[reducible, inline, deprecated Std.Antisymm (since := "2026-01-06")]
                      abbrev IsAntisymm (α : Sort u_1) (r : ααProp) :

                      IsAntisymm X r means the binary relation r on X is antisymmetric.

                      Equations
                        Instances For
                          class IsTrans (α : Sort u_1) (r : ααProp) :

                          IsTrans X r means the binary relation r on X is transitive.

                          • trans (a b c : α) : r a br b cr a c
                          Instances
                            instance instTransOfIsTrans {α : Sort u_1} {r : ααProp} [IsTrans α r] :
                            Trans r r r
                            Equations
                              @[instance 100]
                              instance instIsTransOfTrans {α : Sort u_1} {r : ααProp} [Trans r r r] :
                              IsTrans α r
                              @[reducible, inline, deprecated Std.Total (since := "2026-01-09")]
                              abbrev IsTotal (α : Sort u_1) (r : ααProp) :

                              IsTotal X r means that the binary relation r on X is total, that is, that for any x y : X we have r x y or r y x.

                              Equations
                                Instances For
                                  class IsPreorder (α : Sort u_1) (r : ααProp) extends Std.Refl r, IsTrans α r :

                                  IsPreorder X r means that the binary relation r on X is a pre-order, that is, reflexive and transitive.

                                  • refl (a : α) : r a a
                                  • trans (a b c : α) : r a br b cr a c
                                  Instances
                                    class IsPartialOrder (α : Sort u_1) (r : ααProp) extends IsPreorder α r, Std.Antisymm r :

                                    IsPartialOrder X r means that the binary relation r on X is a partial order, that is, IsPreorder X r and Std.Antisymm r.

                                    • refl (a : α) : r a a
                                    • trans (a b c : α) : r a br b cr a c
                                    • antisymm (a b : α) : r a br b aa = b
                                    Instances
                                      class IsLinearOrder (α : Sort u_1) (r : ααProp) extends IsPartialOrder α r, Std.Total r :

                                      IsLinearOrder X r means that the binary relation r on X is a linear order, that is, IsPartialOrder X r and Std.Total r.

                                      • refl (a : α) : r a a
                                      • trans (a b c : α) : r a br b cr a c
                                      • antisymm (a b : α) : r a br b aa = b
                                      • total (a b : α) : r a b r b a
                                      Instances
                                        class IsEquiv (α : Sort u_1) (r : ααProp) extends IsPreorder α r, Std.Symm r :

                                        IsEquiv X r means that the binary relation r on X is an equivalence relation, that is, IsPreorder X r and Std.Symm r.

                                        • refl (a : α) : r a a
                                        • trans (a b c : α) : r a br b cr a c
                                        • symm (a b : α) : r a br b a
                                        Instances
                                          class IsStrictOrder (α : Sort u_1) (r : ααProp) extends Std.Irrefl r, IsTrans α r :

                                          IsStrictOrder X r means that the binary relation r on X is a strict order, that is, Std.Irrefl r and IsTrans X r.

                                          • irrefl (a : α) : ¬r a a
                                          • trans (a b c : α) : r a br b cr a c
                                          Instances
                                            class IsStrictWeakOrder (α : Sort u_1) (lt : ααProp) extends IsStrictOrder α lt :

                                            IsStrictWeakOrder X lt means that the binary relation lt on X is a strict weak order, that is, IsStrictOrder X lt and ¬lt a b ∧ ¬lt b a → ¬lt b c ∧ ¬lt c b → ¬lt a c ∧ ¬lt c a.

                                            • irrefl (a : α) : ¬lt a a
                                            • trans (a b c : α) : lt a blt b clt a c
                                            • incomp_trans (a b c : α) : ¬lt a b ¬lt b a¬lt b c ¬lt c b¬lt a c ¬lt c a
                                            Instances
                                              @[reducible, inline, deprecated Std.Trichotomous (since := "2026-01-24")]
                                              abbrev IsTrichotomous (α : Sort u_1) (lt : ααProp) :

                                              IsTrichotomous X lt means that the binary relation lt on X is trichotomous, that is, either lt a b or a = b or lt b a for any a and b.

                                              Equations
                                                Instances For
                                                  class IsStrictTotalOrder (α : Sort u_1) (lt : ααProp) extends Std.Trichotomous lt, IsStrictOrder α lt :

                                                  IsStrictTotalOrder X lt means that the binary relation lt on X is a strict total order, that is, Std.Trichotomous lt and IsStrictOrder X lt.

                                                  Instances
                                                    instance eq_isEquiv (α : Sort u_1) :
                                                    IsEquiv α fun (x1 x2 : α) => x1 = x2

                                                    Equality is an equivalence relation.

                                                    Iff is an equivalence relation.

                                                    theorem irrefl {α : Sort u_1} {r : ααProp} [Std.Irrefl r] (a : α) :
                                                    ¬r a a
                                                    theorem refl {α : Sort u_1} {r : ααProp} [Std.Refl r] (a : α) :
                                                    r a a
                                                    theorem trans {α : Sort u_1} {r : ααProp} {a b c : α} [IsTrans α r] :
                                                    r a br b cr a c
                                                    theorem symm {α : Sort u_1} {r : ααProp} {a b : α} [Std.Symm r] :
                                                    r a br b a
                                                    theorem antisymm {α : Sort u_1} {r : ααProp} {a b : α} [Std.Antisymm r] :
                                                    r a br b aa = b
                                                    theorem asymm {α : Sort u_1} {r : ααProp} {a b : α} [Std.Asymm r] :
                                                    r a b¬r b a
                                                    theorem trichotomous {α : Sort u_1} {r : ααProp} [Std.Trichotomous r] (a b : α) :
                                                    r a b a = b r b a
                                                    @[instance 90]
                                                    instance asymm_of_isTrans_of_irrefl {α : Sort u_1} {r : ααProp} [IsTrans α r] [Std.Irrefl r] :
                                                    instance Std.Irrefl.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Irrefl r] :
                                                    Irrefl fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Refl.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Refl r] :
                                                    Refl fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance IsTrans.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [IsTrans α r] :
                                                    IsTrans α fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Symm.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Symm r] :
                                                    Symm fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Antisymm.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Antisymm r] :
                                                    Antisymm fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Asymm.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Asymm r] :
                                                    Asymm fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Total.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Total r] :
                                                    Total fun (a b : α) => Decidable.decide (r a b) = true
                                                    instance Std.Trichotomous.decide {α : Sort u_1} {r : ααProp} [DecidableRel r] [Trichotomous r] :
                                                    Trichotomous fun (a b : α) => Decidable.decide (r a b) = true
                                                    @[elab_without_expected_type]
                                                    theorem irrefl_of {α : Sort u_1} (r : ααProp) [Std.Irrefl r] (a : α) :
                                                    ¬r a a
                                                    @[elab_without_expected_type]
                                                    theorem refl_of {α : Sort u_1} (r : ααProp) [Std.Refl r] (a : α) :
                                                    r a a
                                                    @[elab_without_expected_type]
                                                    theorem trans_of {α : Sort u_1} (r : ααProp) {a b c : α} [IsTrans α r] :
                                                    r a br b cr a c
                                                    @[elab_without_expected_type]
                                                    theorem symm_of {α : Sort u_1} (r : ααProp) {a b : α} [Std.Symm r] :
                                                    r a br b a
                                                    @[elab_without_expected_type]
                                                    theorem asymm_of {α : Sort u_1} (r : ααProp) {a b : α} [Std.Asymm r] :
                                                    r a b¬r b a
                                                    @[elab_without_expected_type]
                                                    theorem total_of {α : Sort u_1} (r : ααProp) [Std.Total r] (a b : α) :
                                                    r a b r b a
                                                    @[elab_without_expected_type]
                                                    theorem trichotomous_of {α : Sort u_1} (r : ααProp) [Std.Trichotomous r] (a b : α) :
                                                    r a b a = b r b a
                                                    def Reflexive {α : Sort u_1} (r : ααProp) :

                                                    Std.Refl as a definition, suitable for use in proofs.

                                                    Equations
                                                      Instances For
                                                        def Symmetric {α : Sort u_1} (r : ααProp) :

                                                        Std.Symm as a definition, suitable for use in proofs.

                                                        Equations
                                                          Instances For
                                                            def Transitive {α : Sort u_1} (r : ααProp) :

                                                            IsTrans as a definition, suitable for use in proofs.

                                                            Equations
                                                              Instances For
                                                                @[deprecated Std.Irrefl (since := "2026-02-12")]
                                                                def Irreflexive {α : Sort u_1} (r : ααProp) :

                                                                Std.Irrefl as a definition, suitable for use in proofs.

                                                                Equations
                                                                  Instances For
                                                                    @[deprecated Std.Antisymm (since := "2026-02-09")]
                                                                    def AntiSymmetric {α : Sort u_1} (r : ααProp) :

                                                                    Std.Antisymm as a definition, suitable for use in proofs.

                                                                    Equations
                                                                      Instances For
                                                                        @[deprecated Std.Total (since := "2026-02-10")]
                                                                        def Total {α : Sort u_1} (r : ααProp) :

                                                                        Std.Total as a definition, suitable for use in proofs.

                                                                        Equations
                                                                          Instances For
                                                                            theorem Equivalence.reflexive {α : Sort u_1} (r : ααProp) (h : Equivalence r) :
                                                                            theorem Equivalence.symmetric {α : Sort u_1} (r : ααProp) (h : Equivalence r) :
                                                                            theorem Equivalence.transitive {α : Sort u_1} (r : ααProp) (h : Equivalence r) :
                                                                            theorem InvImage.trans {α : Sort u_1} {β : Sort u_2} (r : ββProp) (f : αβ) (h : Transitive r) :
                                                                            theorem InvImage.irrefl {α : Sort u_1} {β : Sort u_2} (r : ββProp) (f : αβ) (h : Std.Irrefl r) :
                                                                            @[deprecated InvImage.irrefl (since := "2026-02-12")]
                                                                            theorem InvImage.irreflexive {α : Sort u_1} {β : Sort u_2} (r : ββProp) (f : αβ) (h : Std.Irrefl r) :

                                                                            Alias of InvImage.irrefl.

                                                                            Minimal and maximal #

                                                                            def Minimal {α : Type u_1} [LE α] (P : αProp) (x : α) :

                                                                            Minimal P x means that x is a minimal element satisfying P.

                                                                            Equations
                                                                              Instances For
                                                                                def Maximal {α : Type u_1} [LE α] (P : αProp) (x : α) :

                                                                                Maximal P x means that x is a maximal element satisfying P.

                                                                                Equations
                                                                                  Instances For
                                                                                    theorem Minimal.prop {α : Type u_1} [LE α] {P : αProp} {x : α} (h : Minimal P x) :
                                                                                    P x
                                                                                    theorem Maximal.prop {α : Type u_1} [LE α] {P : αProp} {x : α} (h : Maximal P x) :
                                                                                    P x
                                                                                    theorem Minimal.le_of_le {α : Type u_1} [LE α] {P : αProp} {x y : α} (h : Minimal P x) (hy : P y) (hle : y x) :
                                                                                    x y
                                                                                    theorem Maximal.le_of_ge {α : Type u_1} [LE α] {P : αProp} {x y : α} (h : Maximal P x) (hy : P y) (hle : x y) :
                                                                                    y x
                                                                                    def MinimalFor {ι : Sort u_1} {α : Type u_2} [LE α] (P : ιProp) (f : ια) (i : ι) :

                                                                                    MinimalFor P f i means that f i is minimal over all i satisfying P.

                                                                                    Equations
                                                                                      Instances For
                                                                                        def MaximalFor {ι : Sort u_1} {α : Type u_2} [LE α] (P : ιProp) (f : ια) (i : ι) :

                                                                                        MaximalFor P f i means that f i is maximal over all i satisfying P.

                                                                                        Equations
                                                                                          Instances For
                                                                                            theorem MinimalFor.prop {ι : Sort u_1} {α : Type u_2} [LE α] {P : ιProp} {f : ια} {i : ι} (h : MinimalFor P f i) :
                                                                                            P i
                                                                                            theorem MaximalFor.prop {ι : Sort u_1} {α : Type u_2} [LE α] {P : ιProp} {f : ια} {i : ι} (h : MaximalFor P f i) :
                                                                                            P i
                                                                                            theorem MinimalFor.le_of_le {ι : Sort u_1} {α : Type u_2} [LE α] {P : ιProp} {f : ια} {i j : ι} (h : MinimalFor P f i) (hj : P j) (hji : f j f i) :
                                                                                            f i f j
                                                                                            theorem MaximalFor.le_of_le {ι : Sort u_1} {α : Type u_2} [LE α] {P : ιProp} {f : ια} {i j : ι} (h : MaximalFor P f i) (hj : P j) (hji : f i f j) :
                                                                                            f j f i

                                                                                            Upper and lower sets #

                                                                                            def IsUpperSet {α : Type u_1} [LE α] (s : Set α) :

                                                                                            An upper set in an order α is a set such that any element greater than one of its members is also a member. Also called up-set, upward-closed set.

                                                                                            Equations
                                                                                              Instances For
                                                                                                def IsLowerSet {α : Type u_1} [LE α] (s : Set α) :

                                                                                                A lower set in an order α is a set such that any element less than one of its members is also a member. Also called down-set, downward-closed set.

                                                                                                Equations
                                                                                                  Instances For
                                                                                                    structure UpperSet (α : Type u_1) [LE α] :
                                                                                                    Type u_1

                                                                                                    An upper set in an order α is a set such that any element greater than one of its members is also a member. Also called up-set, upward-closed set.

                                                                                                    Instances For
                                                                                                      structure LowerSet (α : Type u_1) [LE α] :
                                                                                                      Type u_1

                                                                                                      A lower set in an order α is a set such that any element less than one of its members is also a member. Also called down-set, downward-closed set.

                                                                                                      Instances For
                                                                                                        def IsRelUpperSet {α : Type u_1} [LE α] (s : Set α) (P : αProp) :

                                                                                                        An upper set relative to a predicate P is a set such that all elements satisfy P and any element greater than one of its members and satisfying P is also a member.

                                                                                                        Equations
                                                                                                          Instances For
                                                                                                            def IsRelLowerSet {α : Type u_1} [LE α] (s : Set α) (P : αProp) :

                                                                                                            A lower set relative to a predicate P is a set such that all elements satisfy P and any element less than one of its members and satisfying P is also a member.

                                                                                                            Equations
                                                                                                              Instances For
                                                                                                                structure RelUpperSet {α : Type u_1} [LE α] (P : αProp) :
                                                                                                                Type u_1

                                                                                                                An upper set relative to a predicate P is a set such that all elements satisfy P and any element greater than one of its members and satisfying P is also a member.

                                                                                                                Instances For
                                                                                                                  structure RelLowerSet {α : Type u_1} [LE α] (P : αProp) :
                                                                                                                  Type u_1

                                                                                                                  A lower set relative to a predicate P is a set such that all elements satisfy P and any element less than one of its members and satisfying P is also a member.

                                                                                                                  Instances For
                                                                                                                    theorem of_eq {α : Type u_1} {r : ααProp} [Std.Refl r] {a b : α} :
                                                                                                                    a = br a b
                                                                                                                    theorem comm {α : Type u_1} {r : ααProp} [Std.Symm r] {a b : α} :
                                                                                                                    r a b r b a
                                                                                                                    theorem antisymm' {α : Type u_1} {r : ααProp} [Std.Antisymm r] {a b : α} :
                                                                                                                    r a br b ab = a
                                                                                                                    theorem antisymm_iff {α : Type u_1} {r : ααProp} [Std.Refl r] [Std.Antisymm r] {a b : α} :
                                                                                                                    r a b r b a a = b
                                                                                                                    @[elab_without_expected_type]
                                                                                                                    theorem antisymm_of {α : Type u_1} (r : ααProp) [Std.Antisymm r] {a b : α} :
                                                                                                                    r a br b aa = b

                                                                                                                    A version of antisymm with r explicit.

                                                                                                                    This lemma matches the lemmas from lean core in Init.Algebra.Classes, but is missing there.

                                                                                                                    @[elab_without_expected_type]
                                                                                                                    theorem antisymm_of' {α : Type u_1} (r : ααProp) [Std.Antisymm r] {a b : α} :
                                                                                                                    r a br b ab = a

                                                                                                                    A version of antisymm' with r explicit.

                                                                                                                    This lemma matches the lemmas from lean core in Init.Algebra.Classes, but is missing there.

                                                                                                                    theorem comm_of {α : Type u_1} (r : ααProp) [Std.Symm r] {a b : α} :
                                                                                                                    r a b r b a

                                                                                                                    A version of comm with r explicit.

                                                                                                                    This lemma matches the lemmas from lean core in Init.Algebra.Classes, but is missing there.

                                                                                                                    theorem Std.Asymm.antisymm {α : Type u_1} (r : ααProp) [Asymm r] :
                                                                                                                    @[deprecated Std.Asymm.antisymm (since := "2026-01-05")]
                                                                                                                    theorem IsAsymm.isAntisymm {α : Type u_1} (r : ααProp) [Std.Asymm r] :

                                                                                                                    Alias of Std.Asymm.antisymm.

                                                                                                                    @[deprecated Std.Asymm.antisymm (since := "2026-01-06")]
                                                                                                                    theorem Std.Asymm.isAntisymm {α : Type u_1} (r : ααProp) [Asymm r] :

                                                                                                                    Alias of Std.Asymm.antisymm.

                                                                                                                    theorem Std.Asymm.irrefl {α : Type u_1} {r : ααProp} [Asymm r] :
                                                                                                                    @[deprecated Std.Asymm.irrefl (since := "2026-01-05")]
                                                                                                                    theorem IsAsymm.isIrrefl {α : Type u_1} {r : ααProp} [Std.Asymm r] :

                                                                                                                    Alias of Std.Asymm.irrefl.

                                                                                                                    @[deprecated Std.Asymm.irrefl (since := "2026-01-07")]
                                                                                                                    theorem Std.Asymm.isIrrefl {α : Type u_1} {r : ααProp} [Asymm r] :

                                                                                                                    Alias of Std.Asymm.irrefl.

                                                                                                                    theorem Std.Total.trichotomous {α : Type u_1} (r : ααProp) [Total r] :
                                                                                                                    @[deprecated Std.Total.trichotomous (since := "2026-01-24")]
                                                                                                                    theorem Std.Total.isTrichotomous {α : Type u_1} (r : ααProp) [Total r] :

                                                                                                                    Alias of Std.Total.trichotomous.

                                                                                                                    @[instance 100]
                                                                                                                    instance Std.Total.to_refl {α : Type u_1} (r : ααProp) [Total r] :
                                                                                                                    theorem ne_of_irrefl {α : Type u_1} {r : ααProp} [Std.Irrefl r] {x y : α} :
                                                                                                                    r x yx y
                                                                                                                    theorem ne_of_irrefl' {α : Type u_1} {r : ααProp} [Std.Irrefl r] {x y : α} :
                                                                                                                    r x yy x
                                                                                                                    theorem not_rel_of_subsingleton {α : Type u_1} (r : ααProp) [Std.Irrefl r] [Subsingleton α] (x y : α) :
                                                                                                                    ¬r x y
                                                                                                                    theorem rel_of_subsingleton {α : Type u_1} (r : ααProp) [Std.Refl r] [Subsingleton α] (x y : α) :
                                                                                                                    r x y
                                                                                                                    @[simp]
                                                                                                                    theorem empty_relation_apply {α : Type u_1} (a b : α) :
                                                                                                                    theorem rel_congr_left {α : Type u_1} {r : ααProp} [Std.Symm r] [IsTrans α r] {a b c : α} (h : r a b) :
                                                                                                                    r a c r b c
                                                                                                                    theorem rel_congr_right {α : Type u_1} {r : ααProp} [Std.Symm r] [IsTrans α r] {a b c : α} (h : r b c) :
                                                                                                                    r a b r a c
                                                                                                                    theorem rel_congr {α : Type u_1} {r : ααProp} [Std.Symm r] [IsTrans α r] {a b c d : α} (h₁ : r a b) (h₂ : r c d) :
                                                                                                                    r a c r b d
                                                                                                                    theorem trans_trichotomous_left {α : Type u_1} {r : ααProp} [IsTrans α r] [Std.Trichotomous r] {a b c : α} (h₁ : ¬r b a) (h₂ : r b c) :
                                                                                                                    r a c
                                                                                                                    theorem trans_trichotomous_right {α : Type u_1} {r : ααProp} [IsTrans α r] [Std.Trichotomous r] {a b c : α} (h₁ : r a b) (h₂ : ¬r c b) :
                                                                                                                    r a c
                                                                                                                    theorem transitive_of_trans {α : Type u_1} (r : ααProp) [IsTrans α r] :
                                                                                                                    theorem extensional_of_trichotomous_of_irrefl {α : Type u_1} (r : ααProp) [Std.Trichotomous r] [Std.Irrefl r] {a b : α} (H : ∀ (x : α), r x a r x b) :
                                                                                                                    a = b

                                                                                                                    In a trichotomous irreflexive order, every element is determined by the set of predecessors.