summaryrefslogtreecommitdiff
path: root/contrib/subtac/test/take.v
blob: 87ab47d63938984b9ac4b6cb633faa8486507305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(* -*- coq-prog-args: ("-emacs-U" "-debug") -*- *)
Require Import JMeq.
Require Import List.
Require Import Coq.subtac.Utils.

Set Implicit Arguments.

Program Fixpoint take (A : Set) (l : list A) (n : nat | n <= length l) { struct l } : { l' : list A | length l' = n } :=
  match n with
  | 0 => nil
  | S p => 
    match l with
    | cons hd tl => let rest := take tl p in cons hd rest
    | nil => !
    end
  end.

Require Import Omega.

Next Obligation.
  intros.
  simpl in l0.
  apply le_S_n ; exact l0.
Defined.

Next Obligation.
  intros.
  destruct_call take ; subtac_simpl.
Defined.

Next Obligation.
  intros.
  inversion l0.
Defined.