We talked about relations in general and equivalence relations
A relation on sets X1, X2, ..., Xn is simply a subset of X1 × X2 × . . . × Xn. If (x1, x2, . . . , xn) ∈ R, we think of the elements x1, x2, as being related.
A binary relation R on a set A is a relation between A and itself, i.e. a subset of A × A. For elements a and b of A, we write aRb to indicate (a, b) ∈ R.
Examples of binary relations:
A binary relation R on A is an equivalence relation if it satisfies the following three properties:
When writing a program that implements an "equals" method, you should always check that equals satisfies these properties. Otherwise, programmers will get confused.