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