Fix logic with multiple proofs

The algorithm was too greedy. Now we only add proofs such that there is
no intervening labeled environment apart from equations and items.