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