Lean4
/-- Extension for the `positivity` tactic: projection from `EReal` to `ℝ≥0∞`.
We show that `EReal.toENNReal x` is positive whenever `x` is positive,
and it is nonnegative otherwise.
We cannot deduce any corollaries from `x ≠ 0`, since `EReal.toENNReal x = 0` for `x < 0`.
-/
@[positivity EReal.toENNReal _]
def evalERealToENNReal : PositivityExt where
eval {u α} _zα _pα
e := do
match u, α, e with
| 0, ~q(ENNReal), ~q(EReal.toENNReal $a) =>
assertInstancesCommute
match ← core q(inferInstance) q(inferInstance) a with
| .positive pa =>
pure (.positive q(EReal.toENNReal_pos_iff.2 $pa))
| _ =>
pure (.nonnegative q(zero_le $e))
| _, _, _ =>
throwError"not EReal.toENNReal"