File: .lake/packages/lean4/src/lean/Init/Data/Ord.lean

full_name: Ordering
code: inductive Ordering where
  | lt | eq | gt
deriving Inhabited, BEq
goal: Type

full_name: Ordering.lt
code: inductive Ordering where
  | lt | eq | gt
deriving Inhabited, BEq
goal: Ordering

full_name: Ordering.eq
code: inductive Ordering where
  | lt | eq | gt
deriving Inhabited, BEq
goal: Ordering

full_name: Ordering.gt
code: inductive Ordering where
  | lt | eq | gt
deriving Inhabited, BEq
goal: Ordering

full_name: instInhabitedOrdering
code: inductive Ordering where
  | lt | eq | gt
deriving Inhabited, BEq
goal: Inhabited Ordering

full_name: instBEqOrdering
code: BEq
goal: BEq Ordering

full_name: Ordering.instDecidableEq
code: DecidableEq
goal: DecidableEq Ordering

full_name: Ordering.swap
code: /-- Swaps less and greater ordering results -/
def swap : Ordering → Ordering
  
goal: Ordering → Ordering

full_name: Ordering.then
code: /--
If `o₁` and `o₂` are `Ordering`, then `o₁.then o₂` returns `o₁` unless it is `.eq`,
in which case it returns `o₂`. Additionally, it has "short-circuiting" semantics similar to
boolean `x && y`: if `o₁` is not `.eq` then the expression for `o₂` is not evaluated.
This is a useful primitive for constructing lexicographic comparator functions:
```
structure Person where
  name : String
  age : Nat

instance : Ord Person where
  compare a b := (compare a.name b.name).then (compare b.age a.age)
```
This example will sort people first by name (in ascending order) and will sort people with
the same name by age (in descending order). (If all fields are sorted ascending and in the same
order as they are listed in the structure, you can also use `deriving Ord` on the structure
definition for the same effect.)
-/
@[macro_inline] def «then» : Ordering → Ordering → Ordering
  
goal: Ordering → Ordering → Ordering

full_name: Ordering.isEq
code: /--
Check whether the ordering is 'equal'.
-/
def isEq : Ordering → Bool
  
goal: Ordering → Bool

full_name: Ordering.isNe
code: /--
Check whether the ordering is 'not equal'.
-/
def isNe : Ordering → Bool
  
goal: Ordering → Bool

full_name: Ordering.isLE
code: /--
Check whether the ordering is 'less than or equal to'.
-/
def isLE : Ordering → Bool
  
goal: Ordering → Bool

full_name: Ordering.isLT
code: /--
Check whether the ordering is 'less than'.
-/
def isLT : Ordering → Bool
  
goal: Ordering → Bool

full_name: Ordering.isGT
code: /--
Check whether the ordering is 'greater than'.
-/
def isGT : Ordering → Bool
  
goal: Ordering → Bool

full_name: Ordering.isGE
code: /--
Check whether the ordering is 'greater than or equal'.
-/
def isGE : Ordering → Bool
  
goal: Ordering → Bool

full_name: compareOfLessAndEq
code: /--
Yields an `Ordering` s.t. `x < y` corresponds to `Ordering.lt` / `Ordering.gt` and
`x = y` corresponds to `Ordering.eq`.
-/
@[inline] def compareOfLessAndEq {α} (x y : α) [LT α] [Decidable (x < y)] [DecidableEq α] : Ordering 
goal: Ordering

full_name: compareOfLessAndBEq
code: /--
Yields an `Ordering` s.t. `x < y` corresponds to `Ordering.lt` / `Ordering.gt` and
`x == y` corresponds to `Ordering.eq`.
-/
@[inline] def compareOfLessAndBEq {α} (x y : α) [LT α] [Decidable (x < y)] [BEq α] : Ordering 
goal: Ordering

full_name: compareLex
code: /--
Compare `a` and `b` lexicographically by `cmp₁` and `cmp₂`. `a` and `b` are
first compared by `cmp₁`. If this returns 'equal', `a` and `b` are compared
by `cmp₂` to break the tie.
-/
@[inline] def compareLex (cmp₁ cmp₂ : α → β → Ordering) (a : α) (b : β) : Ordering 
goal: Ordering

full_name: Ord
code: /--
`Ord α` provides a computable total order on `α`, in terms of the
`compare : α → α → Ordering` function.

Typically instances will be transitive, reflexive, and antisymmetric,
but this is not enforced by the typeclass.

There is a derive handler, so appending `deriving Ord` to an inductive type or structure
will attempt to create an `Ord` instance.
-/
class Ord (α : Type u) where
  /-- Compare two elements in `α` using the comparator contained in an `[Ord α]` instance. -/
  compare : α → α → Ordering
goal: Type u

full_name: Ord.compare
code: /--
`Ord α` provides a computable total order on `α`, in terms of the
`compare : α → α → Ordering` function.

Typically instances will be transitive, reflexive, and antisymmetric,
but this is not enforced by the typeclass.

There is a derive handler, so appending `deriving Ord` to an inductive type or structure
will attempt to create an `Ord` instance.
-/
class Ord (α : Type u) where
  /-- Compare two elements in `α` using the comparator contained in an `[Ord α]` instance. -/
  compare : α → α → Ordering
goal: α → α → Ordering

full_name: compareOn
code: /--
Compare `x` and `y` by comparing `f x` and `f y`.
-/
@[inline] def compareOn [ord : Ord β] (f : α → β) (x y : α) : Ordering 
goal: Ordering

full_name: instOrdNat
code: instance : Ord Nat 
goal: Ord Nat

full_name: instOrdInt
code: instance : Ord Int 
goal: Ord Int

full_name: instOrdBool
code: instance : Ord Bool 
goal: Ord Bool

full_name: instOrdString
code: instance : Ord String 
goal: Ord String

full_name: instOrdFin
code: instance (n : Nat) : Ord (Fin n) 
goal: Ord (Fin n)

full_name: instOrdUInt8
code: instance : Ord UInt8 
goal: Ord UInt8

full_name: instOrdUInt16
code: instance : Ord UInt16 
goal: Ord UInt16

full_name: instOrdUInt32
code: instance : Ord UInt32 
goal: Ord UInt32

full_name: instOrdUInt64
code: instance : Ord UInt64 
goal: Ord UInt64

full_name: instOrdUSize
code: instance : Ord USize 
goal: Ord USize

full_name: instOrdChar
code: instance : Ord Char 
goal: Ord Char

full_name: instOrdOption
code: instance [Ord α] : Ord (Option α) 
goal: Ord (Option α)

full_name: lexOrd
code: /-- The lexicographic order on pairs. -/
def lexOrd [Ord α] [Ord β] : Ord (α × β) 
goal: Ord (α × β)

full_name: ltOfOrd
code: def ltOfOrd [Ord α] : LT α 
goal: LT α

full_name: «instDecidableRelLt_.lake»
code: instance [Ord α] : DecidableRel (@LT.lt α ltOfOrd) 
goal: DecidableRel LT.lt

full_name: leOfOrd
code: def leOfOrd [Ord α] : LE α 
goal: LE α

full_name: «instDecidableRelLe_.lake»
code: instance [Ord α] : DecidableRel (@LE.le α leOfOrd) 
goal: DecidableRel LE.le

full_name: Ord.toBEq
code: /--
Derive a `BEq` instance from an `Ord` instance.
-/
protected def toBEq (ord : Ord α) : BEq α 
goal: BEq α

full_name: Ord.toLT
code: /--
Derive an `LT` instance from an `Ord` instance.
-/
protected def toLT (_ : Ord α) : LT α 
goal: Ord α → LT α

full_name: Ord.toLE
code: /--
Derive an `LE` instance from an `Ord` instance.
-/
protected def toLE (_ : Ord α) : LE α 
goal: Ord α → LE α

full_name: Ord.opposite
code: /--
Invert the order of an `Ord` instance.
-/
protected def opposite (ord : Ord α) : Ord α 
goal: Ord α

full_name: Ord.on
code: /--
`ord.on f` compares `x` and `y` by comparing `f x` and `f y` according to `ord`.
-/
protected def on (_ : Ord β) (f : α → β) : Ord α 
goal: Ord β → (α → β) → Ord α

full_name: Ord.lex
code: /--
Derive the lexicographic order on products `α × β` from orders for `α` and `β`.
-/
protected def lex (_ : Ord α) (_ : Ord β) : Ord (α × β) 
goal: Ord α → Ord β → Ord (α × β)

full_name: Ord.lex'
code: /--
Create an order which compares elements first by `ord₁` and then, if this
returns 'equal', by `ord₂`.
-/
protected def lex' (ord₁ ord₂ : Ord α) : Ord α 
goal: Ord α

full_name: Ord.arrayOrd
code: /--
Creates an order which compares elements of an `Array` in lexicographic order.
-/
protected def arrayOrd [a : Ord α] : Ord (Array α) 
goal: Ord (Array α)