aboutsummaryrefslogtreecommitdiff
path: root/src/Util/Tactics/ETransitivity.v
blob: 16f26c8e3ea03d4aad62b60d40edae249bf926f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Require Import Coq.Classes.RelationClasses.

Tactic Notation "etransitivity" open_constr(y) :=
  intros;
  let R := match goal with |- ?R ?x ?z => constr:(R) end in
  let x := match goal with |- ?R ?x ?z => constr:(x) end in
  let z := match goal with |- ?R ?x ?z => constr:(z) end in
  let pre_proof_term_head := constr:(@transitivity _ R _) in
  let proof_term_head := (eval cbn in pre_proof_term_head) in
  refine (proof_term_head x y z _ _); [ change (R x y) | change (R y z) ].
(** We call [Coq.Init.Notations.etransitivity] for compatibility
    because it's more powerful than [etransitivity _] in some cases,
    e.g., when things need to be unfolded. *)
Tactic Notation "etransitivity" := Coq.Init.Notations.etransitivity.
Tactic Notation "etransitivity_rev" uconstr(y) := [ > etransitivity y; cycle 1.. ].
Tactic Notation "etransitivity_rev" := [ > etransitivity; cycle 1.. ].

Ltac transitivity_rev y := [ > transitivity y; cycle 1.. ].