List.nonzeroMinimum
, List.minNatAbs
, List.maxNatAbs
#
List.minNatAbs
computes the minimum non-zero absolute value of a List Int
.
This is not generally useful outside of the implementation of the omega
tactic,
so we keep it in the Lean/Elab/Tactic/Omega
directory
(although the definitions are in the List
namespace).
The minimum non-zero entry in a list of natural numbers, or zero if all entries are zero.
We completely characterize the function via
nonzeroMinimum_eq_zero_iff
and nonzeroMinimum_eq_nonzero_iff
below.
Equations
- xs.nonzeroMinimum = (List.filter (fun (x : Nat) => decide (x ≠ 0)) xs).minimum?.getD 0
Instances For
The minimum absolute value of a nonzero entry, or zero if all entries are zero.
We completely characterize the function via
minNatAbs_eq_zero_iff
and minNatAbs_eq_nonzero_iff
below.
Equations
- xs.minNatAbs = (List.map Int.natAbs xs).nonzeroMinimum
Instances For
The maximum absolute value in a list of integers.
Equations
- xs.maxNatAbs = (List.map Int.natAbs xs).maximum?.getD 0