Contextual substitutions question

sub A B’ by B.alt;

In this case, if I want to have both A and B substitutions, how to do?

I understand something like “sub A’ B’ by A.alt B.alt;” doesnt work.

You cannot have a contextual substitution without a context. You can (a) leave out the ticks. Or (b) first substitute one letter contextually, then the other one in the context of the substituted letter, resulting in two consecutive sub rules.