Documentation

CslibFrontier.Computability.Complexity.Problems.Hamiltonian.Diamond

Diamond graphs #

The diamond construction of Sipser, Theorem 7.46 reduces satisfiability to directed Hamiltonian paths. This file treats it for an arbitrary layout of the rows, so that reductions can choose how many nodes each row has. A diamond graph (Cslib.Complexity.Diamond.graph) has

When the detours across each slot all belong to one clause (Cslib.Complexity.Diamond.WellFormed), the graph has a Hamiltonian path from the first top to the last bottom exactly when the rows can be given directions so that every clause has a detour in the direction of its row (Cslib.Complexity.Diamond.mem_DirHamPath_iff). In a Hamiltonian path every separator has its two row neighbours as predecessor and successor, a detour must return to the slot it left, so all separators of a row point the same way, and the node of a clause is entered from a slot whose row points the way of the detour. Conversely, rows traversed in the given directions, each clause visited by one detour in the direction of its row, form a Hamiltonian path.

Sipser's construction is the layout with one slot for each clause in every row; giving each row only the slots of the detours through it makes the graph linear in the size of the formula.

Node labels, detours, graphs, and the WellFormed and Satisfiable predicates are defined in CslibFrontier.Computability.Complexity.Problems.Hamiltonian.Diamond.Defs, and Hamiltonian-path soundness (satisfiable_of_mem_DirHamPath) is proved in CslibFrontier.Computability.Complexity.Problems.Hamiltonian.Diamond.Soundness; both are re-exported here alongside completeness, the equivalences mem_DirHamPath_iff and mem_DirHamCycle_iff, and polynomial-time computability.

Main definitions #

Main results #

References #

Directions satisfying every clause give Hamiltonian paths #

Steps of a row traversal #

theorem Cslib.Complexity.Diamond.mem_DirHamPath_iff {N : ℕ} {slots : ℕ → ℕ} {M : ℕ} {D : List Detour} (hD : WellFormed N slots M D) :
{ graph := graph N slots M D, source := topNode 0, target := topNode N } ∈ DirHamPath ↔ Satisfiable M D

Hamiltonian paths of diamond graphs. A well-formed diamond graph has a Hamiltonian path from the top of the first diamond to the bottom of the last exactly when its rows can be given directions so that every clause has a detour in the direction of its row.

theorem Cslib.Complexity.Diamond.mem_DirHamCycle_iff {N M : ℕ} {slots : ℕ → ℕ} {D : List Detour} (hD : WellFormed N slots M D) :

Hamiltonian cycles of closed diamond graphs. A well-formed closed diamond graph has a Hamiltonian cycle exactly when its rows can be given directions so that every clause has a detour in the direction of its row.

Polynomial time #

Detours encoded with unary clause, row and slot indices.

Instances For
    theorem Cslib.Complexity.Diamond.encDetour_row_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Detour} :
    theorem Cslib.Complexity.Diamond.encDetour_mk_deg :
    Turing.MultiTapeTM.ComputableInDegree (fun (p : ℕ × ℕ × ℕ × Bool) => { clause := p.1, row := p.2.1, slot := p.2.2.1, leftToRight := p.2.2.2 }) encDetourFields encDetour 1 1
    theorem Cslib.Complexity.Diamond.encDetour_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 x2 T2 S2 : γ → ℕ} {x3 : γ → Bool} {T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encUnary T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn Turing.MultiTapeTM.encUnary T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encBool T3 S3) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { clause := x0 x, row := x1 x, slot := x2 x, leftToRight := x3 x }) encIn encDetour (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))
    @[reducible, inline]

    The tuple of the fields of encDetour.

    Instances For
      theorem Cslib.Complexity.Diamond.encDetour_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 x2 : γ → ℕ} {x3 : γ → Bool} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encUnary budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn Turing.MultiTapeTM.encUnary budget) (h3 : Turing.MultiTapeTM.ComputableInSpace x3 encIn Turing.MultiTapeTM.encBool budget) :
      Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { clause := x0 x, row := x1 x, slot := x2 x, leftToRight := x3 x }) encIn encDetour budget
      theorem Cslib.Complexity.Diamond.encDetour_leftToRight_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Detour} :
      theorem Cslib.Complexity.Diamond.encDetour_clause_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Detour} :
      theorem Cslib.Complexity.Diamond.encDetour_slot_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → Detour} :

      A diamond graph is computable in polynomial time from a layout computable in polynomial time, with the numbers of diamonds, slots and clauses in unary.

      A closed diamond graph is computable in polynomial time from a layout computable in polynomial time, with the numbers of diamonds, slots and clauses in unary.