Debian Codegraph @

test-suite/success/primitive_tc.v

raw
1 Create HintDb test discriminated.
2
3 (* Testing that projections can be made hint opaque. *)
4 Module ProjOpaque.
5 #[projections(primitive)]
6 Record bla := { x : unit }.
7
8 Definition bli := {| x := tt |}.
9
10 Class C (p : unit) := {}.
11 Definition I : C (x bli) := Build_C _.
12
13 #[local] Hint Resolve I : test.
14 #[local] Hint Opaque x : test.
15
16 Goal C tt.
17 Proof.
18 Fail typeclasses eauto with test.
19 Abort.
20 End ProjOpaque.
21
22 (* Testing that compatibility constants are equated with their projections in
23 the bnet. *)
24 Module CompatConstants.
25 Class T (p : Prop) : Prop := {}.
26
27 Axiom prod : Prop -> Prop -> Prop.
28 Axiom T_prod : forall p1 p2, T p1 -> T p2 -> T (prod p1 p2).
29 Axiom T_True : T True.
30
31 Class F (f : unit -> Prop) : Prop := { F_T :: forall u, T (f u) }.
32
33 #[projections(primitive)]
34 Record R (useless : unit) : Type :=
35 { v : unit -> Prop;
36 v_F : F (v);
37 }.
38 Hint Opaque v : test.
39 Hint Resolve v_F F_T T_prod T_True : test.
40
41 (* Notation constant := (@v tt). *)
42
43 Goal forall (a : R tt) q, T (prod (v _ a q) (True)).
44 Proof.
45 intros a.
46 (* [v _ a] gets turned into its compatibility constant by the application
47 of [T_prod]. The application of [v_F] after [F_T] only works if the
48 bnet correctly equates the compatibility constant with the projection
49 used in the type and pattern of [v_F] *)
50 typeclasses eauto with test.
51 Qed.
52 End CompatConstants.
53
54 (* Testing that projection opacity settings are properly discharged at the end
55 of sections. *)
56 Module Sections.
57 #[local] Hint Constants Opaque : test.
58 #[local] Hint Projections Opaque : test.
59 Class C (u : unit) := {}.
60 Definition i : C tt := Build_C _.
61 #[global] Hint Resolve i : test.
62
63 Section S.
64 Context (P : Prop). (* Load bearing [Context] but content does not matter! *)
65 #[projections(primitive)]
66 Record r := R { v : unit; prf : P }. (* Load bearing use of the [Context] *)
67 #[global] Hint Transparent v : test.
68 Definition x (p: P) := {| v := tt; prf := p|}.
69 #[global] Hint Transparent x : test.
70 Print HintDb test. (* [v] is transparent *)
71 Goal forall p, C (v (x p)).
72 Proof. intros.
73 typeclasses eauto with test. (* [i] is a candidate, [v] must be transparent *)
74 Qed.
75 End S.
76 Print HintDb test. (* [v] is reportedly transparent *)
77 Goal forall P (p : P), C (v P (x P p)).
78 Proof. intros.
79 typeclasses eauto with test. (* This will fail if [Hint Transparent v] is improperly discharged. *)
80 Qed.
81 End Sections.
82
83 Module HintExtern.
84 #[projections(primitive)]
85 Record bi (x : True) : Type := BI {car : Type; foo : car}.
86 Axiom x : True.
87 Axiom PROP:bi x.
88 Inductive Fwd (P : car x PROP) : Prop := MKFWD.
89 Create HintDb db discriminated.
90 #[local] Hint Opaque foo : test.
91 Module ConstantPattern.
92 #[local] Hint Extern 0 (Fwd (@foo x PROP)) => constructor : test.
93 Goal Fwd (@foo x PROP).
94 Proof.
95 intros.
96 typeclasses eauto with test.
97 Qed.
98 End ConstantPattern.
99
100 Module ProjPattern.
101 #[local] Hint Extern 0 (Fwd (PROP.(@foo x))) => constructor : test.
102 Goal Fwd (@foo x PROP).
103 Proof.
104 intros.
105 typeclasses eauto with test.
106 Qed.
107 End ProjPattern.
108 End HintExtern.