Longest common subsequence of many strings
AbbreviationLongest-common-subsequence instances#✓fully proved
A longest-common-subsequence instance is a pair \((R, K)\) of a finite list \(R\) of binary strings (finite lists of booleans) and a natural number \(K\).
DefinitionFeasible longest-common-subsequence instances#✓fully proved
A longest-common-subsequence instance \((R, K)\) is feasible when there is a binary string \(w\) of length at least \(K\) that is a subsequence of every string in \(R\), that is, \(w\) is obtained from each string in \(R\) by deleting some of its entries.
def LongestCommonSubsequenceFeasible
(i : LongestCommonSubsequenceInstance) : Prop :=
∃ common : List Bool, i.2 ≤ common.length ∧ ∀ s ∈ i.1, common.Sublist s
abbrev LongestCommonSubsequenceInstance := List (List Bool) × ℕ
WantedExt/Complexity/NPComplete/LongestCommonSubsequenceWanted.lean:47
Uses 1 · Used by 1
DefinitionThe LONGEST COMMON SUBSEQUENCE decision problem#✓fully proved
LONGEST COMMON SUBSEQUENCE is the decision problem that accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding, to a feasible longest-common-subsequence instance. Bitstrings that do not decode are rejected.
noncomputable def longestCommonSubsequenceDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := LongestCommonSubsequenceInstance) x with
| some i => decide (LongestCommonSubsequenceFeasible i)
| none => false
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
abbrev LongestCommonSubsequenceInstance := List (List Bool) × ℕ
WantedExt/Complexity/NPComplete/LongestCommonSubsequenceWanted.lean:47
def LongestCommonSubsequenceFeasible
(i : LongestCommonSubsequenceInstance) : Prop :=
∃ common : List Bool, i.2 ≤ common.length ∧ ∀ s ∈ i.1, common.Sublist s
WantedExt/Complexity/NPComplete/LongestCommonSubsequenceWanted.lean:50
Uses 11 · Used by 1
TheoremLONGEST COMMON SUBSEQUENCE is NP-complete#●ready to prove
The LONGEST COMMON SUBSEQUENCE decision problem, over binary strings, belongs to NP, and every decision problem in NP reduces to it by a polynomial-time many-one reduction.
public theorem_wanted longestCommonSubsequence_npComplete :
longestCommonSubsequenceDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L longestCommonSubsequenceDec
noncomputable def longestCommonSubsequenceDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := LongestCommonSubsequenceInstance) x with
| some i => decide (LongestCommonSubsequenceFeasible i)
| none => false
WantedExt/Complexity/NPComplete/LongestCommonSubsequenceWanted.lean:56
def NP : DecisionComplexityClass :=
{ L | ∃ (p : Polynomial ℕ), ∃ R : (List Bool × List Bool) → Bool,
IsPolyTime R ∧
∀ x, L x ↔ ∃ w : List Bool, w.length ≤ p.eval x.length ∧ R (x, w) }
MathlibExt/Computability/Complexity.lean:200
abbrev DecisionProblem := List Bool → Bool
MathlibExt/Computability/Complexity.lean:170
def PolyManyOneRed (L₁ L₂ : MetaMathlibExt.ComplexityTheory.DecisionProblem) : Prop :=
∃ reduce : List Bool → List Bool,
MetaMathlibExt.ComplexityTheory.IsPolyTime reduce ∧ ∀ x, L₁ x = L₂ (reduce x)
CSLibExt/Computability/CookLevin.lean:396
Sources
- M. R. Garey and D. S. Johnson, Computers and Intractability (1979), LONGEST COMMON SUBSEQUENCE; D. Maier, "The complexity of some problems on subsequences and supersequences" (1978).
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.