SATtoColor.sat3Coloring
defimported Lean
Given a satisfying assignment $\mathrm{assign} : V \to \mathrm{Bool}$, the function $\mathrm{sat3Coloring}(\mathrm{assign})$ maps every vertex of $\mathrm{OutputVertex}(V)$ to a color in $\mathrm{Fin}\,3$: palette node $p$ gets color $p$; a positive (resp.\ negative) literal node for variable $v$ gets color $1$ (True) if $\mathrm{assign}(v) = \texttt{true}$ and color $2$ (False) otherwise (resp.\ the reverse); clause gadget node $(c, k)$ gets $\mathrm{clauseGadgetColor}$ applied to the truth values of $c$'s three literals.
Statement
set_option relaxedAutoImplicit false in set_option autoImplicit false in def SATtoColor.sat3Coloring {V : Type} (assign : V → Bool) : OutputVertex V → Fin 3
- Defined in
- TCSlib, `SATtoColor.sat3Coloring`
- Lean proof
- By CS 294-268 course staff (UC Berkeley, Spring 2026), from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Copyright (c) 2026 UC Berkeley CS 294. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.SATtoColor.sat3Coloring← SATtoColor.sat3Coloring (TCSlib/Complexity/NPReductions/ThreeSATToColoring.lean:175): verbatim
- Verified
- 07 Oct 2026
- Axioms
- none listed
- Built on 5
- SATtoColor.OutputVertexThe vertex set of the reduction graph is the inductive type $\mathrm{OutputVertex}(V)$ with three constructors:
•… - SATtoColor.LiteralA literal for switching-lemma formulas: a variable $\mathtt{var} : \mathrm{Fin}\,n$ with a negation flag $\mathtt{neg} : \mathrm{Bool}$…
- SATtoColor.SatisfiesLiteralGiven a Boolean assignment $\mathrm{assign} : V \to \mathrm{Bool}$, the function $\texttt{SATtoColor.SatisfiesLiteral}$ evaluates a…
- SATtoColor.ClauseA clause over a variable type $V$ is a structure bundling exactly three literals $\ell_1, \ell_2, \ell_3 : \mathrm{Literal}\,V$.…
- SATtoColor.clauseGadgetColorGiven the Boolean truth values $a, b, c_3$ of the three literals of a clause, $\mathrm{clauseGadgetColor}(a, b, c_3, k)$ assigns a color…
- SATtoColor.OutputVertexThe vertex set of the reduction graph is the inductive type $\mathrm{OutputVertex}(V)$ with three constructors:
- Used by 2
- SATtoColor.sat3Coloring_litNodeColor of a literal node. Fix a variable type $V$ and a Boolean assignment $\alpha : V \to \{\text{true}, \text{false}\}$, and consider the…
- SATtoColor.SATtoColorCompletenessCompleteness of the 3-SAT to 3-coloring reduction. Let $f$ be a 3-SAT instance over a variable type $V$, that is, a list of clauses, each…
Lean source view module on GitHub
set_option relaxedAutoImplicit false in set_option autoImplicit false in /-- Coloring constructed from a satisfying assignment. -/ def SATtoColor.sat3Coloring {V : Type} (assign : V → Bool) : OutputVertex V → Fin 3 | .palette p => p | .literalNode (.pos v) => if assign v then 1 else 2 | .literalNode (.neg v) => if assign v then 2 else 1 | .clauseGadget c k => clauseGadgetColor (SatisfiesLiteral assign c.l1) (SatisfiesLiteral assign c.l2) (SatisfiesLiteral assign c.l3) k