Fixpoint force_lengthn {A} n (xs: list A) (default: A) :=
match n, xs with
| O, _ => nil
| S n0, nil => default :: force_lengthn n0 nil default
| S n0, hd :: tl => hd :: force_lengthn n0 tl default
end.

Lemma force_lengthn_id: forall {A} n ct (d: A), length ct = n -> force_lengthn n ct d = ct.
Open Scope Z.