aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2020-06-16 15:30:42 +0200
committerPierre-Marie Pédrot2020-06-16 15:31:48 +0200
commit31cbaf0fe258438948ba9611d599dc456c313ddd (patch)
treec3b4dfb4bf84a3c2445299f64027537621580c2b
parent948d8bc64ebfa6371a0dd785c119b5223293ba2b (diff)
Code simplification in Autorewrite.
-rw-r--r--tactics/autorewrite.ml18
1 files changed, 6 insertions, 12 deletions
diff --git a/tactics/autorewrite.ml b/tactics/autorewrite.ml
index 5cc2d69753..785cc011f4 100644
--- a/tactics/autorewrite.ml
+++ b/tactics/autorewrite.ml
@@ -224,25 +224,19 @@ let decompose_applied_relation env sigma c ctype left2right =
let find_rel ty =
let eqclause = Clenv.mk_clenv_from_env env sigma None (EConstr.of_constr c,ty) in
let eqclause = fst (clenv_pose_metas_as_evars eqclause (Evd.undefined_metas eqclause.evd)) in
- let (equiv, args) = EConstr.decompose_app sigma (Clenv.clenv_type eqclause) in
- let rec split_last_two = function
- | [c1;c2] -> [],(c1, c2)
- | x::y::z ->
- let l,res = split_last_two (y::z) in x::l, res
- | _ -> raise Not_found
- in
- try
- let others,(c1,c2) = split_last_two args in
+ let (_, args) = Termops.decompose_app_vect sigma (Clenv.clenv_type eqclause) in
+ let len = Array.length args in
+ if 2 <= len then
+ let c1 = args.(len - 2) in
+ let c2 = args.(len - 1) in
let _ty1, _ty2 = Retyping.get_type_of env eqclause.evd c1, Retyping.get_type_of env eqclause.evd c2 in
(* XXX: It looks like mk_clenv_from_env should be fixed instead? *)
let open EConstr in
let hyp_ty = Unsafe.to_constr ty in
let hyp_left = Unsafe.to_constr @@ c1 in
let hyp_right = Unsafe.to_constr @@ c2 in
-(* if not (evd_convertible env eqclause.evd ty1 ty2) then None *)
-(* else *)
Some { hyp_ty; hyp_left; hyp_right; }
- with Not_found -> None
+ else None
in
match find_rel ctype with
| Some c -> Some c