Documentation

Mathlib.Init.Algebra.Classes

Unbundled algebra classes #

These classes are part of an incomplete refactor described here on the github Wiki. However a subset of them are widely used in mathlib3, and it has been tricky to clean this up as this file was in core Lean 3.

By themselves, these classes are not good replacements for the Monoid / Group etc structures provided by mathlib, as they are not discoverable by simp unlike the current lemmas due to there being little to index on. The Wiki page linked above describes an algebraic normalizer, but it was never implemented in Lean 3.

Porting notes: #

This file is ancient, and it would be good to replace it with a clean version that provides what mathlib4 actually needs.

I've omitted all the @[algebra] attributes, as they are not used elsewhere.

The section StrictWeakOrder has been omitted, but I've left the mathport output in place. Please delete if cleaning up.

I've commented out some classes which we think are completely unused in mathlib.

I've added many of the declarations to nolints.json. If you clean up this file, please add documentation to classes that we are keeping.

Mario made the following analysis of uses in mathlib3:

class IsSymmOp (α : Type u) (β : Type v) (op : α → α → β) :
  • symm_op : ∀ (a b : α), op a b = op b a
Instances
    class IsCommutative (α : Type u) (op : α → α → α) :

    A commutative binary operation.

    • comm : ∀ (a b : α), op a b = op b a
    Instances
      instance instIsCommutative {α : Type u_1} {op : α → α → α} [IsCommutative α op] :
      Equations
      • instIsCommutative = { comm := (_ : ∀ (a b : α), op a b = op b a) }
      instance isSymmOp_of_isCommutative (α : Type u) (op : α → α → α) [IsCommutative α op] :
      IsSymmOp α α op
      Equations
      class IsAssociative (α : Type u) (op : α → α → α) :

      An associative binary operation.

      • assoc : ∀ (a b c : α), op (op a b) c = op a (op b c)
      Instances
        instance instIsAssociative {α : Type u_1} {op : α → α → α} [IsAssociative α op] :
        Equations
        • instIsAssociative = { assoc := (_ : ∀ (a b c : α), op (op a b) c = op a (op b c)) }
        class IsLeftId (α : Type u) (op : α → α → α) (o : outParam α) :

        A binary operation with a left identity.

        • left_id : ∀ (a : α), op o a = a
        Instances
          class IsRightId (α : Type u) (op : α → α → α) (o : outParam α) :

          A binary operation with a right identity.

          • right_id : ∀ (a : α), op a o = a
          Instances
            instance instIsNeutral {α : Type u_1} {o : α} {op : α → α → α} [IsLeftId α op o] [IsRightId α op o] :
            Equations
            • instIsNeutral = { left_neutral := (_ : ∀ (a : α), op o a = a), right_neutral := (_ : ∀ (a : α), op a o = a) }
            class IsLeftCancel (α : Type u) (op : α → α → α) :
            • left_cancel : ∀ (a b c : α), op a b = op a c → b = c
            Instances
              class IsRightCancel (α : Type u) (op : α → α → α) :
              • right_cancel : ∀ (a b c : α), op a b = op c b → a = c
              Instances
                class IsIdempotent (α : Type u) (op : α → α → α) :
                • idempotent : ∀ (a : α), op a a = a
                Instances
                  instance instIsIdempotent {α : Type u_1} {op : α → α → α} [IsIdempotent α op] :
                  Equations
                  • instIsIdempotent = { idempotent := (_ : ∀ (a : α), op a a = a) }
                  class IsIrrefl (α : Type u) (r : α → α → Prop) :

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

                  • irrefl : ∀ (a : α), ¬r a a
                  Instances
                    class IsRefl (α : Type u) (r : α → α → Prop) :

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

                    • refl : ∀ (a : α), r a a
                    Instances
                      class IsSymm (α : Type u) (r : α → α → Prop) :

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

                      • symm : ∀ (a b : α), r a b → r b a
                      Instances
                        instance isSymmOp_of_isSymm (α : Type u) (r : α → α → Prop) [IsSymm α r] :

                        The opposite of a symmetric relation is symmetric.

                        Equations
                        class IsAsymm (α : Type u) (r : α → α → Prop) :

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

                        • asymm : ∀ (a b : α), r a b → ¬r b a
                        Instances
                          class IsAntisymm (α : Type u) (r : α → α → Prop) :

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

                          • antisymm : ∀ (a b : α), r a b → r b a → a = b
                          Instances
                            class IsTrans (α : Type u) (r : α → α → Prop) :

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

                            • trans : ∀ (a b c : α), r a b → r b c → r a c
                            Instances
                              instance instTrans {α : Type u} {r : α → α → Prop} [IsTrans α r] :
                              Trans r r r
                              Equations
                              • instTrans = { trans := (_ : ∀ {a b c : α}, r a b → r b c → r a c) }
                              instance instIsTrans {α : Type u} {r : α → α → Prop} [Trans r r r] :
                              IsTrans α r
                              Equations
                              class IsTotal (α : Type u) (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.

                              • total : ∀ (a b : α), r a b ∨ r b a
                              Instances
                                class IsPreorder (α : Type u) (r : α → α → Prop) extends IsRefl , IsTrans :

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

                                  Instances
                                    class IsTotalPreorder (α : Type u) (r : α → α → Prop) extends IsTrans , IsTotal :

                                    IsTotalPreorder X r means that the binary relation r on X is total and a preorder.

                                      Instances
                                        instance isTotalPreorder_isPreorder (α : Type u) (r : α → α → Prop) [s : IsTotalPreorder α r] :

                                        Every total pre-order is a pre-order.

                                        Equations
                                        class IsPartialOrder (α : Type u) (r : α → α → Prop) extends IsPreorder , IsAntisymm :

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

                                          Instances
                                            class IsLinearOrder (α : Type u) (r : α → α → Prop) extends IsPartialOrder , IsTotal :

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

                                              Instances
                                                class IsEquiv (α : Type u) (r : α → α → Prop) extends IsPreorder , IsSymm :

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

                                                  Instances
                                                    class IsStrictOrder (α : Type u) (r : α → α → Prop) extends IsIrrefl , IsTrans :

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

                                                      Instances
                                                        class IsIncompTrans (α : Type u) (lt : α → α → Prop) :

                                                        IsIncompTrans X lt means that for lt a binary relation on X, the incomparable relation fun a b => ¬ lt a b ∧ ¬ lt b a is transitive.

                                                        • incomp_trans : ∀ (a b c : α), ¬lt a b ∧ ¬lt b a → ¬lt b c ∧ ¬lt c b → ¬lt a c ∧ ¬lt c a
                                                        Instances
                                                          class IsStrictWeakOrder (α : Type u) (lt : α → α → Prop) extends IsStrictOrder , IsIncompTrans :

                                                          IsStrictWeakOrder X lt means that the binary relation lt on X is a strict weak order, that is, IsStrictOrder X lt and IsIncompTrans X lt.

                                                            Instances
                                                              class IsTrichotomous (α : Type u) (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.

                                                              • trichotomous : ∀ (a b : α), lt a b ∨ a = b ∨ lt b a
                                                              Instances
                                                                class IsStrictTotalOrder (α : Type u) (lt : α → α → Prop) extends IsTrichotomous , IsStrictOrder :

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

                                                                  Instances
                                                                    instance eq_isEquiv (α : Type u) :
                                                                    IsEquiv α fun (x x_1 : α) => x = x_1

                                                                    Equality is an equivalence relation.

                                                                    Equations
                                                                    • (_ : IsEquiv α fun (x x_1 : α) => x = x_1) = (_ : IsEquiv α fun (x x_1 : α) => x = x_1)
                                                                    theorem irrefl {α : Type u} {r : α → α → Prop} [IsIrrefl α r] (a : α) :
                                                                    ¬r a a
                                                                    theorem refl {α : Type u} {r : α → α → Prop} [IsRefl α r] (a : α) :
                                                                    r a a
                                                                    theorem trans {α : Type u} {r : α → α → Prop} [IsTrans α r] {a : α} {b : α} {c : α} :
                                                                    r a b → r b c → r a c
                                                                    theorem symm {α : Type u} {r : α → α → Prop} [IsSymm α r] {a : α} {b : α} :
                                                                    r a b → r b a
                                                                    theorem antisymm {α : Type u} {r : α → α → Prop} [IsAntisymm α r] {a : α} {b : α} :
                                                                    r a b → r b a → a = b
                                                                    theorem asymm {α : Type u} {r : α → α → Prop} [IsAsymm α r] {a : α} {b : α} :
                                                                    r a b → ¬r b a
                                                                    theorem trichotomous {α : Type u} {r : α → α → Prop} [IsTrichotomous α r] (a : α) (b : α) :
                                                                    r a b ∨ a = b ∨ r b a
                                                                    theorem incomp_trans {α : Type u} {r : α → α → Prop} [IsIncompTrans α r] {a : α} {b : α} {c : α} :
                                                                    ¬r a b ∧ ¬r b a → ¬r b c ∧ ¬r c b → ¬r a c ∧ ¬r c a
                                                                    instance isAsymm_of_isTrans_of_isIrrefl {α : Type u} {r : α → α → Prop} [IsTrans α r] [IsIrrefl α r] :
                                                                    IsAsymm α r
                                                                    Equations
                                                                    @[elab_without_expected_type]
                                                                    theorem irrefl_of {α : Type u} (r : α → α → Prop) [IsIrrefl α r] (a : α) :
                                                                    ¬r a a
                                                                    @[elab_without_expected_type]
                                                                    theorem refl_of {α : Type u} (r : α → α → Prop) [IsRefl α r] (a : α) :
                                                                    r a a
                                                                    @[elab_without_expected_type]
                                                                    theorem trans_of {α : Type u} (r : α → α → Prop) [IsTrans α r] {a : α} {b : α} {c : α} :
                                                                    r a b → r b c → r a c
                                                                    @[elab_without_expected_type]
                                                                    theorem symm_of {α : Type u} (r : α → α → Prop) [IsSymm α r] {a : α} {b : α} :
                                                                    r a b → r b a
                                                                    @[elab_without_expected_type]
                                                                    theorem asymm_of {α : Type u} (r : α → α → Prop) [IsAsymm α r] {a : α} {b : α} :
                                                                    r a b → ¬r b a
                                                                    @[elab_without_expected_type]
                                                                    theorem total_of {α : Type u} (r : α → α → Prop) [IsTotal α r] (a : α) (b : α) :
                                                                    r a b ∨ r b a
                                                                    @[elab_without_expected_type]
                                                                    theorem trichotomous_of {α : Type u} (r : α → α → Prop) [IsTrichotomous α r] (a : α) (b : α) :
                                                                    r a b ∨ a = b ∨ r b a
                                                                    @[elab_without_expected_type]
                                                                    theorem incomp_trans_of {α : Type u} (r : α → α → Prop) [IsIncompTrans α r] {a : α} {b : α} {c : α} :
                                                                    ¬r a b ∧ ¬r b a → ¬r b c ∧ ¬r c b → ¬r a c ∧ ¬r c a
                                                                    def StrictWeakOrder.Equiv {α : Type u} {r : α → α → Prop} (a : α) (b : α) :
                                                                    Equations
                                                                    Instances For
                                                                      theorem StrictWeakOrder.erefl {α : Type u} {r : α → α → Prop} [IsStrictWeakOrder α r] (a : α) :
                                                                      theorem StrictWeakOrder.esymm {α : Type u} {r : α → α → Prop} {a : α} {b : α} :
                                                                      theorem StrictWeakOrder.etrans {α : Type u} {r : α → α → Prop} [IsStrictWeakOrder α r] {a : α} {b : α} {c : α} :
                                                                      theorem StrictWeakOrder.not_lt_of_equiv {α : Type u} {r : α → α → Prop} {a : α} {b : α} :
                                                                      theorem StrictWeakOrder.not_lt_of_equiv' {α : Type u} {r : α → α → Prop} {a : α} {b : α} :
                                                                      instance StrictWeakOrder.isEquiv {α : Type u} {r : α → α → Prop} [IsStrictWeakOrder α r] :
                                                                      IsEquiv α StrictWeakOrder.Equiv
                                                                      Equations
                                                                      • (_ : IsEquiv α StrictWeakOrder.Equiv) = (_ : IsEquiv α StrictWeakOrder.Equiv)
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        theorem isStrictWeakOrder_of_isTotalPreorder {α : Type u} {le : α → α → Prop} {lt : α → α → Prop} [DecidableRel le] [IsTotalPreorder α le] (h : ∀ (a b : α), lt a b ↔ ¬le b a) :
                                                                        theorem lt_of_lt_of_incomp {α : Type u} {lt : α → α → Prop} [IsStrictWeakOrder α lt] [DecidableRel lt] {a : α} {b : α} {c : α} :
                                                                        lt a b → ¬lt b c ∧ ¬lt c b → lt a c
                                                                        theorem lt_of_incomp_of_lt {α : Type u} {lt : α → α → Prop} [IsStrictWeakOrder α lt] [DecidableRel lt] {a : α} {b : α} {c : α} :
                                                                        ¬lt a b ∧ ¬lt b a → lt b c → lt a c
                                                                        theorem eq_of_incomp {α : Type u} {lt : α → α → Prop} [IsTrichotomous α lt] {a : α} {b : α} :
                                                                        ¬lt a b ∧ ¬lt b a → a = b
                                                                        theorem eq_of_eqv_lt {α : Type u} {lt : α → α → Prop} [IsTrichotomous α lt] {a : α} {b : α} :
                                                                        theorem incomp_iff_eq {α : Type u} {lt : α → α → Prop} [IsTrichotomous α lt] [IsIrrefl α lt] (a : α) (b : α) :
                                                                        ¬lt a b ∧ ¬lt b a ↔ a = b
                                                                        theorem eqv_lt_iff_eq {α : Type u} {lt : α → α → Prop} [IsTrichotomous α lt] [IsIrrefl α lt] (a : α) (b : α) :
                                                                        theorem not_lt_of_lt {α : Type u} {lt : α → α → Prop} [IsStrictOrder α lt] {a : α} {b : α} :
                                                                        lt a b → ¬lt b a