The length of the longest common prefix of two lists #
List.commonPrefixLength l₁ l₂ is the length of the longest list that is a prefix of both l₁
and l₂. It is characterized by List.le_commonPrefixLength_iff: a number n is at most the
common prefix length exactly when the first n entries of the two lists exist and agree.
Common prefix lengths satisfy the ultrametric inequality
min (commonPrefixLength l₁ l₂) (commonPrefixLength l₂ l₃) ≤ commonPrefixLength l₁ l₃.
For reduced words in a free group, the common prefix length is the Gromov product of word
length, and this inequality is what makes word length a Lyndon length function.
The length of the longest common prefix of two lists.
Instances For
A number n is at most the common prefix length of two lists exactly when both lists have at
least n entries and their first n entries agree.
The two lists agree up to their common prefix length.
The ultrametric inequality for common prefix lengths.