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