Skip to content

Commit c2bcdbc

Browse files
committed
feat(init/algebra/order): backport Lean 4 definitions for min and max (#779)
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent fc13c8c commit c2bcdbc

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

library/init/algebra/functions.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variables {α : Type u} [linear_order α]
1717

1818
lemma min_def (a b : α) : min a b = if a ≤ b then a else b :=
1919
by rw [congr_fun linear_order.min_def a, min_default]
20-
lemma max_def (a b : α) : max a b = if ba then a else b :=
20+
lemma max_def (a b : α) : max a b = if ab then b else a :=
2121
by rw [congr_fun linear_order.max_def a, max_default]
2222

2323
private meta def min_tac_step : tactic unit :=
@@ -40,13 +40,13 @@ lemma le_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) : c ≤ min a b :=
4040
by min_tac a b
4141

4242
lemma le_max_left (a b : α) : a ≤ max a b :=
43-
by min_tac b a
43+
by min_tac a b
4444

4545
lemma le_max_right (a b : α) : b ≤ max a b :=
46-
by min_tac b a
46+
by min_tac a b
4747

4848
lemma max_le {a b c : α} (h₁ : a ≤ c) (h₂ : b ≤ c) : max a b ≤ c :=
49-
by min_tac b a
49+
by min_tac a b
5050

5151
lemma eq_min {a b c : α} (h₁ : c ≤ a) (h₂ : c ≤ b) (h₃ : ∀{d}, d ≤ a → d ≤ b → d ≤ c) :
5252
c = min a b :=
@@ -131,5 +131,5 @@ or.elim (le_or_gt b c)
131131
lemma max_lt {a b c : α} (h₁ : a < c) (h₂ : b < c) : max a b < c :=
132132
or.elim (le_or_gt a b)
133133
(assume h : a ≤ b, by min_tac b a)
134-
(assume h : a > b, by min_tac b a)
134+
(assume h : a > b, by min_tac a b)
135135
end

library/init/algebra/order.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ section linear_order
189189

190190
/-- Default definition of `max`. -/
191191
def max_default {α : Type u} [has_le α] [decidable_rel ((≤) : α → α → Prop)] (a b : α) :=
192-
if ba then a else b
192+
if ab then b else a
193193

194194
/-- Default definition of `min`. -/
195195
def min_default {α : Type u} [has_le α] [decidable_rel ((≤) : α → α → Prop)] (a b : α) :=

0 commit comments

Comments
 (0)