Ordering #
@[simp]
theorem
Ordering.swap_inj
{o₁ : Ordering}
{o₂ : Ordering}
:
Ordering.swap o₁ = Ordering.swap o₂ ↔ o₁ = o₂
OrientedCmp cmp
asserts that cmp
is determined by the relation cmp x y = .lt
.
- symm : ∀ (x y : α), Ordering.swap (cmp x y) = cmp y x
The comparator operation is symmetric, in the sense that if
cmp x y
equals.lt
thencmp y x = .gt
and vice versa.
Instances
theorem
Std.OrientedCmp.cmp_eq_gt :
∀ {α : Sort u_1} {cmp : α → α → Ordering} {x y : α} [inst : Std.OrientedCmp cmp],
cmp x y = Ordering.gt ↔ cmp y x = Ordering.lt
theorem
Std.OrientedCmp.cmp_eq_eq_symm :
∀ {α : Sort u_1} {cmp : α → α → Ordering} {x y : α} [inst : Std.OrientedCmp cmp],
cmp x y = Ordering.eq ↔ cmp y x = Ordering.eq
theorem
Std.OrientedCmp.cmp_refl :
∀ {α : Sort u_1} {cmp : α → α → Ordering} {x : α} [inst : Std.OrientedCmp cmp], cmp x x = Ordering.eq
TransCmp cmp
asserts that cmp
induces a transitive relation.
- symm : ∀ (x y : α), Ordering.swap (cmp x y) = cmp y x
- le_trans : ∀ {x y z : α}, cmp x y ≠ Ordering.gt → cmp y z ≠ Ordering.gt → cmp x z ≠ Ordering.gt
The comparator operation is transitive.
Instances
theorem
Std.TransCmp.ge_trans :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y ≠ Ordering.lt → cmp y z ≠ Ordering.lt → cmp x_1 z ≠ Ordering.lt
theorem
Std.TransCmp.lt_asymm :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y : x},
cmp x_1 y = Ordering.lt → cmp y x_1 ≠ Ordering.lt
theorem
Std.TransCmp.gt_asymm :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y : x},
cmp x_1 y = Ordering.gt → cmp y x_1 ≠ Ordering.gt
theorem
Std.TransCmp.le_lt_trans :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y ≠ Ordering.gt → cmp y z = Ordering.lt → cmp x_1 z = Ordering.lt
theorem
Std.TransCmp.lt_le_trans :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y = Ordering.lt → cmp y z ≠ Ordering.gt → cmp x_1 z = Ordering.lt
theorem
Std.TransCmp.lt_trans :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y = Ordering.lt → cmp y z = Ordering.lt → cmp x_1 z = Ordering.lt
theorem
Std.TransCmp.gt_trans :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y = Ordering.gt → cmp y z = Ordering.gt → cmp x_1 z = Ordering.gt
theorem
Std.TransCmp.cmp_congr_left :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y z : x},
cmp x_1 y = Ordering.eq → cmp x_1 z = cmp y z
theorem
Std.TransCmp.cmp_congr_left' :
∀ {x : Sort u_1} {cmp : x → x → Ordering} [inst : Std.TransCmp cmp] {x_1 y : x},
cmp x_1 y = Ordering.eq → cmp x_1 = cmp y
theorem
Std.TransCmp.cmp_congr_right :
∀ {x : Sort u_1} {cmp : x → x → Ordering} {y z x_1 : x} [inst : Std.TransCmp cmp],
cmp y z = Ordering.eq → cmp x_1 y = cmp x_1 z
instance
Std.instOrientedCmpFlipOrdering :
∀ {α : Sort u_1} {cmp : α → α → Ordering} [inst : Std.OrientedCmp cmp], Std.OrientedCmp (flip cmp)
Equations
- ⋯ = ⋯
instance
Std.instTransCmpFlipOrdering :
∀ {α : Sort u_1} {cmp : α → α → Ordering} [inst : Std.TransCmp cmp], Std.TransCmp (flip cmp)
Equations
- ⋯ = ⋯
@[inline]
def
Ordering.byKey
{α : Sort u_1}
{β : Sort u_2}
(f : α → β)
(cmp : β → β → Ordering)
(a : α)
(b : α)
:
Pull back a comparator by a function f
, by applying the comparator to both arguments.
Equations
- Ordering.byKey f cmp a b = cmp (f a) (f b)
Instances For
instance
Ordering.instOrientedCmpByKey
{α : Sort u_1}
{β : Sort u_2}
(f : α → β)
(cmp : β → β → Ordering)
[Std.OrientedCmp cmp]
:
Std.OrientedCmp (Ordering.byKey f cmp)
Equations
- ⋯ = ⋯
instance
Ordering.instTransCmpByKey
{α : Sort u_1}
{β : Sort u_2}
(f : α → β)
(cmp : β → β → Ordering)
[Std.TransCmp cmp]
:
Std.TransCmp (Ordering.byKey f cmp)
Equations
- ⋯ = ⋯
instance
Ordering.instTransCmpByKey_1
{α : Sort u_1}
{β : Sort u_2}
(f : α → β)
(cmp : β → β → Ordering)
[Std.TransCmp cmp]
:
Std.TransCmp (Ordering.byKey f cmp)
Equations
- ⋯ = ⋯