Debian Codegraph @

test-suite/success/bnet.v

raw
1 Set Printing All.
2 (* Set Typeclasses Debug Verbosity 2. *)
3
4 Create HintDb test discriminated.
5
6 Definition id {X} (x:X) := x.
7
8 Hint Transparent id : test.
9
10 Definition opq {X} (x:X) := x.
11
12 Hint Opaque opq : test.
13
14 Definition const {X} (x y : X) := x.
15
16 Hint Transparent const : test.
17
18 Class C {X:Type} (x : X) := MKC {}.
19
20 Module M1.
21 Definition f1 (_ : unit) := tt.
22 Hint Opaque f1 : test.
23
24 Definition C1 : C (fun x => f1 x) := MKC _ _.
25 Hint Resolve C1 : test.
26
27 Goal C (fun x => f1 x).
28 Proof.
29 Print HintDb test.
30 typeclasses eauto with test.
31 Qed.
32
33 Goal C (fun x => id (f1) x).
34 Proof.
35 Print HintDb test.
36 typeclasses eauto with test.
37 Qed.
38
39 Goal C (fun x => opq (f1) x).
40 Proof.
41 Print HintDb test.
42 Fail typeclasses eauto with test.
43 Abort.
44
45 Goal C f1.
46 Proof.
47 Print HintDb test.
48 typeclasses eauto with test.
49 Qed.
50 End M1.
51
52
53 Module M2.
54 Definition f2 (_ _ : unit) := tt.
55 Hint Opaque f2 : test.
56
57 Definition C2 : C (fun x y : unit => f2 x y) := MKC _ _.
58 Hint Resolve C2 : test.
59
60 Goal C (fun x y : unit => f2 x y).
61 Proof.
62 Print HintDb test.
63 typeclasses eauto with test.
64 Abort.
65
66 Goal C (fun x y : unit => id f2 x y).
67 Proof.
68 Print HintDb test.
69 typeclasses eauto with test.
70 Abort.
71
72 Goal C f2.
73 Proof.
74 Print HintDb test.
75 typeclasses eauto with test.
76 Abort.
77
78 Definition C2f : C (fun z x y : unit => f2 x y) := MKC _ _.
79 Hint Resolve C2f : test.
80
81 Goal C (fun z : unit => f2).
82 Proof.
83 Print HintDb test.
84 typeclasses eauto with test.
85 Abort.
86
87 End M2.
88
89 Module const.
90 Inductive option (X : Type) := None | Some (x : X).
91 Definition C_constant {X Y} (c : Y) : C (fun _ : X => c) := MKC _ _.
92 Hint Resolve C_constant : test.
93
94 Goal C (fun _ : nat => @None unit).
95 Proof.
96 Print HintDb test.
97 typeclasses eauto with test.
98 Qed.
99
100 End const.
101
102 Module PrimProjParamsNoArgs.
103 #[projections(primitive)]
104 Record r (dummy : unit) := v { f : unit }.
105 Hint Opaque f : test.
106
107 (* Proj hint, Proj goal *)
108 Module M1.
109 Definition C_pproj dummy : C (fun r : r dummy => r.(f _)) := MKC _ _.
110 Hint Resolve C_pproj : test.
111
112 Goal forall dummy, C (fun r : r dummy => r.(f _)).
113 Proof.
114 intros dummy.
115 Print HintDb test.
116 typeclasses eauto with test.
117 Qed.
118 End M1.
119
120 (* Proj hint, Compat constant goal *)
121 Module M2.
122 Definition C_pproj (dummy : unit) : C (fun r => f dummy r) := MKC _ _.
123 Hint Resolve C_pproj : test.
124
125 Goal forall dummy, C (fun r : r dummy => ltac:(exact (f dummy)) r).
126 Proof.
127 intros dummy.
128 Print HintDb test.
129 typeclasses eauto with test.
130 Qed.
131 End M2.
132
133 (* Compat constant hint, Proj goal *)
134 Module M3.
135 Definition C_pproj (dummy : unit) : C (fun r => ltac:(exact (f dummy)) r) := MKC _ _.
136 Hint Resolve C_pproj : test.
137
138 Goal forall dummy, C (fun r : r dummy => r.(f _ )).
139 Proof.
140 intros dummy.
141 Print HintDb test.
142 typeclasses eauto with test.
143 Qed.
144 End M3.
145
146 (* Compat constant hint, compat constant goal *)
147 Module M4.
148 Definition C_pproj (dummy : unit) : C (fun r => ltac:(exact (f dummy)) r) := MKC _ _.
149 Hint Resolve C_pproj : test.
150
151 Goal forall dummy, C (fun r => ltac:(exact (f dummy)) r).
152 Proof.
153 intros dummy.
154 Print HintDb test.
155 typeclasses eauto with test.
156 Qed.
157 End M4.
158 End PrimProjParamsNoArgs.
159
160 Module PrimProjParamsArgs.
161 #[projections(primitive)]
162 Record r (dummy : unit) := v { f : nat }.
163 Hint Opaque f : test.
164
165 Axiom (P : (unit -> unit -> unit -> nat) -> Prop).
166
167 Axiom (x : r tt).
168
169 (* Proj hint, Proj goal *)
170 Module M1.
171 Definition C_pproj : C (P (fun _ _ _ : unit => x.(f _))) := MKC _ _.
172 Hint Resolve C_pproj : test.
173 Goal C (P (fun _ _ _ : unit => x.(f _))).
174 Proof.
175 Print HintDb test.
176 typeclasses eauto with test.
177 Qed.
178 End M1.
179
180 (* Proj hint, Compat constant goal *)
181 Module M2.
182 Definition C_pproj : C (P (fun _ _ _ : unit => x.(f _))) := MKC _ _.
183 Hint Resolve C_pproj : test.
184 Goal C (P (fun _ _ _ : unit => ltac:(exact (f _ x)))).
185 Proof.
186 Print HintDb test.
187 typeclasses eauto with test.
188 Qed.
189 End M2.
190
191 (* Compat constant hint, Proj goal *)
192 Module M3.
193 Definition C_pproj : C (P (fun _ _ _ : unit => ltac:(exact (f _ x)))) := MKC _ _.
194 Hint Resolve C_pproj : test.
195 Goal C (P (fun _ _ _ : unit => x.(f _))).
196 Proof.
197 Print HintDb test.
198 typeclasses eauto with test.
199 Qed.
200 End M3.
201
202 (* Compat constant hint, compat constant goal *)
203 Module M4.
204 Definition C_pproj : C (P (fun _ _ _ : unit => ltac:(exact (f _ x)))) := MKC _ _.
205 Hint Resolve C_pproj : test.
206 Goal C (P (fun _ _ _ : unit => ltac:(exact (f _ x)))).
207 Proof.
208 Print HintDb test.
209 typeclasses eauto with test.
210 Qed.
211 End M4.
212 End PrimProjParamsArgs.
213
214 Module Negative.
215 (* To test the discriminating power of the bnet we construct a hint that
216 always succeeds. Then, we manually restrict it to interesting patterns and
217 ensure that the application is never attempted by asserting that the
218 overall search fails. *)
219
220 Definition CA {X} x : @C X x := MKC _ _.
221
222
223 Definition f (_ _ : unit) := tt.
224 Definition g (_ _ : unit) := tt.
225 Hint Opaque f g : test.
226
227 Module M1.
228 Hint Resolve CA | (@C _ (fun x => f x)) : test.
229
230 Goal C (fun x => g x).
231 Proof.
232 Fail typeclasses eauto with test.
233 Abort.
234 End M1.
235
236 Module M1i.
237 Hint Resolve CA | (@C _ (fun x => f (id x))) : test.
238
239 Goal C (fun x => g x).
240 Proof.
241 Fail typeclasses eauto with test.
242 Abort.
243 End M1i.
244
245 Module M1o.
246 Hint Resolve CA | (@C _ (fun x => f (opq x))) : test.
247
248 Goal C (fun x => g x).
249 Proof.
250 Fail typeclasses eauto with test.
251 Abort.
252 End M1o.
253 End Negative.