Lean4
/-- A recursion principle for lists which separates the singleton case.
-/
@[elab_as_elim]
def twoStepInduction {motive : (l : List α) → Sort*} (nil : motive []) (singleton : ∀ x, motive [x])
(cons_cons : ∀ x y xs, motive xs → (∀ y, motive (y :: xs)) → motive (x :: y :: xs)) (l : List α) : motive l :=
match l with
| [] => nil
| [x] => singleton x
| x :: y :: xs =>
cons_cons x y xs (twoStepInduction nil singleton cons_cons xs)
(fun y => twoStepInduction nil singleton cons_cons (y :: xs))