A strict weak ordering (swo for short) is a binary relation < on a set A such that its complementary relation ≥ = AxA − < is a total preorder (reflexive, transitive and such that x ≥ y or y ≥ x, or both, for all x, y in A).
We introduce the notion of an extension to a strict weak ordering: Given <A a swo on A, a swo extension of <A to B, where B is a set disjoint with A, is a pair of relations <A→B from A to B and <B→A from B to A for which there is some swo <AUB on AUB such that <A = <AUB ∩ AxA, <A→B = <AUB ∩ AxB, <B→A = <AUB ∩ BxA.
Theorem. (<A→B,<B→A) is a swo extension of <A iff for all a, a' in A, b in B.
- a <A→B b → not(b <B→A a),
- not(a <A→B b) and not(a' <A a) → not(a' <A→B b),
- not(b <B→A a) and not(a <A a') → not(b <B→A a').
- not(a <A→B b) and a <A→B b',
- b <B→A a and not(b' <B→A a) .
We will prove that <AUB = <A U <A→B U <B→A U <B is a swo on B by showing that ≥AUB = (AUB)x(AUB) − <AUB is a total preorder. In the following we will consider x, y, z in AUB:
- Reflexivity (x ≥AUB x): if x is in A, reflexivity follows from the properties of <A. If x is in B and x <AUB x, there would be some a in A verifying the contradictory (not(a <A→B x) and a <A→B x) or (x <B→A a and not(x <B→A a)).
- Transitivity (x ≥AUB y and y ≥AUB z → x ≥AUB z):
- x, y, z in A: from the properties of <A.
- x, y in A, z in B: from property 2.
- x in A, y in B, z in A: If x <A z then not(z <A x), which along with the hypothesis not(x <A→B y) implies by property 2 that not(z <A→B y), in contradiction with not(y <B→A z) by property 1.
- x in A, y, z in B: if x <A→B z, we would have by the hypothesis not(y <B z) and the definition of <B that x <A→B y, in contradiction with the hypothesis not(x <A→B y).
- x in B, y, z in A: from property 3.
- x in B, y in A, z in B: for any a in A, if not(a <A y) then by property 2 not(a <A→B z); and if not(y <A a) we have by property 3 that not(x <B→A a). So, the conditions for x <B z are never satisfied.
- x, y in B, z in A: if x <B→A z then by the hypothesis not(y <B z) and the definition of <B we would have the contradictory x <B y.
- x, y, z in B: for any a in A, if not(a <A→B x) then not(a <A→B y) and thus not(a <A→B z); whereas if x <B→A a then y <B→A a and hence z <B→A a; so, it is not the case that x <B z.
- Comparability (x ≥AUB y or y ≥AUB x):
- x, y in A: from the properties of <A.
- x in A, y in B: from property 1.
- x in B, y in A: from property 1.
- x, y in B: if x <B y then there exists some a in A such either not(a <A→B x) and a <A→B y, which implies not(a <A→B x) and not(y <B→A a); or else x <B→A a and not(y <B→A a), which also implies not(a <A→B x) and not(y <B→A a). Thus in either case y≥AUB a ≥AUB x, and by the transitivity of ≥AUB, it follows that x ≥AUB y.
Swos are important in C++ because sorting algorithms take comparison objects with swo semantics. The swo extension concept that we have developed is related to the notion of partitioning introduced by the C++ standard to describe binary search algorithms, as we will see in a later entry.
No comments:
Post a Comment