| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
open Ltac_plugin |
| 14 |
open Util |
| 15 |
open Names |
| 16 |
open Constr |
| 17 |
open Context |
| 18 |
open Locus |
| 19 |
open Printer |
| 20 |
open Termops |
| 21 |
open Tacinterp |
| 22 |
|
| 23 |
open Ssrmatching_plugin |
| 24 |
open Ssrmatching |
| 25 |
|
| 26 |
open Ssrast |
| 27 |
open Ssrprinters |
| 28 |
open Ssrcommon |
| 29 |
open Proofview.Notations |
| 30 |
|
| 31 |
module ERelevance = EConstr.ERelevance |
| 32 |
|
| 33 |
let ssroldreworder = Summary.ref ~name:"SSR:oldreworder" false |
| 34 |
let () = |
| 35 |
Goptions.(declare_bool_option |
| 36 |
{ optstage = Summary.Stage.Interp; |
| 37 |
optkey = ["SsrOldRewriteGoalsOrder"]; |
| 38 |
optread = (fun _ -> !ssroldreworder); |
| 39 |
optdepr = None; |
| 40 |
optwrite = (fun b -> ssroldreworder := b) }) |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
let tacred_simpl env = |
| 47 |
let simpl_expr = |
| 48 |
Genredexpr.( |
| 49 |
Simpl(Redops.make_red_flag[FBeta;FMatch;FZeta;FDeltaBut []],None)) in |
| 50 |
let esimpl, _ = Redexpr.reduction_of_red_expr env simpl_expr in |
| 51 |
let esimpl e sigma c = |
| 52 |
let (_,t) = esimpl e sigma c in |
| 53 |
t in |
| 54 |
let simpl env sigma c = (esimpl env sigma c) in |
| 55 |
simpl |
| 56 |
|
| 57 |
let safe_simpltac n = |
| 58 |
if n = ~-1 then |
| 59 |
Proofview.Goal.enter begin fun gl -> |
| 60 |
let env = Proofview.Goal.env gl in |
| 61 |
let sigma = Proofview.Goal.sigma gl in |
| 62 |
let concl = Proofview.Goal.concl gl in |
| 63 |
let cl = red_safe (tacred_simpl env) env sigma concl in |
| 64 |
convert_concl_no_check cl |
| 65 |
end |
| 66 |
else |
| 67 |
ssr_n_tac "simpl" n |
| 68 |
|
| 69 |
let simpltac = function |
| 70 |
| Simpl n -> safe_simpltac n |
| 71 |
| Cut n -> Tacticals.tclTRY (donetac n) |
| 72 |
| SimplCut (n,m) -> Tacticals.tclTHEN (safe_simpltac m) (Tacticals.tclTRY (donetac n)) |
| 73 |
| Nop -> Tacticals.tclIDTAC |
| 74 |
|
| 75 |
let simpltac s = Proofview.Goal.enter (fun _ -> simpltac s) |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
let interp_congrarg_at env sigma ist ~concl n rf ty m = |
| 80 |
debug_ssr (fun () -> Pp.(str"===interp_congrarg_at===")); |
| 81 |
let congrn, _ = mkSsrRRef "nary_congruence" in |
| 82 |
let args1 = mkRnat n :: mkRHoles n @ [ty] in |
| 83 |
let args2 = mkRHoles (3 * n) in |
| 84 |
let rec loop i = |
| 85 |
if i + n > m then None else |
| 86 |
try |
| 87 |
let rt = mkRApp congrn (args1 @ mkRApp rf (mkRHoles i) :: args2) in |
| 88 |
debug_ssr (fun () -> Pp.(str"rt=" ++ Printer.pr_glob_constr_env env sigma rt)); |
| 89 |
Some (interp_refine env sigma ist ~concl rt) |
| 90 |
with e when CErrors.noncritical e -> loop (i + 1) in |
| 91 |
loop 0 |
| 92 |
|
| 93 |
let pattern_id = mk_internal_id "pattern value" |
| 94 |
|
| 95 |
let congrtac ((n, t), ty) ist = |
| 96 |
Proofview.Goal.enter begin fun gl -> |
| 97 |
let env = Proofview.Goal.env gl in |
| 98 |
let sigma = Proofview.Goal.sigma gl in |
| 99 |
let concl = Proofview.Goal.concl gl in |
| 100 |
debug_ssr (fun () -> (Pp.str"===congr===")); |
| 101 |
debug_ssr (fun () -> Pp.(str"concl=" ++ Printer.pr_econstr_env env sigma concl)); |
| 102 |
let nsigma, _ as it = interp_term env sigma ist t in |
| 103 |
let sigma = Evd.merge_universe_context sigma (Evd.ustate nsigma) in |
| 104 |
let f, _, _ucst = abs_evars env sigma it in |
| 105 |
let ist' = {ist with lfun = |
| 106 |
Id.Map.add pattern_id (Tacinterp.Value.of_constr f) Id.Map.empty } in |
| 107 |
let rf = mkRltacVar pattern_id in |
| 108 |
let m = pf_nbargs env sigma f in |
| 109 |
let cf = if n > 0 then |
| 110 |
match interp_congrarg_at env sigma ist' ~concl n rf ty m with |
| 111 |
| Some cf -> cf |
| 112 |
| None -> errorstrm Pp.(str "No " ++ int n ++ str "-congruence with " |
| 113 |
++ pr_term t) |
| 114 |
else let rec loop i = |
| 115 |
if i > m then errorstrm Pp.(str "No congruence with " ++ pr_term t) |
| 116 |
else match interp_congrarg_at env sigma ist' ~concl i rf ty m with |
| 117 |
| Some cf -> cf |
| 118 |
| None -> loop (i + 1) in |
| 119 |
loop 1 in |
| 120 |
Tacticals.(tclTHEN (refine_with cf) (tclTRY Tactics.reflexivity)) |
| 121 |
end |
| 122 |
|
| 123 |
let pf_typecheck t = |
| 124 |
Proofview.Goal.enter begin fun gl -> |
| 125 |
let sigma, _ = Typing.type_of (Proofview.Goal.env gl) (Proofview.Goal.sigma gl) t in |
| 126 |
Proofview.Unsafe.tclEVARS sigma |
| 127 |
end |
| 128 |
|
| 129 |
let tclMATCH_GOAL env sigma c t_ok t_fail = |
| 130 |
Proofview.Goal.enter begin fun gl -> |
| 131 |
match unify_HO env sigma (Proofview.Goal.concl gl) c with |
| 132 |
| sigma -> |
| 133 |
Proofview.Unsafe.tclEVARS sigma <*> |
| 134 |
convert_concl ~check:true (Reductionops.nf_evar sigma c) <*> t_ok sigma |
| 135 |
| exception exn when CErrors.noncritical exn -> t_fail () |
| 136 |
end |
| 137 |
|
| 138 |
let mk_evar env sigma ty = |
| 139 |
let sigma = Evd.create_evar_defs sigma in |
| 140 |
let (sigma, x) = Evarutil.new_evar env sigma ty in |
| 141 |
sigma, x |
| 142 |
|
| 143 |
let newssrcongrtac arg ist = |
| 144 |
let open Proofview.Notations in |
| 145 |
Proofview.Goal.enter_one ~__LOC__ begin fun _g -> |
| 146 |
(Ssrcommon.tacMK_SSR_CONST "ssr_congr_arrow") end >>= fun arr -> |
| 147 |
Proofview.Goal.enter begin fun gl -> |
| 148 |
let env = Proofview.Goal.env gl in |
| 149 |
let sigma = Proofview.Goal.sigma gl in |
| 150 |
let concl = Proofview.Goal.concl gl in |
| 151 |
debug_ssr (fun () -> Pp.(str"===newcongr===")); |
| 152 |
debug_ssr (fun () -> Pp.(str"concl=" ++ Printer.pr_econstr_env env sigma concl)); |
| 153 |
|
| 154 |
let fs sigma t = Reductionops.nf_evar sigma t in |
| 155 |
let ssr_congr lr = EConstr.mkApp (arr, lr) in |
| 156 |
let sigma, eq = Evd.fresh_global env sigma Rocqlib.(lib_ref "core.eq.type") in |
| 157 |
|
| 158 |
let equality, _, eq_args, sigma' = saturate env sigma eq 3 in |
| 159 |
Proofview.Unsafe.tclEVARS sigma <*> |
| 160 |
tclMATCH_GOAL env sigma' equality |
| 161 |
(fun sigma' -> |
| 162 |
let x = List.find_map_exn (fun (n, x, _) -> if n = 0 then Some x else None) eq_args in |
| 163 |
let ty = fs sigma' x in |
| 164 |
congrtac (arg, Detyping.detype Detyping.Now ~flags:(PrintingFlags.Detype.current()) env sigma ty) ist) |
| 165 |
(fun () -> |
| 166 |
try |
| 167 |
let sigma, t_lhs = Evarutil.new_Type sigma in |
| 168 |
let sigma, t_rhs = Evarutil.new_Type sigma in |
| 169 |
let sigma, lhs = mk_evar env sigma t_lhs in |
| 170 |
let sigma, rhs = mk_evar env sigma t_rhs in |
| 171 |
let arrow = EConstr.mkArrow lhs ERelevance.relevant (EConstr.Vars.lift 1 rhs) in |
| 172 |
tclMATCH_GOAL env sigma arrow |
| 173 |
(fun sigma -> |
| 174 |
let lr = [|fs sigma lhs;fs sigma rhs|] in |
| 175 |
let a = ssr_congr lr in |
| 176 |
Tacticals.tclTHENLIST [ pf_typecheck a |
| 177 |
; Tactics.apply a |
| 178 |
; congrtac (arg, mkRType) ist ]) |
| 179 |
(fun _ -> Tacticals.tclZEROMSG Pp.(str"Conclusion is not an equality nor an arrow")) |
| 180 |
with e when CErrors.noncritical e -> Proofview.tclZERO e |
| 181 |
) |
| 182 |
end |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
type ssrwkind = RWred of ssrsimpl | RWdef | RWeq |
| 189 |
type ssrrule = ssrwkind * ssrterm |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
type ssrrwarg = (ssrdir * ssrmult) * ((ssrdocc * rpattern option) * ssrrule) |
| 194 |
|
| 195 |
let notimes = 0 |
| 196 |
let nomult = 1, Once |
| 197 |
|
| 198 |
let mkocc occ = None, occ |
| 199 |
let noclr = mkocc None |
| 200 |
let mkclr clr = Some clr, None |
| 201 |
let nodocc = mkclr [] |
| 202 |
|
| 203 |
let is_rw_cut = function RWred (Cut _) -> true | _ -> false |
| 204 |
|
| 205 |
let mk_rwarg (d, (n, _ as m)) ((clr, occ as docc), rx) (rt, _ as r) : ssrrwarg = |
| 206 |
if rt <> RWeq then begin |
| 207 |
if rt = RWred Nop && not (m = nomult && occ = None && rx = None) |
| 208 |
&& (clr = None || clr = Some []) then |
| 209 |
anomaly "Improper rewrite clear switch"; |
| 210 |
if d = R2L && rt <> RWdef then |
| 211 |
CErrors.user_err (Pp.str "Right-to-left switch on simplification"); |
| 212 |
if n <> 1 && is_rw_cut rt then |
| 213 |
CErrors.user_err (Pp.str "Bad or useless multiplier"); |
| 214 |
if occ <> None && rx = None && rt <> RWdef then |
| 215 |
CErrors.user_err (Pp.str "Missing redex for simplification occurrence") |
| 216 |
end; (d, m), ((docc, rx), r) |
| 217 |
|
| 218 |
let norwmult = L2R, nomult |
| 219 |
let norwocc = noclr, None |
| 220 |
|
| 221 |
let simplintac occ rdx sim = |
| 222 |
let simptac m = |
| 223 |
Proofview.Goal.enter begin fun gl -> |
| 224 |
if m <> ~-1 then begin |
| 225 |
if rdx <> None then |
| 226 |
CErrors.user_err (Pp.str "Custom simpl tactic does not support patterns"); |
| 227 |
if occ <> None then |
| 228 |
CErrors.user_err (Pp.str "Custom simpl tactic does not support occurrence numbers"); |
| 229 |
simpltac (Simpl m) |
| 230 |
end else |
| 231 |
let sigma0, concl0, env0 = Proofview.Goal.(sigma gl, concl gl, env gl) in |
| 232 |
let simp env c _ _ = red_safe Tacred.simpl env sigma0 c in |
| 233 |
convert_concl_no_check (eval_pattern env0 sigma0 (Reductionops.nf_evar sigma0 concl0) rdx occ simp) |
| 234 |
end |
| 235 |
in |
| 236 |
let open Tacticals in |
| 237 |
Proofview.Goal.enter begin fun _ -> |
| 238 |
match sim with |
| 239 |
| Simpl m -> simptac m |
| 240 |
| SimplCut (n,m) -> tclTHEN (simptac m) (tclTRY (donetac n)) |
| 241 |
| _ -> simpltac sim |
| 242 |
end |
| 243 |
|
| 244 |
let rec get_evalref env sigma c = match EConstr.kind sigma c with |
| 245 |
| Var id -> Evaluable.EvalVarRef id |
| 246 |
| Const (k,_) -> Evaluable.EvalConstRef k |
| 247 |
| App (c', _) -> get_evalref env sigma c' |
| 248 |
| Cast (c', _, _) -> get_evalref env sigma c' |
| 249 |
| Proj(p,_,_) -> Evaluable.EvalProjectionRef (Names.Projection.repr p) |
| 250 |
| _ -> errorstrm Pp.(str "The term " ++ pr_econstr_pat (Global.env ()) sigma c ++ str " is not unfoldable") |
| 251 |
|
| 252 |
|
| 253 |
let strip_unfold_term _ ((sigma, t) as p) kt = match EConstr.kind sigma t with |
| 254 |
| App (f, a) when kt = NoFlag && Array.for_all (EConstr.isEvar sigma) a && EConstr.isConst sigma f -> |
| 255 |
(sigma, f), true |
| 256 |
| Const _ | Var _ -> p, true |
| 257 |
| Proj _ -> p, true |
| 258 |
| _ -> p, false |
| 259 |
|
| 260 |
let same_proj env sigma t1 t2 = |
| 261 |
match EConstr.kind sigma t1, EConstr.kind sigma t2 with |
| 262 |
| Proj(c1,_,_), Proj(c2, _, _) -> Environ.QProjection.equal env c1 c2 |
| 263 |
| _ -> false |
| 264 |
|
| 265 |
let classify_pattern p = match p with |
| 266 |
| None -> None |
| 267 |
| Some p -> redex_of_pattern p |
| 268 |
|
| 269 |
let unfoldintac occ rdx t (kt,_) = |
| 270 |
Proofview.Goal.enter begin fun gl -> |
| 271 |
let fs sigma x = Reductionops.nf_evar sigma x in |
| 272 |
let sigma0 = Proofview.Goal.sigma gl in |
| 273 |
let env0 = Proofview.Goal.env gl in |
| 274 |
let concl0 = Proofview.Goal.concl gl in |
| 275 |
let (sigma, t), const = strip_unfold_term env0 t kt in |
| 276 |
let body env t c = |
| 277 |
Tacred.unfoldn [AllOccurrences, get_evalref env sigma t] env sigma0 c in |
| 278 |
let easy = occ = None && rdx = None in |
| 279 |
let red_flags = if easy then RedFlags.betaiotazeta else RedFlags.betaiota in |
| 280 |
let beta env = Reductionops.clos_norm_flags red_flags env sigma0 in |
| 281 |
let unfold, conclude = match classify_pattern rdx with |
| 282 |
| None -> |
| 283 |
let rigid ev = Evd.mem sigma0 ev in |
| 284 |
let u = mk_tpattern env0 ~rigid t L2R t (empty_tpatterns (Evd.create_evar_defs sigma)) in |
| 285 |
let find_T, end_T = mk_tpattern_matcher ~raise_NoMatch:true sigma0 occ u in |
| 286 |
(fun env c _ h -> |
| 287 |
try find_T env c h ~k:(fun env c _ _ -> body env t c) |
| 288 |
with NoMatch when easy -> c |
| 289 |
| NoMatch | NoProgress -> errorstrm Pp.(str"No occurrence of " |
| 290 |
++ pr_econstr_pat env sigma0 t ++ spc() ++ str "in " ++ Printer.pr_econstr_env env sigma c)), |
| 291 |
(fun () -> try ignore @@ end_T () with |
| 292 |
| NoMatch when easy -> () |
| 293 |
| NoMatch -> anomaly "unfoldintac") |
| 294 |
| Some _ -> |
| 295 |
(fun env (c as orig_c) _ h -> |
| 296 |
if const then |
| 297 |
let rec aux c = |
| 298 |
match EConstr.kind sigma0 c with |
| 299 |
| Const _ when EConstr.eq_constr sigma0 c t -> body env t t |
| 300 |
| App (f,a) when EConstr.eq_constr sigma0 f t -> EConstr.mkApp (body env f f,a) |
| 301 |
| Proj _ when same_proj env sigma0 c t -> body env t c |
| 302 |
| _ -> |
| 303 |
let c = Reductionops.whd_betaiotazeta env sigma0 c in |
| 304 |
match EConstr.kind sigma0 c with |
| 305 |
| Const _ when EConstr.eq_constr sigma0 c t -> body env t t |
| 306 |
| App (f,a) when EConstr.eq_constr sigma0 f t -> EConstr.mkApp (body env f f,a) |
| 307 |
| Proj _ when same_proj env sigma0 c t -> body env t c |
| 308 |
| Const f -> aux (body env c c) |
| 309 |
| App (f, a) -> aux (EConstr.mkApp (body env f f, a)) |
| 310 |
| _ -> errorstrm Pp.(str "The term "++ pr_econstr_env env sigma orig_c ++ |
| 311 |
str" contains no " ++ pr_econstr_env env sigma t ++ str" even after unfolding") |
| 312 |
in aux c |
| 313 |
else |
| 314 |
try body env t (fs (unify_HO env sigma c t) t) |
| 315 |
with e when CErrors.noncritical e -> errorstrm Pp.(str "The term " ++ |
| 316 |
pr_econstr_env env sigma c ++spc()++ str "does not unify with " ++ pr_econstr_pat env sigma t)), |
| 317 |
ignore in |
| 318 |
let concl = beta env0 (eval_pattern env0 sigma0 concl0 rdx occ unfold) in |
| 319 |
let () = conclude () in |
| 320 |
convert_concl ~check:true concl |
| 321 |
end |
| 322 |
|
| 323 |
let foldtac occ rdx ft = |
| 324 |
Proofview.Goal.enter begin fun gl -> |
| 325 |
let sigma0 = Proofview.Goal.sigma gl in |
| 326 |
let env0 = Proofview.Goal.env gl in |
| 327 |
let concl0 = Proofview.Goal.concl gl in |
| 328 |
let sigma, t = ft in |
| 329 |
let t = Reductionops.nf_evar sigma t in |
| 330 |
let fold, conclude = match classify_pattern rdx with |
| 331 |
| None -> |
| 332 |
let ut = red_product_skip_id env0 sigma t in |
| 333 |
let rigid ev = Evd.mem sigma0 ev in |
| 334 |
let ut = mk_tpattern ~rigid env0 t L2R ut (empty_tpatterns (Evd.create_evar_defs sigma)) in |
| 335 |
let find_T, end_T = mk_tpattern_matcher ~raise_NoMatch:true sigma0 occ ut in |
| 336 |
(fun env c _ h -> try find_T env c h ~k:(fun env t _ _ -> t) with NoMatch ->c), |
| 337 |
(fun () -> try ignore @@ end_T () with NoMatch -> ()) |
| 338 |
| Some _ -> |
| 339 |
(fun env c _ h -> |
| 340 |
try |
| 341 |
let sigma = unify_HO env sigma c t in |
| 342 |
Reductionops.nf_evar sigma t |
| 343 |
with e when CErrors.noncritical e -> |
| 344 |
errorstrm Pp.(str "fold pattern " ++ pr_econstr_pat env sigma t ++ spc () |
| 345 |
++ str "does not match redex " ++ pr_econstr_pat env sigma c)), |
| 346 |
ignore in |
| 347 |
let concl = eval_pattern env0 sigma0 concl0 rdx occ fold in |
| 348 |
let () = conclude () in |
| 349 |
convert_concl ~check:true concl |
| 350 |
end |
| 351 |
|
| 352 |
let converse_dir = function L2R -> R2L | R2L -> L2R |
| 353 |
|
| 354 |
let rw_progress rhs lhs ise = not (EConstr.eq_constr ise lhs (Evarutil.nf_evar ise rhs)) |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
let rec strip_prod_expand_let sigma c = match EConstr.kind sigma c with |
| 363 |
| Prod (_, _, c') -> strip_prod_expand_let sigma c' |
| 364 |
| LetIn (_, v, _, c') -> strip_prod_expand_let sigma (EConstr.Vars.subst1 v c) |
| 365 |
| Cast (c', _, _) -> strip_prod_expand_let sigma c' |
| 366 |
| _ -> c |
| 367 |
|
| 368 |
let rule_id = mk_internal_id "rewrite rule" |
| 369 |
|
| 370 |
exception PRtype_error of (Environ.env * Evd.evar_map * Pretype_errors.pretype_error) option |
| 371 |
|
| 372 |
let id_map_redex _ sigma ~before:_ ~after = sigma, after |
| 373 |
|
| 374 |
|
| 375 |
ty |
| 376 |
s} |
| 377 |
ty |
| 378 |
ty |
| 379 |
_rdx |
| 380 |
|
| 381 |
|
| 382 |
let pirrel_rewrite ?(under=false) ?(map_redex=id_map_redex) pred rdx rdx_ty c_sort new_rdx dir (sigma, c) c_ty eq e_sort = |
| 383 |
let open Tacticals in |
| 384 |
Proofview.Goal.enter begin fun gl -> |
| 385 |
let env = Proofview.Goal.env gl in |
| 386 |
let beta = Reductionops.clos_norm_flags RedFlags.beta env sigma in |
| 387 |
let sigma, new_rdx = map_redex env sigma ~before:rdx ~after:new_rdx in |
| 388 |
|
| 389 |
let evty = beta (EConstr.Vars.subst1 new_rdx pred) in |
| 390 |
let typeclass_candidate = Typeclasses.is_maybe_class_type env sigma evty in |
| 391 |
let sigma, p = |
| 392 |
Evarutil.new_evar ~typeclass_candidate |
| 393 |
~relevance:(Retyping.relevance_of_type env sigma evty) |
| 394 |
env sigma evty |
| 395 |
in |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
let sigma, p, pred , elim = |
| 400 |
try |
| 401 |
let open EConstr in |
| 402 |
let sigma, pred , elim = |
| 403 |
let id = make_annot (Name pattern_id) ERelevance.relevant in |
| 404 |
let penv = EConstr.push_rel (LocalAssum (id, rdx_ty)) env in |
| 405 |
let pred = Vars.subst_var sigma pattern_id pred in |
| 406 |
let sigma, predty , p_sort = |
| 407 |
let sigma, predty = Typing.type_of penv sigma pred in |
| 408 |
let p_sort = Retyping.get_sort_of penv sigma pred in |
| 409 |
sigma, predty, p_sort in |
| 410 |
let (sigma, elim), _ = Equality.lookup_eq_eliminator_with_error env sigma eq ~dep:false ~inccl:true ~l2r:(Some (dir = L2R)) ~c_sort ~e_sort ~p_sort in |
| 411 |
sigma, { Environ.uj_val = mkLambda (id, rdx_ty, pred); uj_type = mkProd (id, rdx_ty, predty) } , elim |
| 412 |
in |
| 413 |
let elimT = Retyping.get_type_of env sigma elim in |
| 414 |
let (idA, tA, elimT) = destProd sigma elimT in |
| 415 |
let (_, _, elimT) = destProd sigma elimT in |
| 416 |
let (idP, tP, _) = destProd sigma elimT in |
| 417 |
let sigma = Typing.check_actual_type env sigma (Retyping.get_judgment_of env sigma rdx_ty) tA in |
| 418 |
let tP = mkLetIn (idA, rdx_ty, tA, mkLetIn (anonR, mkProp, mkType Univ.Universe.type1, tP)) in |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
let sigma = Typing.check_actual_type env sigma pred tP in |
| 423 |
sigma, p, pred.uj_val , elim |
| 424 |
with |
| 425 |
| Pretype_errors.PretypeError (env, sigma, te) -> raise (PRtype_error (Some (env, sigma, te))) |
| 426 |
| e when CErrors.noncritical e -> raise (PRtype_error None) |
| 427 |
in |
| 428 |
let proof = EConstr.mkApp (elim, [| rdx_ty; new_rdx; pred; p; rdx; c |]) in |
| 429 |
debug_ssr (fun () -> Pp.(str"pirrel_rewrite: proof term: " ++ pr_econstr_env env sigma proof)); |
| 430 |
Proofview.tclORELSE (refine_with |
| 431 |
~first_goes_last:(not !ssroldreworder || under) ~with_evars:under (sigma, proof)) |
| 432 |
(fun (e, i) -> |
| 433 |
|
| 434 |
match EConstr.kind sigma c with |
| 435 |
| App (hd, args) -> |
| 436 |
let hd_ty = Retyping.get_type_of env sigma hd in |
| 437 |
let names = let rec aux env t = function 0 -> [] | n -> |
| 438 |
let t = Reductionops.whd_all env sigma t in |
| 439 |
let open EConstr in |
| 440 |
match kind_of_type sigma t with |
| 441 |
| ProdType (name, ty, t) -> |
| 442 |
name.binder_name :: |
| 443 |
aux (EConstr.push_rel (Context.Rel.Declaration.LocalAssum (name,ty)) env) t (n-1) |
| 444 |
| _ -> |
| 445 |
|
| 446 |
CList.init n (fun _ -> Names.Name.Anonymous) in aux env hd_ty (Array.length args) in |
| 447 |
let miss = Util.List.map_filter (fun (t, name) -> |
| 448 |
let evs = Evar.Set.elements (Evarutil.undefined_evars_of_term sigma t) in |
| 449 |
let open_evs = List.filter (fun k -> |
| 450 |
not @@ UnivGen.QualityOrSet.is_prop (Retyping.get_sort_quality_of |
| 451 |
env sigma (Evd.evar_concl (Evd.find_undefined sigma k)))) |
| 452 |
evs in |
| 453 |
if open_evs <> [] then Some name else None) |
| 454 |
(List.combine (Array.to_list args) names) in |
| 455 |
tclZEROMSG Pp.(Himsg.explain_refiner_error env sigma (Logic.UnresolvedBindings miss)++ |
| 456 |
(Pp.fnl()++str"Rule's type:" ++ spc() ++ pr_econstr_env env sigma hd_ty)) |
| 457 |
| _ -> Proofview.tclZERO ~info:i e) |
| 458 |
end |
| 459 |
|
| 460 |
let pf_merge_uc_of s sigma = |
| 461 |
Evd.merge_universe_context sigma (Evd.ustate s) |
| 462 |
|
| 463 |
let rwcltac ?under ?map_redex cl rdx dir (sigma, r) = |
| 464 |
let open Proofview.Notations in |
| 465 |
Proofview.Goal.enter begin fun gl -> |
| 466 |
let env = Proofview.Goal.env gl in |
| 467 |
let sigma0 = Proofview.Goal.sigma gl in |
| 468 |
let concl = Proofview.Goal.concl gl in |
| 469 |
let sigma = resolve_typeclasses ~where:r ~fail:false env sigma in |
| 470 |
let r_n, evs, ucst = abs_evars env sigma0 (sigma, r) in |
| 471 |
let sigma0 = Evd.set_universe_context sigma0 ucst in |
| 472 |
let n = List.length evs in |
| 473 |
let r_n' = abs_cterm env sigma0 n r_n in |
| 474 |
let r' = EConstr.Vars.subst_var sigma pattern_id r_n' in |
| 475 |
let sigma, rdxt = Typing.type_of env sigma rdx in |
| 476 |
let () = debug_ssr (fun () -> Pp.(str"r@rwcltac=" ++ pr_econstr_env env sigma r)) in |
| 477 |
let cvtac, rwtac, sigma0 = |
| 478 |
if EConstr.Vars.closed0 sigma0 r' then |
| 479 |
let c_eq = Rocqlib.(lib_ref "core.eq.type") in |
| 480 |
let sigma, c_ty = Typing.type_of env sigma r in |
| 481 |
let () = debug_ssr (fun () -> Pp.(str"c_ty@rwcltac=" ++ pr_econstr_env env sigma c_ty)) in |
| 482 |
let open EConstr in |
| 483 |
match kind_of_type sigma (Reductionops.whd_all env sigma c_ty) with |
| 484 |
| AtomicType(e, a) when Ssrcommon.is_ind_ref env sigma e c_eq -> |
| 485 |
let new_rdx = if dir = L2R then a.(2) else a.(1) in |
| 486 |
let e_sort = Retyping.get_sort_of env sigma c_ty in |
| 487 |
let c_sort = Retyping.get_sort_of env sigma a.(0) in |
| 488 |
pirrel_rewrite ?under ?map_redex cl rdx a.(0) c_sort new_rdx dir (sigma, r) c_ty e e_sort, Tacticals.tclIDTAC, sigma0 |
| 489 |
| _ -> |
| 490 |
let cl' = EConstr.mkApp (EConstr.mkNamedLambda sigma (make_annot pattern_id ERelevance.relevant) rdxt cl, [|rdx|]) in |
| 491 |
let sigma, _ = Typing.type_of env sigma cl' in |
| 492 |
let sigma0 = pf_merge_uc_of sigma sigma0 in |
| 493 |
convert_concl ~check:true cl', rewritetac ?under dir r', sigma0 |
| 494 |
else |
| 495 |
let dc, r2 = EConstr.decompose_lambda_n_assum sigma0 n r' in |
| 496 |
let r3, _, r3t = |
| 497 |
try EConstr.destCast sigma0 r2 with e when CErrors.noncritical e -> |
| 498 |
errorstrm Pp.(str "no cast from " ++ pr_econstr_pat env sigma0 r |
| 499 |
++ str " to " ++ pr_econstr_env env sigma0 r2) in |
| 500 |
let cl' = EConstr.mkNamedProd sigma (make_annot rule_id ERelevance.relevant) (EConstr.it_mkProd_or_LetIn r3t dc) (EConstr.Vars.lift 1 cl) in |
| 501 |
let cl'' = EConstr.mkNamedProd sigma (make_annot pattern_id ERelevance.relevant) rdxt cl' in |
| 502 |
let itacs = [introid pattern_id; introid rule_id] in |
| 503 |
let cltac = Tactics.clear [pattern_id; rule_id] in |
| 504 |
let rwtacs = [ |
| 505 |
Tacticals.tclTHENLIST [ |
| 506 |
rewritetac ?under dir (EConstr.mkVar rule_id); |
| 507 |
if !ssroldreworder || Option.default false under then |
| 508 |
Proofview.tclUNIT () |
| 509 |
else |
| 510 |
Proofview.cycle 1 |
| 511 |
]; |
| 512 |
cltac] in |
| 513 |
Tactics.apply_type ~typecheck:true cl'' [rdx; EConstr.it_mkLambda_or_LetIn r3 dc], Tacticals.tclTHENLIST (itacs @ rwtacs), sigma0 |
| 514 |
in |
| 515 |
let cvtac' = |
| 516 |
Proofview.tclORELSE cvtac begin function |
| 517 |
| (PRtype_error e, _) -> |
| 518 |
let error = Option.cata (fun (env, sigma, te) -> |
| 519 |
Pp.(fnl () ++ str "Type error was: " ++ Himsg.explain_pretype_error env sigma te)) |
| 520 |
(Pp.mt ()) e in |
| 521 |
if occur_existential sigma0 concl |
| 522 |
then Tacticals.tclZEROMSG Pp.(str "Rewriting impacts evars" ++ error) |
| 523 |
else Tacticals.tclZEROMSG Pp.(str "Dependent type error in rewrite of " |
| 524 |
++ pr_econstr_env env sigma0 |
| 525 |
(EConstr.mkNamedLambda sigma (make_annot pattern_id ERelevance.relevant) rdxt cl) |
| 526 |
++ error) |
| 527 |
| (e, info) -> Proofview.tclZERO ~info e |
| 528 |
end |
| 529 |
in |
| 530 |
Proofview.Unsafe.tclEVARS sigma0 <*> |
| 531 |
Tacticals.tclTHEN cvtac' rwtac |
| 532 |
end |
| 533 |
|
| 534 |
let lz_setoid_relation = |
| 535 |
let last_srel = ref None in |
| 536 |
fun env -> match !last_srel with |
| 537 |
| Some (env', srel) when env' == env -> srel |
| 538 |
| _ -> |
| 539 |
let srel = |
| 540 |
try Some (UnivGen.constr_of_monomorphic_global (Global.env ()) @@ |
| 541 |
Rocqlib.lib_ref "rewrite.prop.RewriteRelation") |
| 542 |
with e when CErrors.noncritical e -> None in |
| 543 |
last_srel := Some (env, srel); srel |
| 544 |
|
| 545 |
let ssr_is_setoid env = |
| 546 |
match lz_setoid_relation env with |
| 547 |
| None -> fun _ _ _ -> false |
| 548 |
| Some srel -> |
| 549 |
fun sigma r args -> |
| 550 |
Rewrite.is_applied_rewrite_relation env |
| 551 |
sigma [] (EConstr.mkApp (r, args)) <> None |
| 552 |
|
| 553 |
let closed0_check env sigma cl p = |
| 554 |
if EConstr.Vars.closed0 sigma cl then |
| 555 |
errorstrm Pp.(str"No occurrence of redex "++ pr_econstr_env env sigma p) |
| 556 |
|
| 557 |
let dir_org = function L2R -> 1 | R2L -> 2 |
| 558 |
|
| 559 |
let rwprocess_rule env dir rule = |
| 560 |
let is_setoid = ssr_is_setoid env in |
| 561 |
let prod_type = Rocqlib.lib_ref "core.prod.type" in |
| 562 |
let prod_intro = Rocqlib.lib_ref "core.prod.intro" in |
| 563 |
let prod_proj1 = Rocqlib.lib_ref "core.prod.proj1" in |
| 564 |
let prod_proj2 = Rocqlib.lib_ref "core.prod.proj2" in |
| 565 |
let r_sigma, rules = |
| 566 |
let rec loop d sigma r t0 rs red = |
| 567 |
let t = |
| 568 |
if red = 1 then Tacred.hnf_constr env sigma t0 |
| 569 |
else Reductionops.clos_whd_flags RedFlags.betaiotazeta env sigma t0 in |
| 570 |
debug_ssr (fun () -> Pp.(str"rewrule="++pr_econstr_pat env sigma t)); |
| 571 |
match EConstr.kind sigma t with |
| 572 |
| Prod (_, xt, at) -> |
| 573 |
let sigma = Evd.create_evar_defs sigma in |
| 574 |
let typeclass_candidate = Typeclasses.is_maybe_class_type env sigma xt in |
| 575 |
let (sigma, x) = Evarutil.new_evar ~typeclass_candidate env sigma xt in |
| 576 |
loop d sigma EConstr.(mkApp (r, [|x|])) (EConstr.Vars.subst1 x at) rs 0 |
| 577 |
| App (pr, a) when is_ind_ref env sigma pr prod_type -> |
| 578 |
let r0 = Reductionops.clos_whd_flags RedFlags.all env sigma r in |
| 579 |
let sigma, pL, pR = match EConstr.kind sigma r0 with |
| 580 |
| App (c, ra) when is_construct_ref env sigma c prod_intro -> |
| 581 |
(sigma, ra.(2), ra.(3)) |
| 582 |
| _ -> |
| 583 |
let ra = Array.append a [|r|] in |
| 584 |
let sigma, pi1 = Evd.fresh_global env sigma prod_proj1 in |
| 585 |
let sigma, pi2 = Evd.fresh_global env sigma prod_proj2 in |
| 586 |
let pL = EConstr.mkApp (pi1, ra) in |
| 587 |
let pR = EConstr.mkApp (pi2, ra) in |
| 588 |
(sigma, pL, pR) |
| 589 |
in |
| 590 |
if EConstr.is_lib_ref env sigma "core.True.type" a.(0) then |
| 591 |
loop (converse_dir d) sigma pR a.(1) rs 0 |
| 592 |
else |
| 593 |
let sigma, rs2 = loop d sigma pR a.(1) rs 0 in |
| 594 |
loop d sigma pL a.(0) rs2 0 |
| 595 |
| App (r_eq, a) when Hipattern.match_with_equality_type env sigma t != None -> |
| 596 |
let (ind, u) = EConstr.destInd sigma r_eq and rhs = Array.last a in |
| 597 |
let np = Inductiveops.inductive_nparamdecls env ind in |
| 598 |
let indu = (ind, u) in |
| 599 |
let ind_ct = Inductiveops.type_of_constructors env indu in |
| 600 |
let lhs0 = last_arg sigma (strip_prod_expand_let sigma ind_ct.(0)) in |
| 601 |
let rdesc = match EConstr.kind sigma lhs0 with |
| 602 |
| Rel i -> |
| 603 |
let lhs = a.(np - i) in |
| 604 |
let lhs, rhs = if d = L2R then lhs, rhs else rhs, lhs in |
| 605 |
|
| 606 |
|
| 607 |
d, r, lhs, rhs |
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
| _ -> |
| 616 |
let lhs = EConstr.Vars.substl (array_list_of_tl (Array.sub a 0 np)) lhs0 in |
| 617 |
let lhs, rhs = if d = R2L then lhs, rhs else rhs, lhs in |
| 618 |
let d' = if Array.length a = 1 then d else converse_dir d in |
| 619 |
d', r, lhs, rhs in |
| 620 |
sigma, rdesc :: rs |
| 621 |
| App (s_eq, a) when is_setoid sigma s_eq a -> |
| 622 |
let np = Array.length a and i = 3 - dir_org d in |
| 623 |
let lhs = a.(np - i) and rhs = a.(np + i - 3) in |
| 624 |
let a' = Array.copy a in let _ = a'.(np - i) <- EConstr.mkVar pattern_id in |
| 625 |
let r' = EConstr.mkCast (r, DEFAULTcast, EConstr.mkApp (s_eq, a')) in |
| 626 |
sigma, (d, r', lhs, rhs) :: rs |
| 627 |
| _ -> |
| 628 |
if red = 0 then loop d sigma r t rs 1 |
| 629 |
else errorstrm Pp.(str "not a rewritable relation: " ++ pr_econstr_pat env sigma t |
| 630 |
++ spc() ++ str "in rule " ++ pr_econstr_pat env sigma (snd rule)) |
| 631 |
in |
| 632 |
let sigma, r = rule in |
| 633 |
let t = Retyping.get_type_of env sigma r in |
| 634 |
loop dir sigma r t [] 0 |
| 635 |
in |
| 636 |
r_sigma, rules |
| 637 |
|
| 638 |
let rwrxtac ?under ?map_redex occ rdx_pat dir rule = |
| 639 |
Proofview.Goal.enter begin fun gl -> |
| 640 |
let env = Proofview.Goal.env gl in |
| 641 |
let sigma0 = Proofview.Goal.sigma gl in |
| 642 |
let r_sigma, rules = rwprocess_rule env dir rule in |
| 643 |
let find_rule rdx = |
| 644 |
let rec rwtac = function |
| 645 |
| [] -> |
| 646 |
errorstrm Pp.(str "pattern " ++ pr_econstr_pat env sigma0 rdx ++ |
| 647 |
str " does not match " ++ pr_dir_side dir ++ |
| 648 |
str " of " ++ pr_econstr_pat env sigma0 (snd rule)) |
| 649 |
| (d, r, lhs, rhs) :: rs -> |
| 650 |
try |
| 651 |
let ise = unify_HO env (Evd.create_evar_defs r_sigma) lhs rdx in |
| 652 |
if not (rw_progress rhs rdx ise) then raise NoMatch else |
| 653 |
d, (ise, Evd.ustate ise, Reductionops.nf_evar ise r) |
| 654 |
with e when CErrors.noncritical e -> rwtac rs in |
| 655 |
rwtac rules in |
| 656 |
let env0 = env in |
| 657 |
let concl0 = Proofview.Goal.concl gl in |
| 658 |
let rigid ev = Evd.mem sigma0 ev in |
| 659 |
let find_R, conclude = match classify_pattern rdx_pat with |
| 660 |
| None -> |
| 661 |
let upats_origin = dir, (snd rule) in |
| 662 |
let rpat pats (d, r, lhs, rhs) = |
| 663 |
let r = Reductionops.nf_evar r_sigma r in |
| 664 |
let lhs = Reductionops.nf_evar r_sigma lhs in |
| 665 |
mk_tpattern ~ok:(rw_progress rhs) ~rigid env0 r d lhs pats |
| 666 |
in |
| 667 |
let rpats = List.fold_left rpat (empty_tpatterns r_sigma) rules in |
| 668 |
let find_R, end_R = mk_tpattern_matcher sigma0 occ ~upats_origin rpats in |
| 669 |
(fun e c _ i -> find_R ~k:(fun _ _ _ h -> EConstr.mkRel h) e c i), |
| 670 |
fun cl -> let rdx,d,r = end_R () in closed0_check env0 sigma0 cl rdx; (d,r),rdx |
| 671 |
| Some (_, e) -> |
| 672 |
let r = ref None in |
| 673 |
(fun env c _ h -> do_once r (fun () -> find_rule c, c); EConstr.mkRel h), |
| 674 |
(fun concl -> closed0_check env0 sigma0 concl e; |
| 675 |
let (d,(ev,ctx,c)) , x = assert_done r in (d,(true, ev,ctx, Reductionops.nf_evar ev c)) , x) in |
| 676 |
let concl0 = Reductionops.nf_evar sigma0 concl0 in |
| 677 |
let concl = eval_pattern env0 sigma0 concl0 rdx_pat occ find_R in |
| 678 |
let (d, (_, sigma, uc, t)), rdx = conclude concl in |
| 679 |
let r = Evd.merge_universe_context sigma uc, t in |
| 680 |
rwcltac ?under ?map_redex concl rdx d r |
| 681 |
end |
| 682 |
|
| 683 |
let ssrinstancesofrule ist dir arg = |
| 684 |
Proofview.Goal.enter begin fun gl -> |
| 685 |
let env0 = Proofview.Goal.env gl in |
| 686 |
let sigma0 = Proofview.Goal.sigma gl in |
| 687 |
let concl0 = Proofview.Goal.concl gl in |
| 688 |
let rigid ev = Evd.mem sigma0 ev in |
| 689 |
let rule = interp_term env0 sigma0 ist arg in |
| 690 |
let r_sigma, rules = rwprocess_rule env0 dir rule in |
| 691 |
let find, conclude = |
| 692 |
let upats_origin = dir, (snd rule) in |
| 693 |
let rpat pats (d, r, lhs, rhs) = |
| 694 |
let r = Reductionops.nf_evar r_sigma r in |
| 695 |
let lhs = Reductionops.nf_evar r_sigma lhs in |
| 696 |
mk_tpattern ~ok:(rw_progress rhs) ~rigid env0 r d lhs pats |
| 697 |
in |
| 698 |
let rpats = List.fold_left rpat (empty_tpatterns r_sigma) rules in |
| 699 |
mk_tpattern_matcher ~all_instances:true ~raise_NoMatch:true sigma0 None ~upats_origin rpats in |
| 700 |
let print env p c _ = Feedback.msg_info Pp.(hov 1 (str"instance:" ++ spc() ++ pr_econstr_env env r_sigma p ++ spc() ++ str "matches:" ++ spc() ++ pr_econstr_env env r_sigma c)); c in |
| 701 |
Feedback.msg_info Pp.(str"BEGIN INSTANCES"); |
| 702 |
try |
| 703 |
while true do |
| 704 |
ignore(find env0 (Reductionops.nf_evar sigma0 concl0) 1 ~k:print) |
| 705 |
done; raise NoMatch |
| 706 |
with NoMatch -> Feedback.msg_info Pp.(str"END INSTANCES"); Tacticals.tclIDTAC |
| 707 |
end |
| 708 |
|
| 709 |
let ipat_rewrite occ dir c = Proofview.Goal.enter begin fun gl -> |
| 710 |
rwrxtac occ None dir (Proofview.Goal.sigma gl, c) |
| 711 |
end |
| 712 |
|
| 713 |
let rwargtac ?under ?map_redex ist ((dir, mult), (((oclr, occ), grx), (kind, gt))) = |
| 714 |
let open Proofview.Notations in |
| 715 |
Proofview.Goal.enter begin fun gl -> |
| 716 |
let env = Proofview.Goal.env gl in |
| 717 |
let sigma = Proofview.Goal.sigma gl in |
| 718 |
let fail = ref false in |
| 719 |
let interp_rpattern env sigma gc = |
| 720 |
try interp_rpattern env sigma gc |
| 721 |
with e when CErrors.noncritical e && snd mult = May -> |
| 722 |
fail := true; { pat_sigma = sigma; pat_pat = T EConstr.mkProp } in |
| 723 |
let interp env sigma gc = |
| 724 |
try interp_term env sigma ist gc |
| 725 |
with e when CErrors.noncritical e && snd mult = May -> fail := true; (sigma, EConstr.mkProp) in |
| 726 |
let rwtac = |
| 727 |
Proofview.Goal.enter begin fun gl -> |
| 728 |
let env = Proofview.Goal.env gl in |
| 729 |
let sigma = Proofview.Goal.sigma gl in |
| 730 |
let rx = Option.map (interp_rpattern env sigma) grx in |
| 731 |
|
| 732 |
let sigma = match rx with |
| 733 |
| None -> sigma |
| 734 |
| Some { pat_sigma = s } -> Evd.set_universe_context sigma (Evd.ustate s) |
| 735 |
in |
| 736 |
let t = interp env sigma gt in |
| 737 |
let sigma = Evd.set_universe_context sigma (Evd.ustate (fst t)) in |
| 738 |
Proofview.Unsafe.tclEVARS sigma <*> |
| 739 |
(match kind with |
| 740 |
| RWred sim -> simplintac occ rx sim |
| 741 |
| RWdef -> if dir = R2L then foldtac occ rx t else unfoldintac occ rx t gt |
| 742 |
| RWeq -> rwrxtac ?under ?map_redex occ rx dir t) |
| 743 |
end |
| 744 |
in |
| 745 |
let ctac = cleartac (interp_clr sigma (oclr, (fst gt, snd (interp env sigma gt)))) in |
| 746 |
if !fail then ctac else Tacticals.tclTHEN (tclMULT mult rwtac) ctac |
| 747 |
end |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
let ssrrewritetac ?under ?map_redex ist rwargs = |
| 756 |
Proofview.Goal.enter begin fun _ -> |
| 757 |
Tacticals.tclTHENLIST (List.map (rwargtac ?under ?map_redex ist) rwargs) |
| 758 |
end |
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
let unfoldtac occ ko t kt = |
| 763 |
Proofview.Goal.enter begin fun gl -> |
| 764 |
let env = Proofview.Goal.env gl in |
| 765 |
let sigma = Proofview.Goal.sigma gl in |
| 766 |
let concl = Proofview.Goal.concl gl in |
| 767 |
let concl = Evarutil.nf_evar sigma concl in |
| 768 |
let cl, c = fill_occ_term env sigma concl occ (fst (strip_unfold_term env t kt)) in |
| 769 |
let cl' = EConstr.Vars.subst1 (Tacred.unfoldn [OnlyOccurrences [1], get_evalref env sigma c] env sigma c) cl in |
| 770 |
let f = if ko = None then RedFlags.betaiotazeta else RedFlags.betaiota in |
| 771 |
convert_concl ~check:true (Reductionops.clos_norm_flags f env sigma cl') |
| 772 |
end |
| 773 |
|
| 774 |
let unlocktac ist args = |
| 775 |
let open Proofview.Notations in |
| 776 |
let utac (occ, gt) = |
| 777 |
Proofview.Goal.enter begin fun gl -> |
| 778 |
let env = Proofview.Goal.env gl in |
| 779 |
let sigma = Proofview.Goal.sigma gl in |
| 780 |
unfoldtac occ occ (interp_term env sigma ist gt) (fst gt) |
| 781 |
end |
| 782 |
in |
| 783 |
Ssrcommon.tacMK_SSR_CONST "locked" >>= fun locked -> |
| 784 |
Ssrcommon.tacMK_SSR_CONST "master_key" >>= fun key -> |
| 785 |
let ktacs = [ |
| 786 |
(Proofview.tclEVARMAP >>= fun sigma -> unfoldtac None None (sigma, locked) InParens); |
| 787 |
Ssrelim.casetac key (fun ?seed:_ k -> k) |
| 788 |
] in |
| 789 |
Tacticals.tclTHENLIST (List.map utac args @ ktacs) |