@@ -309,22 +309,22 @@ and declare_module ?(continuation = ignore) ?name arity mb =
309309let command_variable ?(continuation = default_continuation) arity variable names =
310310 error (Pp. str " Cannot translate an axiom nor a variable. Please use the 'Parametricity Realizer' command." )
311311
312- let translateFullName arity (constant : Names.constant ) : string =
312+ let translateFullName ~ fullname arity (kername : Names.KerName.t ) : string =
313313 let nstr =
314314 (translate_string arity
315315 @@ Names.Label. to_string
316- @@ Names.Constant . label
317- @@ constant) in
316+ @@ Names.KerName . label
317+ @@ kername) in
318318 let pstr =
319319 (Names.ModPath. to_string
320320 @@ Names. modpath
321- @@ Names. canonical_con
322- @@ constant) in
321+ @@ kername) in
323322 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
325326
326-
327- let command_constant ?(continuation = default_continuation) arity constant names =
327+ let command_constant ?(continuation = default_continuation) ~fullname arity constant names =
328328 let poly, opaque =
329329 let cb = Global. lookup_constant constant in
330330 let open Declarations in
@@ -335,7 +335,10 @@ let command_constant ?(continuation = default_continuation) arity constant names
335335 (match cb.const_body with Def _ -> false | _ -> true )
336336 in
337337 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
339342 | Some name -> name
340343 in
341344 let kind = Decl_kinds. (Global , poly, DefinitionBody Definition ) in
@@ -346,45 +349,43 @@ let command_constant ?(continuation = default_continuation) arity constant names
346349 let constr = mkConstU (fst pconst, EInstance. make @@ snd pconst) in
347350 declare_abstraction ~continuation ~opaque ~kind arity (ref evd) env constr name
348351
349- let command_inductive ?(continuation = default_continuation) arity inductive names =
352+ let command_inductive ?(continuation = default_continuation) ~ fullname arity inductive names =
350353 let (evd, env) = Lemmas. get_current_context () in
351354 let evd, pind =
352355 Evd. (with_context_set univ_rigid evd (Universes. fresh_inductive_instance env inductive))
353356 in
354357 let name = match names with
355358 | None ->
356359 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
360362 @@ fst
361363 @@ fst
362364 @@ pind
363365 | Some name -> name
364366 in
365367 declare_inductive name ~continuation arity (ref evd) env pind
366368
367-
368369let command_constructor ?(continuation = default_continuation) arity gref names =
369370 let open Pp in
370371 error ((str " '" )
371372 ++ (Printer. pr_global gref)
372373 ++ (str " ' is a constructor. To generate its parametric translation, please translate its inductive first." ))
373374
374- let command_reference ?(continuation = default_continuation) arity gref names =
375+ let command_reference ?(continuation = default_continuation) ?( fullname = false ) arity gref names =
375376 check_nothing_ongoing () ;
376377 let open Globnames in
377378 match gref with
378379 | VarRef variable ->
379380 command_variable ~continuation arity variable names
380381 | ConstRef constant ->
381- command_constant ~continuation arity constant names
382+ command_constant ~continuation ~fullname arity constant names
382383 | IndRef inductive ->
383- command_inductive ~continuation arity inductive names
384+ command_inductive ~continuation ~fullname arity inductive names
384385 | ConstructRef constructor ->
385386 command_constructor ~continuation arity gref names
386387
387- let command_reference_recursive ?(continuation = default_continuation) arity gref =
388+ let command_reference_recursive ?(continuation = default_continuation) ?( fullname = false ) arity gref =
388389 let open Globnames in
389390 let gref= Globnames. canonical_gr gref in
390391 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
414415 (* DEBUG: *)
415416 let open Pp in msg_info (str " DepRefs:" );
416417 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 ()
418419
419420let translate_command arity c name =
420421 if ! ongoing_translation then error (Pp. str " On going translation." );
0 commit comments