proposition: Lemma rankE x stack : rank x stack = if x \in stack then index x (rev stack) else infty.
proof: Proof. elim: stack => [|a s /= ->] //. have [->|neq_xa] /= := altP eqP; rewrite rev_cons -cats1. by rewrite mem_head index_cat mem_rev /= eqxx addn0 size_rev; case: in_mem. by rewrite in_cons (negPf neq_xa) /= index_cat /= mem_rev; case: in_mem. Qed.
imports: mathcomp(all_ssreflect) extra