AFTD Auto-Formalizing Theoretical Domains

has_common_subsequence

def

Two vectors $u, v \in \alpha^n$ have a common subsequence of length $l$ if there exist strictly increasing index sequences $i, j : \mathrm{Fin}\,l \to \mathrm{Fin}\,n$ such that $u(i(t)) = v(j(t))$ for all $t \in \mathrm{Fin}\,l$.

Statement

def has_common_subsequence {n : ℕ} {α : Type*} (u v : Fin n → α) (l : ℕ) : Prop
Defined in
arXiv:2611.21275 Section II-B
Verified
18 Nov 2026
Axioms
none listed
Built on 2
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
Used by 2
  • has_common_subsequence_zeroAny two vectors of length $n$ have the empty sequence as a common subsequence of length 0.
  • lcs_lengthThe 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$…

Read back from the Lean

Given a natural number n, a type α, two sequences u, v : Fin n → α, and a natural number l, has_common_subsequence u v l asserts that there exist two functions i : Fin l → Fin n and j : Fin l → Fin n such that both i and j are strictly monotone, and for all t : Fin l, u (i t) = v (j t). In other words, u and v share a common subsequence of length l.

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

/-- Predicate stating that two words of length n have a common subsequence of length l. -/
def has_common_subsequence {n : ℕ} {α : Type*} (u v : Fin n → α) (l : ℕ) : Prop := ∃ (i : Fin l → Fin n) (j : Fin l → Fin n), StrictMono i ∧ StrictMono j ∧ ∀ t : Fin l, u (i t) = v (j t)
See it in the graphDiscuss this resultChallenge it