Definition prod : forall (n : nat) (x : nat -> nat), nat.
intros.
induction n as [| n Hrecn].
exact 1.
exact (x n * Hrecn).
Defined.
Definition factorial (n : nat) : nat := prod n S.

Lemma sameProd :
forall (n : nat) (x1 x2 : nat -> nat),
(forall z : nat, z < n -> x1 z = x2 z) -> prod n x1 = prod n x2.