aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/subtac/test/take.v
blob: 90ae8bae84b089a50ce02ae672157164e7cb5075 (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
(* -*- coq-prog-args: ("-emacs-U" "-debug") -*- *)
Require Import JMeq.
Require Import List.
Require Import Program.

Set Implicit Arguments.
Obligations Tactic := idtac.

Print cons.

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.
Solve All Obligations.
Next Obligation.
  destruct_call take ; program_simpl.
Defined.

Next Obligation.
  intros.
  inversion H.
Defined.