Debian Codegraph @

test-suite/success/TypeclassesOpaque.v

raw
1
2 (** Testing the Typeclasses Opaque hints. We create two identical typeclasses [P] and [Q] and compare the behaviour of Typeclasses Opaque and Hint Opaque. They should be the same. *)
3
4 Axiom A : Type.
5 Axiom P : A -> Type.
6 Axiom Q : A -> Type.
7
8 Existing Class P.
9 Existing Class Q.
10
11 Axiom a : A.
12 Axiom pa : P a.
13 Axiom qa : Q a.
14 #[local] Existing Instance pa.
15 #[local] Existing Instance qa.
16
17 Definition b := a.
18 Definition c := a.
19
20 (** b is transparent so typeclass search should find it. *)
21
22 Goal P b.
23 Proof.
24 Succeed typeclasses eauto.
25 Abort.
26
27 (** c is transparent so typeclass search should find it. *)
28
29 Goal Q c.
30 Proof.
31 Succeed typeclasses eauto.
32 Abort.
33
34 (** Creating a local hint in a module or a section *)
35 Section Foo.
36 #[local] Hint Opaque b : typeclass_instances.
37 #[local] Typeclasses Opaque c.
38 End Foo.
39
40 (** Closing the module/section should get rid of the hint, so we expect the same behaviour as before. *)
41
42 (** b is transparent so typeclass search should find it. *)
43
44 Goal P b.
45 Proof.
46 Succeed typeclasses eauto.
47 Abort.
48
49 (** c is transparent so typeclass search should find it. *)
50
51 Goal Q c.
52 Proof.
53 Succeed typeclasses eauto.
54 Abort.
55
56 (** Now setting the locality as export *)
57 Module Foo.
58 #[export] Hint Opaque b : typeclass_instances.
59 #[export] Typeclasses Opaque c.
60 (** Things should fail inside *)
61
62 Goal P b.
63 Proof.
64 Fail typeclasses eauto.
65 Abort.
66 Goal Q c.
67 Proof.
68 Fail typeclasses eauto.
69 Abort.
70 End Foo.
71
72 (** But succeed outside *)
73
74 Goal P b.
75 Proof.
76 Succeed typeclasses eauto.
77 Abort.
78 Goal Q c.
79 Proof.
80 Succeed typeclasses eauto.
81 Abort.
82
83 (** Until of course we export the module *)
84 Export Foo.
85
86 Goal P b.
87 Proof.
88 Fail typeclasses eauto.
89 Abort.
90 Goal Q c.
91 Proof.
92 Fail typeclasses eauto.
93 Abort.
94
95 (** Finally we test the localities for this alias *)
96
97 Succeed #[local] Typeclasses Opaque b.
98 Succeed #[global] Typeclasses Opaque b.
99 Succeed #[export] Typeclasses Opaque b.
100 Succeed #[local] Typeclasses Transparent b.
101 Succeed #[global] Typeclasses Transparent b.
102 Succeed #[export] Typeclasses Transparent b.
103
104 Notation bar := (0 + 0).
105 Fail Local Typeclasses Transparent bar.
106
107 Notation baz := b.
108 Succeed Local Typeclasses Transparent baz.