Betweenness
AbbreviationBETWEENNESS instances#✓fully proved
An instance of BETWEENNESS is a pair \((n, T)\) of a natural number \(n\) (the number of elements) and a list \(T\) of triples of natural numbers.
abbrev BetweennessInstance := ℕ × List (ℕ × ℕ × ℕ)
Used by 3
DefinitionWell-formed BETWEENNESS instances#✓fully proved
A BETWEENNESS instance \((n, T)\) is well formed when every triple \((a, b, c)\) in \(T\) satisfies \(a < n\), \(b < n\) and \(c < n\), and \(a\), \(b\), \(c\) are pairwise distinct.
def WellFormed (i : BetweennessInstance) : Prop :=
∀ t ∈ i.2, t.1 < i.1 ∧ t.2.1 < i.1 ∧ t.2.2 < i.1 ∧ t.1 ≠ t.2.1 ∧ t.1 ≠ t.2.2 ∧ t.2.1 ≠ t.2.2
abbrev BetweennessInstance := ℕ × List (ℕ × ℕ × ℕ)
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:45
Uses 1 · Used by 1
DefinitionBETWEENNESS feasibility#✓fully proved
A BETWEENNESS instance \((n, T)\) is feasible when there is an ordering of the numbers \(0, \dots, n-1\) such that for every triple \((a, b, c)\) in \(T\), either \(p(a) < p(b) < p(c)\) or \(p(c) < p(b) < p(a)\), where \(p(m)\) is the position of \(m\) in the ordering, counting from \(0\), and \(p(m) = n\) when \(m\) is not among \(0, \dots, n-1\).
def BetweennessFeasible
(i : BetweennessInstance) : Prop :=
∃ ord : List ℕ, ord.Perm (List.range i.1) ∧
∀ t ∈ i.2, (ord.idxOf t.1 < ord.idxOf t.2.1 ∧ ord.idxOf t.2.1 < ord.idxOf t.2.2) ∨
(ord.idxOf t.2.2 < ord.idxOf t.2.1 ∧ ord.idxOf t.2.1 < ord.idxOf t.1)
abbrev BetweennessInstance := ℕ × List (ℕ × ℕ × ℕ)
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:45
Uses 1 · Used by 1
DefinitionThe BETWEENNESS decision problem#✓fully proved
BETWEENNESS accepts a bitstring \(x\) exactly when \(x\) decodes, under the canonical bitstring encoding of pairs \((n, T)\) of a natural number and a list of triples of natural numbers, to a BETWEENNESS instance that is both well formed and feasible. Bitstrings that do not decode to such a pair are rejected.
noncomputable def betweennessDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := BetweennessInstance) x with
| some i => decide (WellFormed i ∧ BetweennessFeasible 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 BetweennessInstance := ℕ × List (ℕ × ℕ × ℕ)
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:45
def WellFormed (i : BetweennessInstance) : Prop :=
∀ t ∈ i.2, t.1 < i.1 ∧ t.2.1 < i.1 ∧ t.2.2 < i.1 ∧ t.1 ≠ t.2.1 ∧ t.1 ≠ t.2.2 ∧ t.2.1 ≠ t.2.2
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:48
def BetweennessFeasible
(i : BetweennessInstance) : Prop :=
∃ ord : List ℕ, ord.Perm (List.range i.1) ∧
∀ t ∈ i.2, (ord.idxOf t.1 < ord.idxOf t.2.1 ∧ ord.idxOf t.2.1 < ord.idxOf t.2.2) ∨
(ord.idxOf t.2.2 < ord.idxOf t.2.1 ∧ ord.idxOf t.2.1 < ord.idxOf t.1)
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:52
Uses 12 · Used by 1
TheoremBETWEENNESS is NP-complete#●ready to prove
The BETWEENNESS decision problem belongs to NP, and every decision problem in NP has a polynomial-time many-one reduction to it.
public theorem_wanted betweenness_npComplete :
betweennessDec ∈ MetaMathlibExt.ComplexityTheory.NP ∧
∀ L : MetaMathlibExt.ComplexityTheory.DecisionProblem,
L ∈ MetaMathlibExt.ComplexityTheory.NP →
Cslib.CookLevin.PolyManyOneRed L betweennessDec
noncomputable def betweennessDec :
MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
match MetaMathlibExt.BitstringEncoding.bitDecode
(α := BetweennessInstance) x with
| some i => decide (WellFormed i ∧ BetweennessFeasible i)
| none => false
WantedExt/Complexity/NPComplete/BetweennessWanted.lean:60
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), BETWEENNESS; M. Opatrny, "Total ordering problem" (1979).
Uses 5
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.