The transitivity
tactic requires an argument, which is the intermediate term that you want to introduce into the equality. First call intros
(that's almost always the first thing to do in a proof) to have the hypotheses nicely in the environment. Then you can say transitivity (g x)
and you're left with two immediate applications of an assumption.
intros.
transitivity (g x); auto.
You can also make Coq guess which intermediate term to use. This doesn't always work, because sometimes Coq finds a candidate that doesn't work out in the end, but this case is simple enough and works immediately. The lemma that transitivity
applies is eq_trans
; use eapply eq_trans
to leave a subterm open (?
). The first eauto
chooses a subterm that works for the first branch of the proof, and here it also works in the second branch of the proof.
intros.
eapply eq_trans.
eauto.
eauto.
This can be abbreviated as intros; eapply eq_trans; eauto
. It can even be abbreviated further to
eauto using eq_trans.
eq_trans
isn't in the default hint database because it often leads down an unsuccessful branch.