language agnostic - Total, weak, partial orderings - complete definition -
i've been reading wikipedia , other sources understand simple differences betwen strict/non-strict ordering, weak/non-weak ordering, partial/total ordering.. i'm still confused. can please post simple (in plain english language preferred) , finish (but preferably not long) explanation of these?
let x set. relation < ⊆ x × x partial ordering if
for x ∈ x, never have x < x,
whenever x < y, never have y < x, and
whenever x < y , y < z, have x < z.
a total ordering partial ordering additional property 2 x , y, have precisely 1 of x < y, or y < x, or x = y.
a weak ordering on set x (as far know) partial ordering < additional property induced ordering on quotient set x / ~ total ordering, [x] = [y] ∈ x / ~ if , if neither x < y nor y < x hold in x.
in other words, in partial ordering, some elements can compared, , if can compared, ordering consistent. examples of partial orderings:
proper subsets of set x, a < b means a ⊊ b.
natural numbers a < b meaning "a divides b".
template specializations in c++.
a total ordering 1 all elements, @ once, form single, consistent order.
a weak ordering total ordering if you're willing lump several elements , treat them equivalent purpose of ordering.
the term "strict" refers utilize of "<" defining relation, opposed "≤". can see how easy rewrite definitions in terms of ≤, e.g. in partial ordering have x ≤ x, etc.
here 2 examples, both of c++ template specializations. both partially ordered, of course, first totally ordered.
example #1:
template <typename t> struct foo {}; // a1 template <typename u> struct foo<u*> {}; // a2 template <> struct foo<int*> {}; // a3
these specializations totally ordered a3 < a2 < a1, "<" means "more specialized than".
example #2:
template <typename t1, typename t2> struct bar {}; // b1 template <typename u> struct bar<int, u> {}; // b2a template <typename v> struct bar<v, int> {}; // b2b template <> struct bar<int, int> {}; // b3
this time, have b3 < b2b < b1 , b3 < b2a < b1, b2a , b2b not comparable.
in c++, manifests in next way: if specialization b3 not defined, attempting instantiate bar<int, int>
result in compiler error because there no unambiguous "most specialized" specialization.
partially ordered sets can have many "least" elements , "biggest" elements, because notions can speak elements comparable. among b1, b2a , b2b, both b2a , b2b "least elements", because there no element that's smaller. nonetheless there isn't unique smallest element.
language-agnostic order strict-weak-ordering
No comments:
Post a Comment