In fact, there is a much simpler solution. A fixadmits recursion (aka induction) on any subterm, and nat_rectadmits recursion on a direct subtopic of a nat. nat_rectit is determined by itself fix, but nat_indis only a special case nat_rect.
Definition nat_rect_2 (P : nat -> Type) (f1 : P 0) (f2 : P 1)
(f3 : forall n, P n -> P (S (S n))) : forall n, P n :=
fix nat_rect_2 n :=
match n with
| 0 => f1
| 1 => f2
| S (S m) => f3 m (nat_rect_2 m)
end.
user1861759