Result
For a finite set s : Finset α in a linear order, the definitions s.max' h and s.min' h take a proof h : s.Nonempty as an argument.
Although these proofs are logically irrelevant, it is convenient in Lean to have explicit rewrite lemmas stating that the value does not depend on the chosen witness.
Theorem (proof irrelevance for max')
For any h₁ h₂ : s.Nonempty,
Theorem (proof irrelevance for min')
For any h₁ h₂ : s.Nonempty,
These lemmas are useful when rewriting expressions produced by unfolding definitions that use max'/min' with non-canonical Nonempty proofs (e.g. divisor-ordering problems involving successive max' operations).
Lean4 / mathlib formalization
File FinsetMaxProofIrrel.lean (complete, no sorry):
import Mathlib.Data.Finset.Max
namespace Finset
variable {α : Type*} [LinearOrder α]
/-- `Finset.max'` does not depend on the choice of nonemptiness witness.
This is essentially proof irrelevance, but having it as a lemma is convenient for rewriting.
-/
theorem max'_eq_max' {s : Finset α} (h₁ h₂ : s.Nonempty) : s.max' h₁ = s.max' h₂ := by
classical
cases Subsingleton.elim h₁ h₂
rfl
/-- `Finset.min'` does not depend on the choice of nonemptiness witness. -/
theorem min'_eq_min' {s : Finset α} (h₁ h₂ : s.Nonempty) : s.min' h₁ = s.min' h₂ := by
classical
cases Subsingleton.elim h₁ h₂
rfl
end Finset
Compilation
$ cd /opt/lean/Math
$ lake env lean FinsetMaxProofIrrel.lean
# success