HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, the lexicographic or lexicographical order (also known as lexical order, or dictionary order) is a generalization of the alphabetical order of the
dictionaries A dictionary is a listing of lexemes from the lexicon of one or more specific languages, often arranged alphabetically (or by radical and stroke for ideographic languages), which may include information on definitions, usage, etymologies, p ...
to sequences of ordered symbols or, more generally, of elements of a totally ordered set. There are several variants and generalizations of the lexicographical ordering. One variant applies to sequences of different lengths by comparing the lengths of the sequences before considering their elements. Another variant, widely used in
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many appl ...
, orders
subset In mathematics, Set (mathematics), set ''A'' is a subset of a set ''B'' if all Element (mathematics), elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are ...
s of a given finite set by assigning a total order to the finite set, and converting subsets into increasing sequences, to which the lexicographical order is applied. A generalization defines an order on a
Cartesian product In mathematics, specifically set theory, the Cartesian product of two sets ''A'' and ''B'', denoted ''A''×''B'', is the set of all ordered pairs where ''a'' is in ''A'' and ''b'' is in ''B''. In terms of set-builder notation, that is : A\ti ...
of partially ordered sets; this order is a total order if and only if all factors of the Cartesian product are totally ordered.


Motivation and definition

The words in a
lexicon A lexicon is the vocabulary of a language or branch of knowledge (such as nautical or medical). In linguistics, a lexicon is a language's inventory of lexemes. The word ''lexicon'' derives from Koine Greek language, Greek word (), neuter of () ...
(the set of words used in some language) have a conventional ordering, used in
dictionaries A dictionary is a listing of lexemes from the lexicon of one or more specific languages, often arranged alphabetically (or by radical and stroke for ideographic languages), which may include information on definitions, usage, etymologies, p ...
and encyclopedias, that depends on the underlying ordering of the alphabet of symbols used to build the words. The lexicographical order is one way of formalizing word order given the order of the underlying symbols. The formal notion starts with a finite set , often called the alphabet, which is totally ordered. That is, for any two symbols and in that are not the same symbol, either or . The ''words'' of are the finite sequences of symbols from , including words of length 1 containing a single symbol, words of length 2 with 2 symbols, and so on, even including the empty sequence \varepsilon with no symbols at all. The lexicographical order on the set of all these finite words orders the words as follows: # Given two different words of the same length, say and , the order of the two words depends on the alphabetic order of the symbols in the first place where the two words differ (counting from the beginning of the words): if and only if in the underlying order of the alphabet . # If two words have different lengths, the usual lexicographical order pads the shorter one with "blanks" (a special symbol that is treated as smaller than every element of ) at the end until the words are the same length, and then the words are compared as in the previous case. However, in
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many appl ...
, another convention is frequently used for the second case, whereby a shorter sequence is always smaller than a longer sequence. This variant of the lexicographical order is sometimes called . In lexicographical order, the word "Thomas" appears before "Thompson" because they first differ at the fifth letter ('a' and 'p'), and letter 'a' comes before the letter 'p' in the alphabet. Because it is the first difference, in this case the 5th letter is the "most significant difference" for alphabetical ordering. An important property of the lexicographical order is that for each , the set of words of length is well-ordered by the lexicographical order (provided the alphabet is finite); that is, every decreasing sequence of words of length is finite (or equivalently, every non-empty subset has a least element). It is not true that the set of ''all'' finite words is well-ordered; for example, the infinite set of words has no lexicographically earliest element.


Numeral systems and dates

The lexicographical order is used not only in dictionaries, but also commonly for numbers and dates. One of the drawbacks of the
Roman numeral system Roman numerals are a numeral system that originated in ancient Rome and remained the usual way of writing numbers throughout Europe well into the Late Middle Ages. Numbers are written with combinations of letters from the Latin alphabet, eac ...
is that it is not always immediately obvious which of two numbers is the smaller. On the other hand, with the
positional notation Positional notation (or place-value notation, or positional numeral system) usually denotes the extension to any base of the Hindu–Arabic numeral system (or decimal system). More generally, a positional system is a numeral system in which the ...
of the Hindu–Arabic numeral system, comparing numbers is easy, because the natural order on
nonnegative integer In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''cardinal n ...
s is the same as the variant shortlex of the lexicographic order. In fact, with positional notation, a nonnegative integer is represented by a sequence of numerical digits, and an integer is larger than another one if either it has more digits (ignoring leading zeroes) or the number of digits is the same and the first (most significant) digit which differs is larger. For real numbers written in decimal notation, a slightly different variant of the lexicographical order is used: the parts on the left of the decimal point are compared as before; if they are equal, the parts at the right of the decimal point are compared with the lexicographical order. The padding 'blank' in this context is a trailing "0" digit. When negative numbers are also considered, one has to reverse the order for comparing negative numbers. This is not usually a problem for humans, but it may be for
computer A computer is a machine that can be programmed to Execution (computing), carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as C ...
s (testing the sign takes some time). This is one of the reasons for adopting two's complement representation for representing signed integers in computers. Another example of a non-dictionary use of lexicographical ordering appears in the ISO 8601 standard for dates, which expresses a date as YYYY-MM-DD. This formatting scheme has the advantage that the lexicographical order on sequences of characters that represent dates coincides with the chronological order: an earlier CE date is smaller in the lexicographical order than a later date up to year 9999. This date ordering makes computerized sorting of dates easier by avoiding the need for a separate sorting algorithm.


Monoid of words

The over an alphabet is the free monoid over . That is, the elements of the monoid are the finite sequences (words) of elements of (including the empty sequence, of length 0), and the operation (multiplication) is the concatenation of words. A word is a
prefix A prefix is an affix which is placed before the Word stem, stem of a word. Adding it to the beginning of one word changes it into another word. For example, when the prefix ''un-'' is added to the word ''happy'', it creates the word ''unhappy'' ...
(or 'truncation') of another word if there exists a word such that . By this definition, the empty word (\varepsilon) is a prefix of every word, and every word is a prefix of itself (with = \varepsilon); care must be taken if these cases are to be excluded. With this terminology, the above definition of the lexicographical order becomes more concise: Given a partially or totally ordered set , and two words and over such that is non-empty, then one has under lexicographical order, if at least one of the following conditions is satisfied: * is a prefix of * there exists words , , (possibly empty) and elements and of such that :: :: :: Notice that, due to the prefix condition in this definition, \varepsilon < b\,\, \text b \neq \varepsilon, where \varepsilon is the empty word. If \,<\, is a total order on A, then so is the lexicographic order on the words of A. However, in general this is not a well-order, even if the alphabet A is well-ordered. For instance, if , the language has no least element in the lexicographical order: . Since many applications require well orders, a variant of the lexicographical orders is often used. This well-order, sometimes called or , consists in considering first the lengths of the words (if , then a < b), and, if the lengths are equal, using the lexicographical order. If the order on is a well-order, the same is true for the shortlex order.


Cartesian products

The lexicographical order defines an order on a
Cartesian product In mathematics, specifically set theory, the Cartesian product of two sets ''A'' and ''B'', denoted ''A''×''B'', is the set of all ordered pairs where ''a'' is in ''A'' and ''b'' is in ''B''. In terms of set-builder notation, that is : A\ti ...
of ordered sets, which is a total order when all these sets are themselves totally ordered. An element of a Cartesian product E_1 \times \cdots \times E_n is a sequence whose ith element belongs to E_i for every i. As evaluating the lexicographical order of sequences compares only elements which have the same rank in the sequences, the lexicographical order extends to Cartesian products of ordered sets. Specifically, given two partially ordered sets A and B, the A \times B is defined as (a, b) \leq \left(a^, b^\right) \text a < a^ \text \left(a = a^ \text b \leq b^\right), The result is a partial order. If A and B are each totally ordered, then the result is a total order as well. The lexicographical order of two totally ordered sets is thus a
linear extension In order theory, a branch of mathematics, a linear extension of a partial order is a total order (or linear order) that is compatible with the partial order. As a classic example, the lexicographic order of totally ordered sets is a linear extens ...
of their product order. One can define similarly the lexicographic order on the Cartesian product of an infinite family of ordered sets, if the family is indexed by the
nonnegative integers In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called ''cardinal ...
, or more generally by a well-ordered set. This generalized lexicographical order is a total order if each factor set is totally ordered. Unlike the finite case, an infinite product of well-orders is not necessarily well-ordered by the lexicographical order. For instance, the set of
countably infinite In mathematics, a set is countable if either it is finite or it can be made in one to one correspondence with the set of natural numbers. Equivalently, a set is ''countable'' if there exists an injective function from it into the natural numbers; ...
binary sequences (by definition, the set of functions from non-negative integers to \, also known as the Cantor space \^) is not well-ordered; the subset of sequences that have precisely one 1 (that is, ) does not have a least element under the lexicographical order induced by 0 < 1, because is an
infinite descending chain In mathematics, a total or linear order is a partial order in which any two elements are comparable. That is, a total order is a binary relation \leq on some Set (mathematics), set X, which satisfies the following for all a, b and c in X: # a ...
. Similarly, the infinite lexicographic product is not Noetherian either because is an infinite ascending chain.


Functions over a well-ordered set

The functions from a well-ordered set X to a totally ordered set Y may be identified with sequences indexed by X of elements of Y. They can thus be ordered by the lexicographical order, and for two such functions f and g, the lexicographical order is thus determined by their values for the smallest x such that f(x) \neq g(x). If Y is also well-ordered and X is finite, then the resulting order is a well-order. As shown above, if X is infinite this is not the case.


Finite subsets

In
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many appl ...
, one has often to enumerate, and therefore to order the
finite subset A set is the mathematical model for a collection of different things; a set contains '' elements'' or ''members'', which can be mathematical objects of any kind: numbers, symbols, points in space, lines, other geometrical shapes, variables, or ...
s of a given set S. For this, one usually chooses an order on S. Then,
sorting Sorting refers to ordering data in an increasing or decreasing manner according to some linear relationship among the data items. # ordering: arranging items in a sequence ordered by some criterion; # categorizing: grouping items with similar pro ...
a subset of S is equivalent to convert it into an increasing sequence. The lexicographic order on the resulting sequences induces thus an order on the subsets, which is also called the . In this context, one generally prefer to sort first the subsets by
cardinality In mathematics, the cardinality of a set is a measure of the number of elements of the set. For example, the set A = \ contains 3 elements, and therefore A has a cardinality of 3. Beginning in the late 19th century, this concept was generalized ...
, such as in the
shortlex order In mathematics, and particularly in the theory of formal languages, shortlex is a total ordering for finite sequences of objects that can themselves be totally ordered. In the shortlex ordering, sequences are primarily sorted by cardinality (length) ...
. Therefore, in the following, we will consider only orders on subsets of fixed cardinal. For example, using the natural order of the integers, the lexicographical ordering on the subsets of three elements of S = \ is : ::. For ordering finite subsets of a given cardinality of the natural numbers, the order (see below) is often more convenient, because all initial segments are finite, and thus the colexicographical order defines an order isomorphism between the natural numbers and the set of sets of n natural numbers. This is not the case for the lexicographical order, as, with the lexicographical order, we have, for example, 12 n < 134 for every n > 2.


Group orders of Z^n

Let \Z^n be the
free Abelian group In mathematics, a free abelian group is an abelian group with a basis. Being an abelian group means that it is a set with an addition operation that is associative, commutative, and invertible. A basis, also called an integral basis, is a subse ...
of rank n, whose elements are sequences of n integers, and operation is the
addition Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol ) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication and Division (mathematics), division. ...
. A group order on \Z^n is a total order, which is compatible with addition, that is a < b \quad \text \quad a+c < b+c. The lexicographical ordering is a group order on \Z^n. The lexicographical ordering may also be used to characterize all group orders on \Z^n.. In fact, n
linear form In mathematics, a linear form (also known as a linear functional, a one-form, or a covector) is a linear map from a vector space to its field of scalars (often, the real numbers or the complex numbers). If is a vector space over a field , the s ...
s with real coefficients, define a map from \Z^n into \R^n, which is injective if the forms are linearly independent (it may be also injective if the forms are dependent, see below). The lexicographic order on the image of this map induces a group order on \Z^n. Robbiano's theorem is that every group order may be obtained in this way. More precisely, given a group order on \Z^n, there exist an integer s \leq n and s linear forms with real coefficients, such that the induced map \varphi from \Z^n into \R^s has the following properties; * \varphi is injective; * the resulting isomorphism from \Z^n to the image of \varphi is an order isomorphism when the image is equipped with the lexicographical order on \R^s.


Colexicographic order

The colexicographic or colex order is a variant of the lexicographical order that is obtained by reading finite sequences from the right to the left instead of reading them from the left to the right. More precisely, whereas the lexicographical order between two sequences is defined by : if for the first where and differ, the colexicographical order is defined by : if for the last where and differ In general, the difference between the colexicographical order and the lexicographical order is not very significant. However, when considering increasing sequences, typically for coding subsets, the two orders differ significantly. For example, for ordering the increasing sequences (or the sets) of two natural integers, the lexicographical order begins by :, and the colexicographic order begins by :. The main property of the colexicographical order for increasing sequences of a given length is that every initial segment is finite. In other words, the colexicographical order for increasing sequences of a given length induces an order isomorphism with the natural numbers, and allows enumerating these sequences. This is frequently used in
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many appl ...
, for example in the proof of the Kruskal–Katona theorem.


Monomials

When considering polynomials, the order of the terms does not matter in general, as the addition is commutative. However, some algorithms, such as polynomial long division, require the terms to be in a specific order. Many of the main algorithms for multivariate polynomials are related with Gröbner bases, concept that requires the choice of a
monomial order In mathematics, a monomial order (sometimes called a term order or an admissible order) is a total order on the set of all ( monic) monomials in a given polynomial ring, satisfying the property of respecting multiplication, i.e., * If u \leq v and ...
, that is a total order, which is compatible with the monoid structure of the monomials. Here "compatible" means that a < b \text ac < bc, if the monoid operation is denoted multiplicatively. This compatibility implies that the product of a polynomial by a monomial does not change the order of the terms. For Gröbner bases, a further condition must be satisfied, namely that every non constant monomial is greater than the monomial . However this condition is not needed for other related algorithms, such as the algorithms for the computation of the tangent cone. As Gröbner bases are defined for polynomials in a fixed number of variables, it is common to identify monomials (for example x_1 x_2^3 x_4 x_5^2) with their exponent vectors (here ). If is the number of variables, every monomial order is thus the restriction to \N^n of a monomial order of \Z^n (see above \Z^n, for a classification). One of these admissible orders is the lexicographical order. It is, historically, the first to have been used for defining Gröbner bases, and is sometimes called for distinguishing it from other orders that are also related to a lexicographical order. Another one consists in comparing first the total degrees, and then resolving the conflicts by using the lexicographical order. This order is not widely used, as either the lexicographical order or the degree reverse lexicographical order have generally better properties. The consists also in comparing first the total degrees, and, in case of equality of the total degrees, using the reverse of the colexicographical order. That is, given two exponent vectors, one has _1, \ldots, a_n< _1, \ldots, b_n/math> if either a_1+ \cdots+ a_n < b_1+ \cdots+ b_n, or a_1+ \cdots+ a_n = b_1+\cdots+ b_n \quad \text\quad a_i >b_i \text i \text a_i \neq b_i. For this ordering, the monomials of degree one have the same order as the corresponding indeterminates (this would not be the case if the reverse lexicographical order would be used). For comparing monomials in two variables of the same total degree, this order is the same as the lexicographic order. This is not the case with more variables. For example, for exponent vectors of monomials of degree two in three variables, one has for the degree reverse lexicographic order:
, 0, 2 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline (t ...
<
, 1, 1 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 0, 1 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline ...
<
, 2, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 1, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 0, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
/math> For the lexicographical order, the same exponent vectors are ordered as
, 0, 2 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline (t ...
<
, 1, 1 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 2, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 0, 1 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline ...
<
, 1, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
<
, 0, 0 The comma is a punctuation mark that appears in several variants in different languages. It has the same shape as an apostrophe or single closing quotation mark () in many typefaces, but it differs from them in being placed on the baseline o ...
A useful property of the degree reverse lexicographical order is that a homogeneous polynomial is a multiple of the least indeterminate if and only if its leading monomial (its greater monomial) is a multiple of this least indeterminate.


See also

* Collation * Kleene–Brouwer order * Lexicographic preferences *
Lexicographic order topology on the unit square In general topology, the lexicographic ordering on the unit square (sometimes the dictionary order on the unit square) is a topology on the unit square ''S'', i.e. on the set of points (''x'',''y'') in the plane such that and Construction The ...
* Lexicographic ordering in tensor abstract index notation * Lexicographically minimal string rotation * Long line (topology) * Lyndon word *
Star product In mathematics, the star product is a method of combining graded posets with unique minimal and maximal elements, preserving the property that the posets are Eulerian. Definition The star product of two graded posets (P,\le_P) and (Q,\le_Q), w ...
, a different way of combining partial orders *
Shortlex order In mathematics, and particularly in the theory of formal languages, shortlex is a total ordering for finite sequences of objects that can themselves be totally ordered. In the shortlex ordering, sequences are primarily sorted by cardinality (length) ...
* Orders on the Cartesian product of totally ordered sets


References


External links

* {{Wikiversity-inline, Lexicographic and colexicographic order Order theory Lexicography