# Grammaticality of "if X then A. Otherwise if Y B"

I am explaining something that has the following structure if written in computer language:

``````if X
A
else
B
``````

However the condition `X` is quite subtle, and because of this I want to recall it when I state the else statement.

Before adding this extra explanation I had an otherwise in place of my else.

I was wondering if it was proper to keep the otherwise, making the fragment read as follows:

If [X] then [A]. Otherwise if [Y] [B]

I want to insist that [Y] is the strict opposite of [X] here.

EDIT

Even though I am not authorized to publish the exact citation, I will try to write something "equivalent":

If x is not in X then A happens. Otherwise if x is in X then B happens.

• As Russell’s answer points out, in your computer-language version (and in your English version), [Y] is not the strict opposite of [X]. It is just anything that is not [X]. To make a strict opposite, it would have to be `if (X == Y) then A; else if (X == !Y) then B` in pseudo-code. Expressing that in regular English would be fairly cumbersome and lead to some clumsy wordings. Are you quite sure that’s exactly what you need to say? May 5, 2015 at 12:16
• contrariwise is a word that just doesn't get used enough. May 5, 2015 at 12:51

(1.) Note that in your example B is arguably not "the opposite of A" but "all possible items in the set with the exception of A.

eg Slightly 'strange' but I thinks makes the point - "If I was given the choice of a primary colour I'd choose Red, otherwise I could choose Green or Blue.
"Green or Blue" or Green or Blue alone are NOT the opposite of Red.

(2.) The statement of the alternative would usually be redundant but can be included for emphasis or to ensure there is no mistake made. If doing this here is a risk of appearing pedantic. With the same sense:

"Of the two twins Fred was born first, then Frank."

"Of the two twins Fred was born first, then the one who was born second was Frank.

In the 1st sentence the "then Frank" is redundant in establishing birth order but does provide a name.

In the second sentence adding "the one who was born second" is redundant, superfluous, unneeded, OTT and seems a bit strange. In exceedingly complex scenarios doing this may have merit.