Took a bit of time to type up the explanation for exercise 3 properly, but here it is.
Let:
- A be (x == y)
- B be (x == z)
- ¬A be NOT A (x != y) (and similarly ¬B be NOT B (x != z))
- A ∧ B be (A && B)
- A V B be (A || B)
For expression
I,
(x == y && x != z) || (x != y && x == z)
can be rewritten as
(A ∧ ¬B) V (¬A ∧ B)
For expression
II,
(x == y || x == z) && (x != y || x != z)
can be rewritten as
(A V B) ∧ (¬A V ¬B)
which can be expanded and changed using boolean algebra to:
(A ∧ ¬A) V (A ∧ ¬B) V (B ∧ ¬A) V (B ∧ ¬B)
= 0 V (A ∧ ¬B) V (B ∧ ¬A) V 0
= (A ∧ ¬B) V (¬A ∧ B)
and therefore is the same as expression I.
For expression
III,
(x == y) != (x == z)
can be rewritten as
A != B
which can be interpreted as "A and not B, or not A and B" because if A is true, B must be false, and vice versa. Both A and B cannot be both true or false at the same time. As such, the expression can be rewritten as
(A ∧ ¬B) V (¬A ∧ B)
and therefore is the same as expression I. Hence all 3 expressions are equivalent.
It can be quite tricky to understand expression III, but since there are only A and B, you can put it into a truth table such as the following:
A |
B |
A != B |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
0 |
and again, you'll get
(A ∧ ¬B) V (¬A ∧ B).
Btw, as an aside, the 3 expressions represent the XOR (exclusive-OR) logic.