Documentation

Atlas.TheoryOfComputation.code.Clique

def Clique.HasKClique {V : Type u_1} (G : SimpleGraph V) (k : ) :

A graph G has a k-clique iff there exists a k-vertex subset all of whose pairs are adjacent in G.

Instances For
    def Clique.CLIQUE (V : Type u_1) :

    The language CLIQUE = {⟨G, k⟩ | G has a k-clique} as a set of graph/integer pairs.

    Instances For

      The polarity of a propositional literal: positive (x) or negative (¬x).

      Instances For
        @[implicit_reducible]

        A propositional literal: a variable index together with a polarity, so that ⟨i, .pos⟩ represents x_i and ⟨i, .neg⟩ represents ¬x_i.

        Instances For
          Instances For
            @[implicit_reducible]

            Two literals are contradictory when they refer to the same variable but have opposite polarities (e.g. x_i and ¬x_i).

            Instances For
              @[implicit_reducible]

              Contradictoriness of literals is decidable, inherited from decidability of equality on variable indices and polarities.

              The "contradictory" relation between literals is symmetric.

              Evaluate a literal under a truth assignment σ : ℕ → Bool: a positive literal returns σ l.varIdx, a negative literal returns its negation.

              Instances For
                @[reducible, inline]

                A 3-clause is a triple of literals, representing the disjunction l₁ ∨ l₂ ∨ l₃ in a 3CNF formula.

                Instances For

                  Project the j-th literal (for j : Fin 3) out of a 3-clause.

                  Instances For

                    A 3-clause is satisfied by an assignment σ iff at least one of its three literals evaluates to true under σ.

                    Instances For
                      @[reducible, inline]

                      A 3CNF formula, represented as a list of 3-clauses (interpreted as their conjunction).

                      Instances For

                        A 3CNF formula φ is satisfiable iff there is an assignment σ under which every clause of φ is satisfied.

                        Instances For

                          The graph produced by the standard 3SAT ≤_P CLIQUE reduction. Vertices are pairs (i, j) with i a clause index and j ∈ Fin 3 a literal position; two distinct vertices are adjacent iff they come from different clauses and their literals are not contradictory. A clique of size |φ| then encodes a satisfying assignment by picking, in each clause, a literal that is true.

                          Instances For
                            theorem ThreeSATToClique.contradictory_not_both_true {l₁ l₂ : Literal} {σ : Bool} (hc : l₁.IsContradictory l₂) (h₁ : Literal.eval σ l₁ = true) (h₂ : Literal.eval σ l₂ = true) :

                            Two contradictory literals cannot both evaluate to true under any single assignment.

                            noncomputable def ThreeSATToClique.ThreeClause.trueLitPos (σ : Bool) (c : ThreeClause) (hsat : isSatBy σ c) :
                            Fin 3

                            Given a satisfying assignment σ for a clause c, choose (using classical choice) one position j : Fin 3 whose literal evaluates to true.

                            Instances For

                              Specification of trueLitPos: the literal at the chosen position indeed evaluates to true under σ.

                              noncomputable def ThreeSATToClique.satisfyingClique (φ : ThreeCNF) (σ : Bool) (hsat : ∀ (i : Fin (List.length φ)), ThreeClause.isSatBy σ (List.get φ i)) :

                              Given a satisfying assignment σ for every clause of φ, build the candidate clique in reductionGraph φ by selecting, for each clause i, the vertex (i, j) where j is a position witnessing the clause's satisfaction.

                              Instances For
                                theorem ThreeSATToClique.satisfyingClique_card (φ : ThreeCNF) (σ : Bool) (hsat : ∀ (i : Fin (List.length φ)), ThreeClause.isSatBy σ (List.get φ i)) :

                                The candidate clique satisfyingClique φ σ hsat has exactly |φ| vertices (one per clause), since the map i ↦ (i, _) is injective in i.

                                theorem ThreeSATToClique.satisfyingClique_isClique (φ : ThreeCNF) (σ : Bool) (hsat : ∀ (i : Fin (List.length φ)), ThreeClause.isSatBy σ (List.get φ i)) :

                                The candidate set satisfyingClique φ σ hsat is indeed a clique in reductionGraph φ: any two of its vertices come from different clauses, and their selected literals are both true under σ, hence not contradictory.

                                Forward direction of the 3SAT ≤_P CLIQUE reduction: if φ is satisfiable, then reductionGraph φ contains a |φ|-clique.

                                Backward direction of the 3SAT ≤_P CLIQUE reduction: a |φ|-clique in reductionGraph φ must hit every clause exactly once (since edges only join different clauses) and pick a pairwise non-contradictory set of literals; setting variables to make all chosen positive literals true yields a satisfying assignment for φ.

                                Correctness of the 3SAT ≤_P CLIQUE reduction. A 3CNF formula φ is satisfiable iff its reduction graph reductionGraph φ contains a clique of size |φ|.

                                Tape alphabet used to encode either a 3SAT instance or a CLIQUE instance on a single Turing-machine tape. The symbol sat φ represents an encoded 3CNF formula φ, and clique φ represents the encoded CLIQUE instance ⟨reductionGraph φ, |φ|⟩.

                                Instances For

                                  Encoded 3SAT language: those single-symbol tape strings [.sat φ] whose underlying formula φ is satisfiable.

                                  Instances For

                                    Encoded CLIQUE language (specialized to instances arising from the reduction): the single-symbol strings [.clique φ] whose reduction graph reductionGraph φ contains a |φ|-clique.

                                    Instances For

                                      The reduction function f : Σ* → Σ* on encodings: maps [.sat φ] to [.clique φ] and every other input to the empty string.

                                      Instances For

                                        On any input that is not of the form [.sat φ], the reduction function threeSATToCliqueEnc returns the empty list.

                                        The empty string is not in the encoded CLIQUE language, since every member of CLIQUEEnc has the form [.clique φ].

                                        Full correctness of the reduction function as a many-one reduction: for every input string w, w ∈ ThreeSATEncthreeSATToCliqueEnc w ∈ CLIQUEEnc.

                                        The reduction function threeSATToCliqueEnc is computable in polynomial time; this is the time-complexity content of the 3SAT ≤_P CLIQUE reduction.

                                        3SAT ≤_P CLIQUE. The encoded 3SAT language polynomially reduces to the encoded CLIQUE language via threeSATToCliqueEnc.

                                        Corollary (CLIQUE ∈ P → 3SAT ∈ P). Combining the polynomial-time reduction 3SAT ≤_P CLIQUE with closure of P under polynomial-time reductions: if the encoded CLIQUE language is in P, so is encoded 3SAT.