@@ -897,13 +897,13 @@ let warns_of_options options = options.user_warns
897
897
[%% else ]
898
898
let warns_of_options options = options.user_warns |> Option. map UserWarn. with_empty_qf
899
899
[%% endif]
900
- let add_axiom_or_variable api id ty local options state =
900
+ let add_axiom_or_variable api id ty local_bkind options state =
901
901
let state, poly, cumul, udecl, _ = poly_cumul_udecl_variance_of_options state options in
902
902
let used = universes_of_term state ty in
903
903
let sigma = restricted_sigma_of used state in
904
904
if cumul then
905
905
err Pp. (str api ++ str" : unsupported attribute @udecl-cumul! or @univpoly-cumul!" );
906
- if poly && local then
906
+ if poly && Option. has_some local_bkind then
907
907
err Pp. (str api ++ str" : section variables cannot be universe polymorphic" );
908
908
let univs = UState. check_univ_decl (Evd. evar_universe_context sigma) udecl ~poly in
909
909
let kind = Decls. Logical in
@@ -914,14 +914,16 @@ let add_axiom_or_variable api id ty local options state =
914
914
if not (is_ground sigma ty) then
915
915
err Pp. (str" coq.env.add-const: the type must be ground. Did you forge to call coq.typecheck-indt-decl?" );
916
916
let gr, _ =
917
- if local then begin
918
- Dumpglob. dump_definition name true " var" ;
919
- comAssumption_declare_variable id Vernacexpr. NoCoercion ~kind (EConstr. to_constr sigma ty) ~univs ~impargs Glob_term. Explicit ~name
920
- end else begin
917
+ match local_bkind with
918
+ | Some implicit_kind -> begin
919
+ Dumpglob. dump_definition name true " var" ;
920
+ comAssumption_declare_variable id Vernacexpr. NoCoercion ~kind (EConstr. to_constr sigma ty) ~univs ~impargs implicit_kind ~name
921
+ end
922
+ | None -> begin
921
923
Dumpglob. dump_definition name false " ax" ;
922
924
comAssumption_declare_axiom Vernacexpr. NoCoercion ~local: Locality. ImportDefaultBehavior ~kind (EConstr. to_constr sigma ty)
923
925
~univs ~impargs ~inline: options.inline ~name ~id
924
- end
926
+ end
925
927
in
926
928
let ucsts = match univs with UState. Monomorphic_entry x , _ -> x | _ -> Univ.ContextSet. empty in
927
929
gr, ucsts
@@ -1960,7 +1962,7 @@ Supported attributes:
1960
1962
- @dropunivs! (default: false, drops all universe constraints from the store after the definition)
1961
1963
|} )))))),
1962
1964
(fun id body types opaque _ ~depth {options} _ -> grab_global_env__drop_sigma_univs_if_option_is_set options "coq.env.add-const" (fun state ->
1963
- let local = options .local = Some true in
1965
+ let local_bkind = if options .local = Some true then Some Glob_term. Explicit else None in
1964
1966
let state = minimize_universes state in
1965
1967
(* Maybe: UState.nf_universes on body and type * )
1966
1968
match body with
@@ -1970,7 +1972,7 @@ Supported attributes:
1970
1972
err Pp. (str "coq.env.add-const: both Type and Body are unspecified" )
1971
1973
| B. Given ty ->
1972
1974
warn_deprecated_add_axiom () ;
1973
- let gr , uctx = add_axiom_or_variable "coq.env.add-const" id ty local options state in
1975
+ let gr , uctx = add_axiom_or_variable "coq.env.add-const" id ty local_bkind options state in
1974
1976
uctx , state , !: (global_constant_of_globref gr ), []
1975
1977
end
1976
1978
| B. Given body ->
@@ -1993,7 +1995,7 @@ Supported attributes:
1993
1995
let state , poly , cumul , udecl , _ = poly_cumul_udecl_variance_of_options state options in
1994
1996
if cumul then err Pp. (str "coq.env.add-const: unsupported attribute @udecl-cumul! or @univpoly-cumul!" );
1995
1997
let kind = Decls. (IsDefinition Definition) in
1996
- let scope = if local
1998
+ let scope = if Option. has_some local_bkind
1997
1999
then Locality. Discharge
1998
2000
else Locality. (Global ImportDefaultBehavior) in
1999
2001
let cinfo = cinfo_make state types options .using ~name :(Id. of_string id ) ~typ :types ~impargs :[] () in
@@ -2035,22 +2037,29 @@ Supported attributes:
2035
2037
- @inline! (default: no inlining)
2036
2038
- @inline-at! N (default: no inlining)|} )))),
2037
2039
(fun id ty _ ~depth {options} _ -> grab_global_env "coq.env.add-axiom" (fun state ->
2038
- let gr , uctx = add_axiom_or_variable "coq.env.add-axiom" id ty false options state in
2040
+ let gr , uctx = add_axiom_or_variable "coq.env.add-axiom" id ty None options state in
2039
2041
uctx , state , !: (global_constant_of_globref gr ), [] ))),
2040
2042
DocAbove);
2041
2043
2042
- MLCode(Pred("coq.env.add-section-variable" ,
2044
+ MLCode(Pred("coq.env.add-section-variable-two " ,
2043
2045
In(id , "Name" ,
2046
+ In(implicit_kind , "I" ,
2044
2047
CIn(closed_ground_term , "Ty" ,
2045
2048
Out(constant , "C" ,
2046
2049
Full (global , {|Declare a new section variable: C gets a constant derived from Name
2047
2050
and the current module.
2048
- |} )))),
2049
- (fun id ty _ ~depth {options} _ -> grab_global_env_drop_sigma_keep_univs "coq.env.add-section-variable" (fun state ->
2050
- let gr , uctx = add_axiom_or_variable "coq.env.add-section-variable" id ty true options state in
2051
+ |} ))))) ,
2052
+ (fun id bkind ty _ ~depth {options} _ -> grab_global_env_drop_sigma_keep_univs "coq.env.add-section-variable" (fun state ->
2053
+ let gr , uctx = add_axiom_or_variable "coq.env.add-section-variable" id ty (Some bkind ) options state in
2051
2054
uctx , state , !: (global_constant_of_globref gr ), [] ))),
2052
2055
DocAbove);
2053
2056
2057
+ LPCode {|
2058
+ pred coq.env.add-section-variable i:id, i:term, o:constant.
2059
+ coq.env.add-section-variable Name Ty C :-
2060
+ coq.env.add-section-variable-two Name explicit Ty C.
2061
+ |} ;
2062
+
2054
2063
MLCode(Pred("coq.env.add-indt" ,
2055
2064
CIn(indt_decl_in , "Decl" ,
2056
2065
Out(inductive , "I" ,
0 commit comments