Lean4
/-- Extension for the `positivity` tactic: a square root is nonnegative, and is strictly positive if
its input is. -/
@[positivity √_]
def evalSqrt : PositivityExt where
eval {u α} _zα _pα
e := do
match u, α, e with
| 0, ~q(ℝ), ~q(√$a) =>
let ra ← catchNone <| core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(Real.sqrt_pos_of_pos $pa))
| _ =>
pure (.nonnegative q(Real.sqrt_nonneg $a))
| _, _, _ =>
throwError"not Real.sqrt"