playground/coq/nth_tuple.v

26 lines
528 B
Coq

(*
https://coq.zulipchat.com/#narrow/stream/237977-Coq-users/topic/Project.20nth.20element.20of.20n-tuple
Soln by guillaume melquiond: https://www.lri.fr/~melquion/index.html.en
*)
Require Import List.
Definition nth_tup {l : list Type}:
forall (x:fold_right prod unit l) (n:nat), nth n l unit.
Proof.
induction l as [|A l IH].
- intros _ [|] ; exact tt.
- intros [a b] [|n].
exact a.
now apply IH.
Restart.
induction l.
- intros _ [|].
+ exact tt.
+ exact tt.
- intros H n.
apply (IHl H).
Defined.