Lean4
/-- Extension for the `positivity` tactic: `Int.floor` is nonnegative if its input is. -/
@[positivity ⌊_⌋]
def evalIntFloor : PositivityExt where
eval {u α} _zα _pα
e := do
match u, α, e with
| 0, ~q(ℤ), ~q(@Int.floor $α' $ir $io $j $a) =>
match ← core q(inferInstance) q(inferInstance) a with
| .positive pa =>
assertInstancesCommute
pure (.nonnegative q(int_floor_nonneg_of_pos (α := $α') $pa))
| .nonnegative pa =>
assertInstancesCommute
pure (.nonnegative q(int_floor_nonneg (α := $α') $pa))
| _ =>
pure .none
| _, _, _ =>
throwError"failed to match on Int.floor application"