Checking overlow after addition of 2 integers in 2's complement form

Q) Let an−1an−2...a0 and bn−1bn−2...b0 denote the 2’s complement representation of two integers A and B respectively. Addition of A and B yields a sum S=sn−1sn−2...s0.The outgoing carry generated at the most significant bit position, if any, is ignored. Show that an overflow (incorrect addition result) will occur only if the following Boolean condition holds:
(~sn−1)⊕(an−1sn−1)=bn−1(sn−1⊕an−1)

where ⊕ denotes the Boolean XOR operation and ~ denotes the boolean NOT operation. You may use the Boolean identity: X+Y=X⊕Y⊕(XY) to prove your result.

My Attempt :- When an−1bn−1(~sn−1) + (~an−1)∗(~bn−1)∗sn−1 is 1 then overflow OCCURS otherwise no overflow. Means when 2 positive numbers are added and answer is negative and when 2 negative numbers are added and answer is positive then overflow occurs otherwise it does not occur.
Here,
(~sn−1)⊕(an−1sn−1)=bn−1(sn−1⊕an−1)
(sn−1)(an−1sn−1) + (~sn−1)(~(an−1sn−1))= bn−1(sn−1(~an−1)+ an−1(~sn−1))
After solving further, I am getting finally :-
sn−1an−1 + (~sn−1) = bn−1sn−1(~an−1) + bn−1an−1(~sn−1)

I don't know how to solve further to get the desired result and I also don't know whther I am going in right direction or not. Please help.

• It's not clear what you are trying to accomplish. The CPU has CCR flags that tell you what's going on, other than using the CPU I don't understand how would you do this algebra. – Marko Buršič Mar 27 '19 at 11:44
• @Marko, I also don't know what I was doing because I was not getting any clue how to solve it. Can you please tell me how to show the given boolean condition for overflow ? – ankit Mar 27 '19 at 13:46