Module docstring
{"# min lemmas ","# max lemmas "}
{"# min lemmas ","# max lemmas "}
Nat.min_eq_min
theorem
(a : Nat) : Nat.min a b = min a b
protected theorem min_eq_min (a : Nat) : Nat.min a b = min a b := rfl
Nat.zero_min
theorem
(a : Nat) : min 0 a = 0
@[simp] protected theorem zero_min (a : Nat) : min 0 a = 0 := by
simp [Nat.min_def]
Nat.min_zero
theorem
(a : Nat) : min a 0 = 0
@[simp] protected theorem min_zero (a : Nat) : min a 0 = 0 := by
simp [Nat.min_def]
Nat.add_min_add_right
theorem
(a b c : Nat) : min (a + c) (b + c) = min a b + c
@[simp] protected theorem add_min_add_right (a b c : Nat) : min (a + c) (b + c) = min a b + c := by
rw [Nat.min_def, Nat.min_def]
simp only [Nat.add_le_add_iff_right]
split <;> simp
Nat.add_min_add_left
theorem
(a b c : Nat) : min (a + b) (a + c) = a + min b c
@[simp] protected theorem add_min_add_left (a b c : Nat) : min (a + b) (a + c) = a + min b c := by
rw [Nat.min_def, Nat.min_def]
simp only [Nat.add_le_add_iff_left]
split <;> simp
Nat.mul_min_mul_right
theorem
(a b c : Nat) : min (a * c) (b * c) = min a b * c
@[simp] protected theorem mul_min_mul_right (a b c : Nat) : min (a * c) (b * c) = min a b * c := by
by_cases h : 0 < c
· rw [Nat.min_def, Nat.min_def]
simp only [Nat.mul_le_mul_right_iff h]
split <;> simp
· replace h : c = 0 := by exact Nat.eq_zero_of_not_pos h
subst h
simp
Nat.mul_min_mul_left
theorem
(a b c : Nat) : min (a * b) (a * c) = a * min b c
@[simp] protected theorem mul_min_mul_left (a b c : Nat) : min (a * b) (a * c) = a * min b c := by
rw [Nat.mul_comm a, Nat.mul_comm a, Nat.mul_min_mul_right, Nat.mul_comm]
Nat.min_comm
theorem
(a b : Nat) : min a b = min b a
protected theorem min_comm (a b : Nat) : min a b = min b a := by
match Nat.lt_trichotomy a b with
| .inl h => simp [Nat.min_def, h, Nat.le_of_lt, Nat.not_le_of_lt]
| .inr (.inl h) => simp [Nat.min_def, h]
| .inr (.inr h) => simp [Nat.min_def, h, Nat.le_of_lt, Nat.not_le_of_lt]
Nat.instCommutativeMin
instance
: Std.Commutative (α := Nat) min
instance : Std.Commutative (α := Nat) min := ⟨Nat.min_comm⟩
Nat.min_le_right
theorem
(a b : Nat) : min a b ≤ b
protected theorem min_le_right (a b : Nat) : min a b ≤ b := by
by_cases (a ≤ b) <;> simp [Nat.min_def, *]
Nat.min_le_left
theorem
(a b : Nat) : min a b ≤ a
protected theorem min_le_left (a b : Nat) : min a b ≤ a :=
Nat.min_comm .. ▸ Nat.min_le_right ..
Nat.min_eq_left
theorem
{a b : Nat} (h : a ≤ b) : min a b = a
protected theorem min_eq_left {a b : Nat} (h : a ≤ b) : min a b = a := if_pos h
Nat.min_eq_right
theorem
{a b : Nat} (h : b ≤ a) : min a b = b
protected theorem min_eq_right {a b : Nat} (h : b ≤ a) : min a b = b :=
Nat.min_comm .. ▸ Nat.min_eq_left h
Nat.le_min_of_le_of_le
theorem
{a b c : Nat} : a ≤ b → a ≤ c → a ≤ min b c
protected theorem le_min_of_le_of_le {a b c : Nat} : a ≤ b → a ≤ c → a ≤ min b c := by
intros; cases Nat.le_total b c with
| inl h => rw [Nat.min_eq_left h]; assumption
| inr h => rw [Nat.min_eq_right h]; assumption
Nat.le_min
theorem
{a b c : Nat} : a ≤ min b c ↔ a ≤ b ∧ a ≤ c
protected theorem le_min {a b c : Nat} : a ≤ min b c ↔ a ≤ b ∧ a ≤ c :=
⟨fun h => ⟨Nat.le_trans h (Nat.min_le_left ..), Nat.le_trans h (Nat.min_le_right ..)⟩,
fun ⟨h₁, h₂⟩ => Nat.le_min_of_le_of_le h₁ h₂⟩
Nat.lt_min
theorem
{a b c : Nat} : a < min b c ↔ a < b ∧ a < c
protected theorem lt_min {a b c : Nat} : a < min b c ↔ a < b ∧ a < c := Nat.le_min
Nat.max_eq_max
theorem
(a : Nat) : Nat.max a b = max a b
protected theorem max_eq_max (a : Nat) : Nat.max a b = max a b := rfl
Nat.zero_max
theorem
(a : Nat) : max 0 a = a
@[simp] protected theorem zero_max (a : Nat) : max 0 a = a := by
simp [Nat.max_def]
Nat.max_zero
theorem
(a : Nat) : max a 0 = a
@[simp] protected theorem max_zero (a : Nat) : max a 0 = a := by
simp +contextual [Nat.max_def]
Nat.add_max_add_right
theorem
(a b c : Nat) : max (a + c) (b + c) = max a b + c
@[simp] protected theorem add_max_add_right (a b c : Nat) : max (a + c) (b + c) = max a b + c := by
rw [Nat.max_def, Nat.max_def]
simp only [Nat.add_le_add_iff_right]
split <;> simp
Nat.add_max_add_left
theorem
(a b c : Nat) : max (a + b) (a + c) = a + max b c
@[simp] protected theorem add_max_add_left (a b c : Nat) : max (a + b) (a + c) = a + max b c := by
rw [Nat.max_def, Nat.max_def]
simp only [Nat.add_le_add_iff_left]
split <;> simp
Nat.mul_max_mul_right
theorem
(a b c : Nat) : max (a * c) (b * c) = max a b * c
@[simp] protected theorem mul_max_mul_right (a b c : Nat) : max (a * c) (b * c) = max a b * c := by
by_cases h : 0 < c
· rw [Nat.max_def, Nat.max_def]
simp only [Nat.mul_le_mul_right_iff h]
split <;> simp
· replace h : c = 0 := by exact Nat.eq_zero_of_not_pos h
subst h
simp
Nat.mul_max_mul_left
theorem
(a b c : Nat) : max (a * b) (a * c) = a * max b c
@[simp] protected theorem mul_max_mul_left (a b c : Nat) : max (a * b) (a * c) = a * max b c := by
rw [Nat.mul_comm a, Nat.mul_comm a, Nat.mul_max_mul_right, Nat.mul_comm]
Nat.max_comm
theorem
(a b : Nat) : max a b = max b a
protected theorem max_comm (a b : Nat) : max a b = max b a := by
simp only [Nat.max_def]
by_cases h₁ : a ≤ b <;> by_cases h₂ : b ≤ a <;> simp [h₁, h₂]
· exact Nat.le_antisymm h₂ h₁
· cases not_or_intro h₁ h₂ <| Nat.le_total ..
Nat.instCommutativeMax
instance
: Std.Commutative (α := Nat) max
instance : Std.Commutative (α := Nat) max := ⟨Nat.max_comm⟩
Nat.le_max_left
theorem
(a b : Nat) : a ≤ max a b
protected theorem le_max_left (a b : Nat) : a ≤ max a b := by
by_cases (a ≤ b) <;> simp [Nat.max_def, *]
Nat.le_max_right
theorem
(a b : Nat) : b ≤ max a b
protected theorem le_max_right (a b : Nat) : b ≤ max a b :=
Nat.max_comm .. ▸ Nat.le_max_left ..
Nat.max_eq_right
theorem
{a b : Nat} (h : a ≤ b) : max a b = b
protected theorem max_eq_right {a b : Nat} (h : a ≤ b) : max a b = b := if_pos h
Nat.max_eq_left
theorem
{a b : Nat} (h : b ≤ a) : max a b = a
protected theorem max_eq_left {a b : Nat} (h : b ≤ a) : max a b = a :=
Nat.max_comm .. ▸ Nat.max_eq_right h
Nat.max_le_of_le_of_le
theorem
{a b c : Nat} : a ≤ c → b ≤ c → max a b ≤ c
protected theorem max_le_of_le_of_le {a b c : Nat} : a ≤ c → b ≤ c → max a b ≤ c := by
intros; cases Nat.le_total a b with
| inl h => rw [Nat.max_eq_right h]; assumption
| inr h => rw [Nat.max_eq_left h]; assumption
Nat.max_le
theorem
{a b c : Nat} : max a b ≤ c ↔ a ≤ c ∧ b ≤ c
protected theorem max_le {a b c : Nat} : maxmax a b ≤ c ↔ a ≤ c ∧ b ≤ c :=
⟨fun h => ⟨Nat.le_trans (Nat.le_max_left ..) h, Nat.le_trans (Nat.le_max_right ..) h⟩,
fun ⟨h₁, h₂⟩ => Nat.max_le_of_le_of_le h₁ h₂⟩
Nat.max_lt
theorem
{a b c : Nat} : max a b < c ↔ a < c ∧ b < c
protected theorem max_lt {a b c : Nat} : maxmax a b < c ↔ a < c ∧ b < c :=
match c with
| 0 => by simp
| c + 1 => by simpa [Nat.lt_add_one_iff] using Nat.max_le