I am trying to learn the basics of Kotlin. The current topic is: Total Order. I am having a hard time understanding how the statements below will be applied. It says:
We say that the sequence has a total order with the relation less or equal when for each a, b, c from this sequence the following statements are true:
You can look at the second sequence above and check if it is possible to apply these rules there.
(The sequence above: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 27 18 19 20)
Can you share some examples of how the statements above will be applied?
CodePudding user response:
if a <= b
and b <= a
then a = b
if a
is less than or equal to b
AND greater than or equal to b
, then the only option is that the two numbers are the same.
if a <= b
and b <= c
then a <= c
in this example you can imagine the variables in a sequence.
a is less than or equal to b = a - b
b is less than or equal to c = a - b - c
CodePudding user response:
As another example, lets pick something that isn't totally ordered. Lets use subsets of the integers 1 to 10. So our elements are things like {1, 3} or {3, 6, 8, 10} or {}. Let's let ≤ mean "is a subset of".
Let A and B be two subsets.
- If A is a subset of B and B is a subset of A, are they the same set? Yep.
- If A is a subset of B and B is a subset of C, is A a subset of C? Yep.
- Is either A a subset of B or B a subset of A? No. There are all sorts of examples in which neither is the subset of the other.
So here we don't have a total ordering.