Lean4
/-- Extension for the `positivity` tactic: cast from `ℝ≥0∞` to `EReal`. -/
@[positivity ENNReal.toEReal _]
def evalENNRealToEReal : PositivityExt where
eval {u α} _zα _pα
e := do
match u, α, e with
| 0, ~q(EReal), ~q(ENNReal.toEReal $a) =>
let ra ← core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(EReal.coe_ennreal_pos.2 $pa))
| .nonzero pa =>
pure (.positive q(EReal.coe_ennreal_pos_iff_ne_zero.2 $pa))
| _ =>
pure (.nonnegative q(EReal.coe_ennreal_nonneg $a))
| _, _, _ =>
throwError"not ENNReal.toEReal"