@@ -309,22 +309,22 @@ and declare_module ?(continuation = ignore) ?name arity mb =
309
309
let command_variable ?(continuation = default_continuation) arity variable names =
310
310
error (Pp. str " Cannot translate an axiom nor a variable. Please use the 'Parametricity Realizer' command." )
311
311
312
- let translateFullName arity (constant : Names.constant ) : string =
312
+ let translateFullName ~ fullname arity (kername : Names.KerName.t ) : string =
313
313
let nstr =
314
314
(translate_string arity
315
315
@@ Names.Label. to_string
316
- @@ Names.Constant . label
317
- @@ constant) in
316
+ @@ Names.KerName . label
317
+ @@ kername) in
318
318
let pstr =
319
319
(Names.ModPath. to_string
320
320
@@ Names. modpath
321
- @@ Names. canonical_con
322
- @@ constant) in
321
+ @@ kername) in
323
322
let plstr = Str. split (Str. regexp (" \. " )) pstr in
324
- (String. concat " _o_" (plstr@ [nstr]))
323
+ if fullname then
324
+ (String. concat " _o_" (plstr@ [nstr]))
325
+ else nstr
325
326
326
-
327
- let command_constant ?(continuation = default_continuation) arity constant names =
327
+ let command_constant ?(continuation = default_continuation) ~fullname arity constant names =
328
328
let poly, opaque =
329
329
let cb = Global. lookup_constant constant in
330
330
let open Declarations in
@@ -335,7 +335,10 @@ let command_constant ?(continuation = default_continuation) arity constant names
335
335
(match cb.const_body with Def _ -> false | _ -> true )
336
336
in
337
337
let name = match names with
338
- | None -> Names. id_of_string (translateFullName arity constant)
338
+ | None -> Names. id_of_string
339
+ @@ translateFullName ~fullname arity
340
+ @@ Names.Constant. canonical
341
+ @@ constant
339
342
| Some name -> name
340
343
in
341
344
let kind = Decl_kinds. (Global , poly, DefinitionBody Definition ) in
@@ -346,45 +349,43 @@ let command_constant ?(continuation = default_continuation) arity constant names
346
349
let constr = mkConstU (fst pconst, EInstance. make @@ snd pconst) in
347
350
declare_abstraction ~continuation ~opaque ~kind arity (ref evd) env constr name
348
351
349
- let command_inductive ?(continuation = default_continuation) arity inductive names =
352
+ let command_inductive ?(continuation = default_continuation) ~ fullname arity inductive names =
350
353
let (evd, env) = Lemmas. get_current_context () in
351
354
let evd, pind =
352
355
Evd. (with_context_set univ_rigid evd (Universes. fresh_inductive_instance env inductive))
353
356
in
354
357
let name = match names with
355
358
| None ->
356
359
Names. id_of_string
357
- @@ translate_string arity
358
- @@ Names.Label. to_string
359
- @@ Names.MutInd. label
360
+ @@ translateFullName ~fullname arity
361
+ @@ Names.MutInd. canonical
360
362
@@ fst
361
363
@@ fst
362
364
@@ pind
363
365
| Some name -> name
364
366
in
365
367
declare_inductive name ~continuation arity (ref evd) env pind
366
368
367
-
368
369
let command_constructor ?(continuation = default_continuation) arity gref names =
369
370
let open Pp in
370
371
error ((str " '" )
371
372
++ (Printer. pr_global gref)
372
373
++ (str " ' is a constructor. To generate its parametric translation, please translate its inductive first." ))
373
374
374
- let command_reference ?(continuation = default_continuation) arity gref names =
375
+ let command_reference ?(continuation = default_continuation) ?( fullname = false ) arity gref names =
375
376
check_nothing_ongoing () ;
376
377
let open Globnames in
377
378
match gref with
378
379
| VarRef variable ->
379
380
command_variable ~continuation arity variable names
380
381
| ConstRef constant ->
381
- command_constant ~continuation arity constant names
382
+ command_constant ~continuation ~fullname arity constant names
382
383
| IndRef inductive ->
383
- command_inductive ~continuation arity inductive names
384
+ command_inductive ~continuation ~fullname arity inductive names
384
385
| ConstructRef constructor ->
385
386
command_constructor ~continuation arity gref names
386
387
387
- let command_reference_recursive ?(continuation = default_continuation) arity gref =
388
+ let command_reference_recursive ?(continuation = default_continuation) ?( fullname = false ) arity gref =
388
389
let open Globnames in
389
390
let gref= Globnames. canonical_gr gref in
390
391
let label = Names.Label. of_id (Nametab. basename_of_global gref) in
@@ -414,7 +415,7 @@ let command_reference_recursive ?(continuation = default_continuation) arity gre
414
415
(* DEBUG: *)
415
416
let open Pp in msg_info (str " DepRefs:" );
416
417
List. iter (fun x -> let open Pp in msg_info (Printer. pr_global x)) dep_refs;
417
- list_continuation continuation (fun continuation gref -> command_reference ~continuation arity gref None ) dep_refs ()
418
+ list_continuation continuation (fun continuation gref -> command_reference ~continuation ~fullname arity gref None ) dep_refs ()
418
419
419
420
let translate_command arity c name =
420
421
if ! ongoing_translation then error (Pp. str " On going translation." );
0 commit comments