Debian Codegraph @

test-suite/success/PatternsInBinders.v

raw
1 (** The purpose of this file is to test functional properties of the
2 destructive patterns used in binders ([fun] and [forall]). *)
3
4
5 Definition swap {A B} '((x,y) : A*B) := (y,x).
6
7 (** Tests the use of patterns in [fun] and [Definition] *)
8 Section TestFun.
9
10 Variables A B : Type.
11
12 Goal forall (x:A) (y:B), swap (x,y) = (y,x).
13 Proof. reflexivity. Qed.
14
15 Goal forall u:A*B, swap (swap u) = u.
16 Proof. destruct u. reflexivity. Qed.
17
18 Goal @swap A B = fun '(x,y) => (y,x).
19 Proof. reflexivity. Qed.
20
21 End TestFun.
22
23
24 (** Tests the use of patterns in [forall] *)
25 Section TestForall.
26
27 Variables A B : Type.
28
29 Goal forall '((x,y) : A*B), swap (x,y) = (y,x).
30 Proof. intros [x y]. reflexivity. Qed.
31
32 Goal forall x0:A, exists '((x,y) : A*A), swap (x,y) = (x,y).
33 Proof.
34 intros x0.
35 exists (x0,x0).
36 reflexivity.
37 Qed.
38
39 End TestForall.
40
41
42
43 (** Tests the use of patterns in dependent definitions. *)
44
45 Section TestDependent.
46
47 Inductive Fin (n:nat) := Z : Fin n.
48
49 Definition F '(n,p) : Type := (Fin n * Fin p)%type.
50
51 Definition both_z '(n,p) : F (n,p) := (Z _,Z _).
52
53 End TestDependent.
54
55
56 (** Tests with a few other types just to make sure parsing is
57 robust. *)
58 Section TestExtra.
59
60 Definition proj_informative {A P} '(exist _ x _ : { x:A | P x }) : A := x.
61
62 Inductive Foo := Bar : nat -> bool -> unit -> nat -> Foo.
63
64 Definition foo '(Bar n b tt p) :=
65 if b then n+p else n-p.
66
67 End TestExtra.