Zulip Chat Archive
Stream: general
Topic: Code for CompleteLinearOrder
Yijun Yuan (Oct 21 2025 at 03:29):
In mathlib, CompleteLinearOrder = CompleteOrder + BiheytingAlgebra. I'm just confused why the following code doesn't work?
instance {α : Type*} [h1 : CompleteLattice α] [h2 : LinearOrder α] : CompleteLinearOrder α :=
{
h1, h2.toBiheytingAlgebra with
}
Lean is just complaining about LinearOrder.toBiheytingAlgebra requires BoundedOrder, but why it can't be automatically inferred by CompleteLattice, i.e. h1 in the above code?
Andrew Yang (Oct 21 2025 at 03:33):
Both CompleteLattice and LinearOrder extends PartialOrder, so {α : Type*} [h1 : CompleteLattice α] [h2 : LinearOrder α] actually means let α be a type, equipped with an order h1 that makes it into a complete lattice, and another totally unrelated order h2 that makes it into a linear order.
Yijun Yuan (Oct 21 2025 at 08:17):
I understand the situation, but what is the correct way to do so?
Kenny Lau (Oct 21 2025 at 08:41):
@Yijun Yuan this might be an #xy problem, what are you actually trying to do?
Floris van Doorn (Oct 21 2025 at 09:55):
Yijun Yuan said:
I understand the situation, but what is the correct way to do so?
Never assume [h1 : CompleteLattice α] [h2 : LinearOrder α]. Just assume [CompleteLinearOrder α] directly.
Yijun Yuan (Oct 21 2025 at 10:09):
I figured it out by myself. Maybe I should do
noncomputable instance {α : Type*} [h1 : CompleteLattice α] [DecidableEq α] [DecidableLE α] [DecidableLT α] [h2 : IsTotal _ h1.toLE.le] : CompleteLinearOrder α := {
h1, (Lattice.toLinearOrder α).toBiheytingAlgebra with
le_total := h2.total
toDecidableLE := inferInstance
}
Last updated: Dec 20 2025 at 21:32 UTC