@@ -231,9 +231,10 @@ let univpoly_of ~poly ~cumulative =
231
231
| true , false -> Poly
232
232
| false , _ -> Mono
233
233
234
+ [%% if coq = " 8.19" || coq = " 8.20" ]
234
235
let of_coq_inductive_definition id =
235
236
let open Vernacentries.Preprocessed_Mind_decl in
236
- let { flags; typing_flags; private_ind; uniform; inductives } = id in
237
+ let { flags; typing_flags; private_ind; uniform; inductives } = id in
237
238
if List. length inductives != 1 then nYI " mutual inductives" ;
238
239
let inductive = List. hd inductives in
239
240
let (((name),(parameters,non_uniform_parameters),arity,constructors),notations) = inductive in
@@ -255,6 +256,34 @@ let univpoly_of ~poly ~cumulative =
255
256
constructors;
256
257
univpoly = univpoly_of ~poly ~cumulative
257
258
}
259
+ [%% else ]
260
+ let of_coq_inductive_definition id =
261
+ let open Vernacentries.Preprocessed_Mind_decl in
262
+ let { flags; udecl; typing_flags; private_ind; uniform; inductives } = id in
263
+ if List. length inductives != 1 then nYI " mutual inductives" ;
264
+ let inductive = List. hd inductives in
265
+ let (((name),(parameters,non_uniform_parameters),arity,constructors),notations) = inductive in
266
+ if notations != [] then CErrors. user_err Pp. (str " notations not supported" );
267
+ let name = [Names.Id. to_string name.CAst. v] in
268
+ let constructors =
269
+ List. map (function (Vernacexpr. (_ ,NoCoercion,NoInstance),c ) -> c
270
+ | _ -> CErrors. user_err Pp. (str " coercion and instance flags not supported" ))
271
+ constructors in
272
+ let { ComInductive. template; cumulative; poly; finite } = flags in
273
+ if template <> None then nYI " raw template polymorphic inductives" ;
274
+ if udecl <> None then nYI " raw universe polymorphic inductives with universe declaration" ;
275
+ {
276
+ finiteness = finite;
277
+ name;
278
+ parameters;
279
+ non_uniform_parameters;
280
+ arity;
281
+ constructors;
282
+ univpoly = univpoly_of ~poly ~cumulative
283
+ }
284
+ [%% endif]
285
+
286
+ [%% if coq = " 8.19" || coq = " 8.20" ]
258
287
let of_coq_record_definition id =
259
288
let open Vernacentries.Preprocessed_Mind_decl in
260
289
let { flags; primitive_proj; kind; records; } : record = id in
@@ -277,8 +306,32 @@ let univpoly_of ~poly ~cumulative =
277
306
constructor = Some idbuild;
278
307
fields = cfs;
279
308
univpoly = univpoly_of ~poly ~cumulative
280
- }
281
-
309
+ }
310
+ [%% else ]
311
+ let of_coq_record_definition id =
312
+ let open Vernacentries.Preprocessed_Mind_decl in
313
+ let { flags; udecl; primitive_proj; kind; records; } : record = id in
314
+ if List. length records != 1 then nYI " mutual inductives" ;
315
+ let open Record.Ast in
316
+ let { name; is_coercion; binders : Constrexpr .local_binder_expr list ; cfs; idbuild; sort; default_inhabitant_id : Names.Id .t option ; } = List. hd records in
317
+ if is_coercion = Vernacexpr. AddCoercion then CErrors. user_err Pp. (str " coercion flag not supported" );
318
+ let name = [Names.Id. to_string name.CAst. v] in
319
+ let sort = sort |> Option. map (fun sort ->
320
+ match sort.CAst. v with
321
+ | Constrexpr. CSort s -> s
322
+ | _ -> CErrors. user_err ?loc:sort.CAst. loc Pp. (str " only explicits sorts are supported" )) in
323
+ let { ComInductive. template; cumulative; poly; finite } = flags in
324
+ if template <> None then nYI " raw template polymorphic inductives" ;
325
+ if udecl <> None then nYI " raw universe polymorphic inductives with universe declaration" ;
326
+ {
327
+ name;
328
+ parameters = binders;
329
+ sort;
330
+ constructor = Some idbuild;
331
+ fields = cfs;
332
+ univpoly = univpoly_of ~poly ~cumulative
333
+ }
334
+ [%% endif]
282
335
let intern_record_decl glob_sign (it : raw_record_decl ) = glob_sign, it
283
336
284
337
[%% if coq = " 8.19" ]
@@ -996,6 +1049,15 @@ let handle_template_polymorphism = function
996
1049
| Some false -> Some false
997
1050
| Some true -> err Pp. (str " #[universes(template)] is not supported" )
998
1051
1052
+ [%% if coq = " 8.19" || coq = " 8.20" ]
1053
+ let handle_template_polymorphism flags =
1054
+ let open Vernacentries.Preprocessed_Mind_decl in
1055
+ { flags with template = handle_template_polymorphism flags.template }
1056
+ [%% else ]
1057
+ let handle_template_polymorphism flags =
1058
+ { flags with ComInductive. template = handle_template_polymorphism flags.ComInductive. template }
1059
+ [%% endif]
1060
+
999
1061
let in_elpi_cmd_synterp ~depth ?calldepth state (x : Cmd.raw ) =
1000
1062
let open Cmd in
1001
1063
match x with
@@ -1021,6 +1083,43 @@ let in_elpi_cmd_synterp ~depth ?calldepth state (x : Cmd.raw) =
1021
1083
| Term raw_term ->
1022
1084
state, E. mkApp trmc E. mkDiscard [] , []
1023
1085
1086
+ [%% if coq = " 8.19" || coq = " 8.20" ]
1087
+ let dest_rdecl raw_rdecl =
1088
+ let open Vernacentries.Preprocessed_Mind_decl in
1089
+ let { flags = ({ template; poly; cumulative; udecl; finite } as flags); primitive_proj; kind; records } = raw_rdecl in
1090
+ flags, udecl, primitive_proj, kind, records
1091
+ let interp_structure ~flags udecl kind ~primitive_proj x =
1092
+ let open Vernacentries.Preprocessed_Mind_decl in
1093
+ let { template; poly; cumulative; finite } = flags in
1094
+ Record. interp_structure ~template udecl kind ~cumulative ~poly ~primitive_proj finite x
1095
+ [%% else ]
1096
+ let dest_rdecl (raw_rdecl : Cmd.raw_record_decl ) =
1097
+ let open Vernacentries.Preprocessed_Mind_decl in
1098
+ let { flags; udecl; primitive_proj; kind; records } = raw_rdecl in
1099
+ flags, udecl, primitive_proj, kind, records
1100
+ let interp_structure ~flags udecl kind ~primitive_proj x =
1101
+ Record. interp_structure ~flags udecl kind ~primitive_proj x
1102
+ [%% endif]
1103
+
1104
+ [%% if coq = " 8.19" || coq = " 8.20" ]
1105
+ let dest_idecl raw_indt =
1106
+ let open Vernacentries.Preprocessed_Mind_decl in
1107
+ let { flags = ({ udecl } as flags); typing_flags; uniform; private_ind; inductives } = raw_indt in
1108
+ flags, udecl, typing_flags, uniform, private_ind, inductives
1109
+ let interp_mutual_inductive ~flags ~env ~uniform ~private_ind ?typing_flags ~udecl x =
1110
+ let open Vernacentries.Preprocessed_Mind_decl in
1111
+ let { template; poly; cumulative; finite } = flags in
1112
+ ComInductive. interp_mutual_inductive ~env ~template ~cumulative ~poly ~uniform ~private_ind ?typing_flags udecl x finite
1113
+ [%% else ]
1114
+ let dest_idecl raw_indt =
1115
+ let open Vernacentries.Preprocessed_Mind_decl in
1116
+ let { flags; udecl; typing_flags; uniform; private_ind; inductives } = raw_indt in
1117
+ flags, udecl, typing_flags, uniform, private_ind, inductives
1118
+ let interp_mutual_inductive ~flags ~env ~uniform ~private_ind ?typing_flags ~udecl x =
1119
+ ComInductive. interp_mutual_inductive ~env ~flags ~uniform ~private_ind ?typing_flags udecl x
1120
+ [%% endif]
1121
+
1122
+
1024
1123
let in_elpi_cmd ~depth ?calldepth coq_ctx state ~raw (x : Cmd.top ) =
1025
1124
let open Cmd in
1026
1125
let hyps = [] in
@@ -1032,12 +1131,11 @@ let in_elpi_cmd ~depth ?calldepth coq_ctx state ~raw (x : Cmd.top) =
1032
1131
let state, t = grecord2lp ~depth state glob_rdecl in
1033
1132
state, t, []
1034
1133
| RecordDecl (_ist ,(glob_sign ,raw_rdecl )) ->
1035
- let open Vernacentries.Preprocessed_Mind_decl in
1036
- let { flags = { template; poly; cumulative; udecl; finite }; primitive_proj; kind; records } = raw_rdecl in
1037
- let template = handle_template_polymorphism template in
1134
+ let flags, udecl, primitive_proj, kind, records = dest_rdecl raw_rdecl in
1135
+ let flags = handle_template_polymorphism flags in
1038
1136
(* Definitional type classes cannot be interpreted using this function (why?) *)
1039
1137
let kind = if kind = Vernacexpr. Class true then Vernacexpr. Class false else kind in
1040
- let e = Record. interp_structure ~template udecl kind ~cumulative ~poly ~ primitive_proj finite records in
1138
+ let e = interp_structure ~flags udecl kind ~primitive_proj records in
1041
1139
record_entry2lp ~depth coq_ctx E. no_constraints state ~loose_udecl: (udecl = None ) e
1042
1140
| IndtDecl (_ist ,(glob_sign ,raw_indt )) when raw ->
1043
1141
let raw_indt = of_coq_inductive_definition raw_indt in
@@ -1046,15 +1144,12 @@ let in_elpi_cmd ~depth ?calldepth coq_ctx state ~raw (x : Cmd.top) =
1046
1144
let state, t = ginductive2lp ~depth state glob_indt in
1047
1145
state, t, []
1048
1146
| IndtDecl (_ist ,(glob_sign ,raw_indt )) ->
1049
- let open Vernacentries.Preprocessed_Mind_decl in
1050
- let { flags = { template; poly; cumulative; udecl; finite }; typing_flags; uniform; private_ind; inductives } = raw_indt in
1051
- let template = handle_template_polymorphism template in
1147
+ let flags, udecl, typing_flags, uniform, private_ind, inductives = dest_idecl raw_indt in
1148
+ let flags = handle_template_polymorphism flags in
1052
1149
let e =
1053
1150
match inductives with
1054
1151
| [mind_w_not] ->
1055
- ComInductive. interp_mutual_inductive ~env: coq_ctx.env
1056
- ~template ~cumulative ~poly ~uniform ~private_ind ?typing_flags
1057
- udecl [mind_w_not] finite
1152
+ interp_mutual_inductive ~flags ~env: coq_ctx.env ~uniform ~private_ind ?typing_flags ~udecl [mind_w_not]
1058
1153
| _ -> nYI " (HOAS) mutual inductives"
1059
1154
in
1060
1155
inductive_entry2lp ~depth coq_ctx E. no_constraints state ~loose_udecl: (udecl = None ) e
0 commit comments