aboutsummaryrefslogtreecommitdiffhomepage
path: root/test-suite/output/PatternsInBinders.v
blob: 8911909abc299c0fb4debcaedf81054eb94f56c2 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(** The purpose of this file is to test printing of the destructive
    patterns used in binders ([fun] and [forall]). *)

Parameters (A B : Type) (P:A->Prop).

Definition swap '((x,y) : A*B) := (y,x).
Print swap.

Check fun '((x,y) : A*B) => (y,x).

Check forall '(x,y), swap (x,y) = (y,x).

Definition proj_informative '(exist _ x _ : { x:A | P x }) : A := x.
Print proj_informative.

Inductive Foo := Bar : nat -> bool -> unit -> nat -> Foo.
Definition foo '(Bar n b tt p) :=
  if b then n+p else n-p.
Print foo.

Definition baz '(Bar n1 b1 tt p1) '(Bar n2 b2 tt p2) := n1+p1.
Print baz.

(** Some test involving unicode noations. *)
Module WithUnicode.

  Require Import Coq.Unicode.Utf8.

  Check λ '((x,y) : A*B),  (y,x).
  Check ∀ '(x,y), swap (x,y) = (y,x).

End WithUnicode.


(** * Suboptimal printing *)

(** These tests show examples which expose the [let] introduced by
    the pattern notation in binders. *)

Module Suboptimal.

Definition swap {A B} '((x,y) : A*B) := (y,x).
Print swap.

Check forall (A B:Type) '((x,y) : A*B), swap (x,y) = (y,x).

Check exists '((x,y):A*A), swap (x,y) = (y,x).

Inductive Fin (n:nat) := Z : Fin n.
Definition F '(n,p) : Type := (Fin n * Fin p)%type.
Definition both_z '(n,p) : F (n,p) := (Z _,Z _).
Print both_z.

End Suboptimal.