package coq

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file g_ring.ml

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457

# 11 "plugins/ring/g_ring.mlg"
 

open Ltac_plugin
open Pp
open Util
open Ring_ast
open Ring
open Stdarg
open Tacarg
open Pcoq.Constr
open Pltac



let __coq_plugin_name = "coq-core.plugins.ring"
let _ = Mltop.add_known_module __coq_plugin_name
let () = Tacentries.tactic_extend __coq_plugin_name "protect_fv" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("protect_fv", Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_string), 
                                                              Tacentries.TyIdent ("in", 
                                                              Tacentries.TyArg (
                                                              Extend.TUentry (Genarg.get_arg_tag wit_ident), 
                                                              Tacentries.TyNil)))), 
           (fun map id ist -> 
# 29 "plugins/ring/g_ring.mlg"
      protect_tac_in map id 
           )));
         (Tacentries.TyML (Tacentries.TyIdent ("protect_fv", Tacentries.TyArg (
                                                             Extend.TUentry (Genarg.get_arg_tag wit_string), 
                                                             Tacentries.TyNil)), 
          (fun map ist -> 
# 31 "plugins/ring/g_ring.mlg"
      protect_tac map 
          )))]


# 34 "plugins/ring/g_ring.mlg"
 

open Pptactic
open Ppconstr

let pr_ring_mod env sigma = function
  | Ring_kind (Computational eq_test) -> str "decidable" ++ pr_arg (pr_constr_expr env sigma) eq_test
  | Ring_kind Abstract ->  str "abstract"
  | Ring_kind (Morphism morph) -> str "morphism" ++ pr_arg (pr_constr_expr env sigma) morph
  | Const_tac (CstTac cst_tac) -> str "constants" ++ spc () ++ str "[" ++ pr_raw_tactic env sigma cst_tac ++ str "]"
  | Const_tac (Closed l) -> str "closed" ++ spc () ++ str "[" ++ prlist_with_sep spc pr_qualid l ++ str "]"
  | Pre_tac t -> str "preprocess" ++ spc () ++ str "[" ++ pr_raw_tactic env sigma t ++ str "]"
  | Post_tac t -> str "postprocess" ++ spc () ++ str "[" ++ pr_raw_tactic env sigma t ++ str "]"
  | Setoid(sth,ext) -> str "setoid" ++ pr_arg (pr_constr_expr env sigma) sth ++ pr_arg (pr_constr_expr env sigma) ext
  | Pow_spec(Closed l,spec) -> str "power_tac" ++ pr_arg (pr_constr_expr env sigma) spec ++ spc () ++ str "[" ++ prlist_with_sep spc pr_qualid l ++ str "]"
  | Pow_spec(CstTac cst_tac,spec) -> str "power_tac" ++ pr_arg (pr_constr_expr env sigma) spec ++ spc () ++ str "[" ++ pr_raw_tactic env sigma cst_tac ++ str "]"
  | Sign_spec t -> str "sign" ++ pr_arg (pr_constr_expr env sigma) t
  | Div_spec t -> str "div" ++ pr_arg (pr_constr_expr env sigma) t



let (wit_ring_mod, ring_mod) = Vernacextend.vernac_argument_extend ~name:"ring_mod" 
                               {
                               Vernacextend.arg_parsing = Vernacextend.Arg_rules (
                                                          [(Pcoq.Production.make
                                                            (Pcoq.Rule.next 
                                                            (Pcoq.Rule.next 
                                                            (Pcoq.Rule.stop)
                                                            ((Pcoq.Symbol.token (CLexer.terminal "div"))))
                                                            ((Pcoq.Symbol.nterm constr)))
                                                            (fun div_spec _
                                                            loc -> 
# 70 "plugins/ring/g_ring.mlg"
                                    Div_spec div_spec 
                                                                   ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "power_tac"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.nterm tactic)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ cst_tac _
                                                           pow_spec _ loc ->
                                                           
# 69 "plugins/ring/g_ring.mlg"
             Pow_spec (CstTac cst_tac, pow_spec) 
                                                           ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "power"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.list1 ((Pcoq.Symbol.nterm global)))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ l _
                                                           pow_spec _ loc ->
                                                           
# 67 "plugins/ring/g_ring.mlg"
             Pow_spec (Closed l, pow_spec) 
                                                           ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "sign"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           (fun sign_spec _
                                                           loc -> 
# 65 "plugins/ring/g_ring.mlg"
                                      Sign_spec sign_spec 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "setoid"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           (fun ext sth _
                                                           loc -> 
# 64 "plugins/ring/g_ring.mlg"
                                              Setoid(sth,ext) 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "postprocess"))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.nterm tactic)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ post _ _
                                                           loc -> 
# 63 "plugins/ring/g_ring.mlg"
                                                Post_tac post 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "preprocess"))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.nterm tactic)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ pre _ _
                                                           loc -> 
# 62 "plugins/ring/g_ring.mlg"
                                              Pre_tac pre 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "closed"))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.list1 ((Pcoq.Symbol.nterm global)))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ l _ _
                                                           loc -> 
# 61 "plugins/ring/g_ring.mlg"
                                                Const_tac(Closed l) 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "constants"))))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "["))))
                                                           ((Pcoq.Symbol.nterm tactic)))
                                                           ((Pcoq.Symbol.token (CLexer.terminal "]"))))
                                                           (fun _ cst_tac _ _
                                                           loc -> 
# 60 "plugins/ring/g_ring.mlg"
                                                 Const_tac(CstTac cst_tac) 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "morphism"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           (fun morph _
                                                           loc -> 
# 59 "plugins/ring/g_ring.mlg"
                                      Ring_kind(Morphism morph) 
                                                                  ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "abstract"))))
                                                           (fun _ loc -> 
# 58 "plugins/ring/g_ring.mlg"
                        Ring_kind Abstract 
                                                                    ));
                                                          (Pcoq.Production.make
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.next 
                                                           (Pcoq.Rule.stop)
                                                           ((Pcoq.Symbol.token (CLexer.terminal "decidable"))))
                                                           ((Pcoq.Symbol.nterm constr)))
                                                           (fun eq_test _
                                                           loc -> 
# 57 "plugins/ring/g_ring.mlg"
                                         Ring_kind(Computational eq_test) 
                                                                  ))]);
                               Vernacextend.arg_printer = fun env sigma -> 
                               
# 56 "plugins/ring/g_ring.mlg"
               pr_ring_mod env sigma 
                               ;
                               }
let _ = (wit_ring_mod, ring_mod)


# 73 "plugins/ring/g_ring.mlg"
 

let pr_ring_mods env sigma l = surround (prlist_with_sep pr_comma (pr_ring_mod env sigma) l)



let (wit_ring_mods, ring_mods) = Vernacextend.vernac_argument_extend ~name:"ring_mods" 
                                 {
                                 Vernacextend.arg_parsing = Vernacextend.Arg_rules (
                                                            [(Pcoq.Production.make
                                                              (Pcoq.Rule.next 
                                                              (Pcoq.Rule.next 
                                                              (Pcoq.Rule.next 
                                                              (Pcoq.Rule.stop)
                                                              ((Pcoq.Symbol.token (CLexer.terminal "("))))
                                                              ((Pcoq.Symbol.list1sep ((Pcoq.Symbol.nterm ring_mod)) ((Pcoq.Symbol.rules 
                                                              [Pcoq.Rules.make 
                                                              (Pcoq.Rule.next_norec 
                                                              (Pcoq.Rule.stop)
                                                              ((Pcoq.Symbol.token (CLexer.terminal ","))))
                                                              (fun _ loc -> 
                                                              
# 0 ""
()
                                                              )])) false)))
                                                              ((Pcoq.Symbol.token (CLexer.terminal ")"))))
                                                              (fun _ mods _
                                                              loc -> 
                                                              
# 81 "plugins/ring/g_ring.mlg"
                                                     mods 
                                                              ))]);
                                 Vernacextend.arg_printer = fun env sigma -> 
                                 
# 80 "plugins/ring/g_ring.mlg"
               pr_ring_mods env sigma 
                                 ;
                                 }
let _ = (wit_ring_mods, ring_mods)

let () = Vernacextend.vernac_extend ~command:"AddSetoidRing" ~classifier:(fun _ -> Vernacextend.classify_as_sideeff) ?entry:None 
         [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Add", 
                                     Vernacextend.TyTerminal ("Ring", 
                                     Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref), 
                                     Vernacextend.TyTerminal (":", Vernacextend.TyNonTerminal (
                                                                   Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                                   Vernacextend.TyNonTerminal (
                                                                   Extend.TUopt (
                                                                   Extend.TUentry (Genarg.get_arg_tag wit_ring_mods)), 
                                                                   Vernacextend.TyNil)))))), 
         (let coqpp_body id t l
         () = Vernacextend.vtdefault (fun () -> 
# 86 "plugins/ring/g_ring.mlg"
      add_theory id.CAst.v t (Option.default [] l) 
              ) in fun id
         t l ?loc ~atts () -> coqpp_body id t l
         (Attributes.unsupported_attributes atts)), None));
         (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Print", 
                                    Vernacextend.TyTerminal ("Rings", 
                                    Vernacextend.TyNil)), (let coqpp_body () = 
                                                          Vernacextend.vtdefault (fun () -> 
                                                          
# 87 "plugins/ring/g_ring.mlg"
                                                                  
    print_rings ()
  
                                                          ) in fun ?loc ~atts ()
                                                          -> coqpp_body (Attributes.unsupported_attributes atts)), Some 
         
# 87 "plugins/ring/g_ring.mlg"
                             Vernacextend.classify_as_query 
         ))]

let () = Tacentries.tactic_extend __coq_plugin_name "ring_lookup" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("ring_lookup", Tacentries.TyArg (
                                                               Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 0), 
                                                               Tacentries.TyIdent ("[", 
                                                               Tacentries.TyArg (
                                                               Extend.TUlist0 (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_constr)), 
                                                               Tacentries.TyIdent ("]", 
                                                               Tacentries.TyArg (
                                                               Extend.TUlist1 (
                                                               Extend.TUentry (Genarg.get_arg_tag wit_constr)), 
                                                               Tacentries.TyNil)))))), 
           (fun f lH lrt ist -> 
# 94 "plugins/ring/g_ring.mlg"
      let (t,lr) = List.sep_last lrt in ring_lookup f lH lr t 
           )))]


# 97 "plugins/ring/g_ring.mlg"
 

let pr_field_mod env sigma = function
  | Ring_mod m -> pr_ring_mod env sigma m
  | Inject inj -> str "completeness" ++ pr_arg (pr_constr_expr env sigma) inj



let (wit_field_mod, field_mod) = Vernacextend.vernac_argument_extend ~name:"field_mod" 
                                 {
                                 Vernacextend.arg_parsing = Vernacextend.Arg_rules (
                                                            [(Pcoq.Production.make
                                                              (Pcoq.Rule.next 
                                                              (Pcoq.Rule.next 
                                                              (Pcoq.Rule.stop)
                                                              ((Pcoq.Symbol.token (CLexer.terminal "completeness"))))
                                                              ((Pcoq.Symbol.nterm constr)))
                                                              (fun inj _
                                                              loc -> 
                                                              
# 108 "plugins/ring/g_ring.mlg"
                                        Inject inj 
                                                              ));
                                                            (Pcoq.Production.make
                                                             (Pcoq.Rule.next 
                                                             (Pcoq.Rule.stop)
                                                             ((Pcoq.Symbol.nterm ring_mod)))
                                                             (fun m loc -> 
# 107 "plugins/ring/g_ring.mlg"
                         Ring_mod m 
                                                                    ))]);
                                 Vernacextend.arg_printer = fun env sigma -> 
                                 
# 106 "plugins/ring/g_ring.mlg"
               pr_field_mod env sigma 
                                 ;
                                 }
let _ = (wit_field_mod, field_mod)


# 111 "plugins/ring/g_ring.mlg"
 

let pr_field_mods env sigma l = surround (prlist_with_sep pr_comma (pr_field_mod env sigma) l)



let (wit_field_mods, field_mods) = Vernacextend.vernac_argument_extend ~name:"field_mods" 
                                   {
                                   Vernacextend.arg_parsing = Vernacextend.Arg_rules (
                                                              [(Pcoq.Production.make
                                                                (Pcoq.Rule.next 
                                                                (Pcoq.Rule.next 
                                                                (Pcoq.Rule.next 
                                                                (Pcoq.Rule.stop)
                                                                ((Pcoq.Symbol.token (CLexer.terminal "("))))
                                                                ((Pcoq.Symbol.list1sep ((Pcoq.Symbol.nterm field_mod)) ((Pcoq.Symbol.rules 
                                                                [Pcoq.Rules.make 
                                                                (Pcoq.Rule.next_norec 
                                                                (Pcoq.Rule.stop)
                                                                ((Pcoq.Symbol.token (CLexer.terminal ","))))
                                                                (fun _ loc ->
                                                                
# 0 ""
()
                                                                )])) false)))
                                                                ((Pcoq.Symbol.token (CLexer.terminal ")"))))
                                                                (fun _ mods _
                                                                loc -> 
                                                                
# 119 "plugins/ring/g_ring.mlg"
                                                      mods 
                                                                ))]);
                                   Vernacextend.arg_printer = fun env sigma -> 
                                   
# 118 "plugins/ring/g_ring.mlg"
               pr_field_mods env sigma 
                                   ;
                                   }
let _ = (wit_field_mods, field_mods)

let () = Vernacextend.vernac_extend ~command:"AddSetoidField" ~classifier:(fun _ -> Vernacextend.classify_as_sideeff) ?entry:None 
         [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Add", 
                                     Vernacextend.TyTerminal ("Field", 
                                     Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_identref), 
                                     Vernacextend.TyTerminal (":", Vernacextend.TyNonTerminal (
                                                                   Extend.TUentry (Genarg.get_arg_tag wit_constr), 
                                                                   Vernacextend.TyNonTerminal (
                                                                   Extend.TUopt (
                                                                   Extend.TUentry (Genarg.get_arg_tag wit_field_mods)), 
                                                                   Vernacextend.TyNil)))))), 
         (let coqpp_body id t l
         () = Vernacextend.vtdefault (fun () -> 
# 124 "plugins/ring/g_ring.mlg"
    let l = match l with None -> [] | Some l -> l in add_field_theory id.CAst.v t l 
              ) in fun id
         t l ?loc ~atts () -> coqpp_body id t l
         (Attributes.unsupported_attributes atts)), None));
         (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Print", 
                                    Vernacextend.TyTerminal ("Fields", 
                                    Vernacextend.TyNil)), (let coqpp_body () = 
                                                          Vernacextend.vtdefault (fun () -> 
                                                          
# 125 "plugins/ring/g_ring.mlg"
                                                               
    print_fields ()
  
                                                          ) in fun ?loc ~atts ()
                                                          -> coqpp_body (Attributes.unsupported_attributes atts)), Some 
         
# 125 "plugins/ring/g_ring.mlg"
                           Vernacextend.classify_as_query
         ))]

let () = Tacentries.tactic_extend __coq_plugin_name "field_lookup" ~level:0 
         [(Tacentries.TyML (Tacentries.TyIdent ("field_lookup", Tacentries.TyArg (
                                                                Extend.TUentry (Genarg.get_arg_tag wit_tactic), 
                                                                Tacentries.TyIdent ("[", 
                                                                Tacentries.TyArg (
                                                                Extend.TUlist0 (
                                                                Extend.TUentry (Genarg.get_arg_tag wit_constr)), 
                                                                Tacentries.TyIdent ("]", 
                                                                Tacentries.TyArg (
                                                                Extend.TUlist1 (
                                                                Extend.TUentry (Genarg.get_arg_tag wit_constr)), 
                                                                Tacentries.TyNil)))))), 
           (fun f lH lt ist -> 
# 132 "plugins/ring/g_ring.mlg"
        let (t,l) = List.sep_last lt in field_lookup f lH l t 
           )))]

OCaml

Innovation. Community. Security.