software-engineering

Definition

Lexicographic Order (Tuples/Sequences)

Lexicographical order (or dictionary order) is a generalization of the standard ordering of words to sequences or tuples of elements from an ordered set.

Let be a strictly ordered set (e.g., integers, characters). Let and be two finite sequences in .

We say that is lexicographically smaller than () if and only if one of the following holds:

  1. Strict Prefix: is a proper prefix of .
  2. First Mismatch: At the first position where the sequences differ, the element in is smaller than the element in .

Recursive Definition:
For sequences defined by a head () and tail (), i.e., , the order is defined recursively:

  • Intuition: It behaves exactly like a dictionary. To compare two words, you look at the first letter. If they differ, the word with the “smaller” (earlier) letter comes first, regardless of what follows. If they match, you discard the first letter and compare the rest. If one word runs out of letters (is a prefix) while the other still has letters, the shorter one comes first.
  • Significance: The position of an element determines its weight. The index is infinitely more significant than .

Examples

  1. Example (Mismatch Dominates Magnitude):
    • . Even though , the decision is made at the first index ().
  2. Example (Prefix Rule):
    • . The first two elements match, but runs out of elements first (length ).
  3. Example (Empty Tuple):
    • . The empty tuple is the “smallest” element in the set of all sequences.
  4. Example (Standard Tie-Breaking):
    • . Indices 1 and 2 match (). The comparison happens at index 3 ().