Lean4
/-- Decreasing induction: if `P (k+1)` implies `P k` for all `k < n`, then `P n` implies `P m` for
all `m ≤ n`.
Also works for functions to `Sort*`.
For a version also assuming `m ≤ k`, see `Nat.decreasingInduction'`. -/
@[elab_as_elim]
def decreasingInduction {n} {motive : (m : ℕ) → m ≤ n → Sort*}
(of_succ : ∀ k (h : k < n), motive (k + 1) h → motive k (le_of_succ_le h)) (self : motive n (Nat.le_refl _)) {m}
(mn : m ≤ n) : motive m mn := by
induction mn using leRec with
| refl => exact self
| @le_succ_of_le k _ ih => apply ih (fun i hi => of_succ i (le_succ_of_le hi)) (of_succ k (lt_succ_self _) self)