Skip to content

Commit 9b60f00

Browse files
committed
feat: Checking associativity in partial order (#1030)
Match leanprover-community/mathlib3#17942
1 parent cdc9f72 commit 9b60f00

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Mathlib/Order/Basic.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,23 @@ theorem le_implies_le_of_le_of_le {a b c d : α} [Preorder α] (hca : c ≤ a) (
428428
a ≤ b → c ≤ d :=
429429
fun hab ↦ (hca.trans hab).trans hbd
430430

431+
section PartialOrder
432+
variable [PartialOrder α]
433+
434+
/-- To prove commutativity of a binary operation `○`, we only to check `a ○ b ≤ b ○ a` for all `a`,
435+
`b`. -/
436+
lemma commutative_of_le {f : β → β → α} (comm : ∀ a b, f a b ≤ f b a) : ∀ a b, f a b = f b a :=
437+
fun _ _ ↦ (comm _ _).antisymm $ comm _ _
438+
439+
/-- To prove associativity of a commutative binary operation `○`, we only to check
440+
`(a ○ b) ○ c ≤ a ○ (b ○ c)` for all `a`, `b`, `c`. -/
441+
lemma associative_of_commutative_of_le {f : α → α → α} (comm : Commutative f)
442+
(assoc : ∀ a b c, f (f a b) c ≤ f a (f b c)) :
443+
Associative f :=
444+
fun a b c ↦ le_antisymm (assoc _ _ _) $ by rw [comm, comm b, comm _ c, comm a]; exact assoc _ _ _
445+
446+
end PartialOrder
447+
431448
@[ext]
432449
theorem Preorder.toLE_injective {α : Type _} : Function.Injective (@Preorder.toLE α) :=
433450
fun A B h ↦ match A, B with

0 commit comments

Comments
 (0)