AFTD Auto-Formalizing Theoretical Domains

multiset_max

def

The maximum element of a multiset of natural numbers s, defined as 0 if s is empty.

Statement

def multiset_max (s : Multiset ℕ) : ℕ
Defined in
scout/2611-15780-multiple-choice-knapsack-with-small-items.md:204
Verified
14 Nov 2026
Axioms
none listed

Read back from the Lean

multiset_max is defined as a function taking a multiset of natural numbers s : Multiset ℕ and returning a natural number, specifically the supremum of the identity function over the finset of elements in s (s.toFinset.sup id). For a nonempty multiset, this is the maximum element of s; for the empty multiset, this evaluates to 0.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

Lean source view module on GitHub

/-- The maximum element of a multiset of natural numbers, or 0 if empty. -/
def multiset_max (s : Multiset ℕ) : ℕ := s.toFinset.sup id
See it in the graphDiscuss this resultChallenge it