lcs_length
def
The length of the longest common subsequence of two vectors $u, v \in \alpha^n$ is the supremum of lengths $l \le n$ for which $u$ and $v$ have a common subsequence of length $l$.
Statement
noncomputable def lcs_length {n : ℕ} {α : Type*} (u v : Fin n → α) : ℕ
- Defined in
- arXiv:2611.21275 Section II-B
- Verified
- 19 Nov 2026
- Axioms
- none listed
- Built on 1
- has_common_subsequenceTwo vectors $u, v \in \alpha^n$ have a common subsequence of length $l$ if there exist strictly increasing index sequences…
- Used by 1
- insdel_distThe insertion-deletion distance between two vectors $u, v \in \alpha^n$ is $2(n - l_{\mathrm{LCS}}(u, v))$.
Read back from the Lean
The function lcs_length takes an implicit length n : ℕ, an implicit type α, and two sequences of length n, u, v : Fin n → α, and defines their longest common subsequence length as the supremum (in ℕ) of the set of natural numbers l such that l ≤ n and u and v have a common subsequence of length l (according to has_common_subsequence).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- The length of the longest common subsequence (LCS) of two words of length n. -/ noncomputable def lcs_length {n : ℕ} {α : Type*} (u v : Fin n → α) : ℕ := sSup {l : ℕ | l ≤ n ∧ has_common_subsequence u v l}