in reply to If line is followed by line, delete both lines

This part of your spec is confusing (at least to me)...
  1. If cat is followed by dog in the preceding (next?) line, I want to delete both lines.
  2. But if dog is followed by cat, I want to keep both the lines.
    What the purpose of this extra condition?
In this sequence, does line 3 being "cat" somehow overrule, Rule #1 and keep line #2, dog and even perhaps line #1 in the output?
1 cat 2 dog 3 cat
Rule #1 says this should be "cat" (dog cannot follow cat):
3 cat
But Rule #2, seems to indicate that sometimes cat can indeed follow dog - maybe the confluence or Rule 1 and Rule 2 causes "1 cat" to be deleted, but somehow "2 dog" is saved from deletion by Rule #2? How this would work is certainly not clear to me.:
2 dog 3 cat
Or maybe even no changes at all happen due to conflicting rules?!
1 cat 2 dog 3 cat
The English and code examples are not sufficient for me to understand what to code that will exactly solve your problem. The requirements are just not clear to me.

Please correct the English and elaborate on the examples.