@@ -1265,7 +1265,7 @@ let index_of_ind_arg sigma t =
1265
1265
*)
1266
1266
1267
1267
type eliminator =
1268
- | ElimConstant of ( Constant .t * EInstance .t )
1268
+ | ElimConstant of EConstr .constr * int option
1269
1269
(* Constant generated by a scheme function *)
1270
1270
| ElimClause of EConstr .constr with_bindings
1271
1271
(* Arbitrary expression provided by the user *)
@@ -1275,10 +1275,13 @@ let general_elim_clause0 with_evars flags (submetas, c, ty) elim =
1275
1275
let env = Proofview.Goal. env gl in
1276
1276
let sigma = Proofview.Goal. sigma gl in
1277
1277
let clause, bindings, index = match elim with
1278
- | ElimConstant cst ->
1279
- let elimc = mkConstU cst in
1278
+ | ElimConstant (elimc , i ) ->
1280
1279
let elimt = Retyping. get_type_of env sigma elimc in
1281
- let i = index_of_ind_arg sigma elimt in
1280
+ let elimt = Reductionops. whd_all env sigma elimt in
1281
+ let i = match i with
1282
+ | Some i -> i
1283
+ | None -> index_of_ind_arg sigma elimt
1284
+ in
1282
1285
(elimc, elimt), NoBindings , Some i
1283
1286
| ElimClause (elimc , lbindelimc ) ->
1284
1287
let elimt = Retyping. get_type_of env sigma elimc in
@@ -1293,13 +1296,18 @@ let general_elim_clause0 with_evars flags (submetas, c, ty) elim =
1293
1296
Clenv. res_pf elimclause ~with_evars ~with_classes: true ~flags
1294
1297
end
1295
1298
1296
- let general_elim_clause_in0 with_evars flags id (submetas , c , ty ) elim =
1299
+ let dbg = CDebug. create ~name: " general_elim" ()
1300
+
1301
+ let general_elim_clause_in0 with_evars flags id (submetas , c , ty ) elimc indarg =
1297
1302
Proofview.Goal. enter begin fun gl ->
1298
1303
let env = Proofview.Goal. env gl in
1299
1304
let sigma = Tacmach. project gl in
1300
- let elimc = mkConstU elim in
1301
1305
let elimt = Retyping. get_type_of env sigma elimc in
1302
- let i = index_of_ind_arg sigma elimt in
1306
+ let elimt = Reductionops. whd_all env sigma elimt in
1307
+ let i = match indarg with
1308
+ | Some i -> i
1309
+ | None -> index_of_ind_arg sigma elimt
1310
+ in
1303
1311
let elimclause = mk_clenv_from env sigma (elimc, elimt) in
1304
1312
let indmv =
1305
1313
try nth_arg (Some i) (clenv_arguments elimclause)
@@ -1314,6 +1322,8 @@ let general_elim_clause_in0 with_evars flags id (submetas, c, ty) elim =
1314
1322
let elimclause = clenv_instantiate ~flags ~submetas indmv elimclause (c, ty) in
1315
1323
let hyp = mkVar id in
1316
1324
let hyp_typ = Retyping. get_type_of env sigma hyp in
1325
+ let _ = dbg (fun () -> Printer. pr_etype_env env sigma elimc) in
1326
+ let _ = dbg (fun () -> Printer. pr_etype_env env sigma elimt) in
1317
1327
let elimclause =
1318
1328
try clenv_instantiate ~flags hypmv elimclause (hyp, hyp_typ)
1319
1329
with PretypeError (env ,evd ,NoOccurrenceFound (op ,_ )) ->
@@ -1343,14 +1353,10 @@ let general_elim with_evars clear_flag (c, lbindc) elim =
1343
1353
(apply_clear_request clear_flag (use_clear_hyp_by_default () ) id)
1344
1354
end
1345
1355
1346
- let general_elim_clause with_evars flags where arg elim =
1347
- Proofview. tclENV >> = fun env ->
1348
- Proofview. tclEVARMAP >> = fun sigma ->
1349
- let (sigma, (elim, u)) = Evd. fresh_constant_instance env sigma elim in
1350
- Proofview.Unsafe. tclEVARS sigma < *>
1356
+ let general_elim_clause with_evars flags where arg elimc indarg =
1351
1357
match where with
1352
- | None -> general_elim_clause0 with_evars flags arg (ElimConstant (elim, EInstance. make u ))
1353
- | Some id -> general_elim_clause_in0 with_evars flags id arg (elim, EInstance. make u)
1358
+ | None -> general_elim_clause0 with_evars flags arg (ElimConstant (elimc, indarg ))
1359
+ | Some id -> general_elim_clause_in0 with_evars flags id arg elimc indarg
1354
1360
1355
1361
(* Case analysis tactics *)
1356
1362
@@ -1425,7 +1431,7 @@ let default_elim with_evars clear_flag (c,_ as cx) =
1425
1431
let sigma, elim = find_ind_eliminator env sigma ind
1426
1432
(Retyping. get_sort_quality_of env sigma concl) in
1427
1433
Proofview. tclTHEN (Proofview.Unsafe. tclEVARS sigma)
1428
- (general_elim with_evars clear_flag cx (ElimConstant elim))
1434
+ (general_elim with_evars clear_flag cx (ElimConstant (mkConstU elim, None ) ))
1429
1435
end)
1430
1436
begin function (e , info ) -> match e with
1431
1437
| IsNonrec ->
@@ -2126,7 +2132,7 @@ let intro_decomp_eq ?loc l thin tac id =
2126
2132
| Some (eq ,u ,eq_args ) ->
2127
2133
! intro_decomp_eq_function
2128
2134
(fun n -> tac ((CAst. make id)::thin) (Some n) l)
2129
- (eq,t,eq_args) (c, t)
2135
+ (eq,u, t,eq_args) (c, t)
2130
2136
| None ->
2131
2137
let info = Exninfo. reify () in
2132
2138
Tacticals. tclZEROMSG ~info (str " Not a primitive equality here." )
0 commit comments