Binary encodings of graphs and positive CNF formulas

Lax783278.Encoding · concepts/Lax783278/Encoding.lean · lax-783278

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    A graph on nn labeled vertices is encoded by 1n01^n0 followed by its n×nn\times n adjacency matrix in row order. A formula on nn variables with mm clauses is encoded by 1n0 1m01^n0\,1^m0 followed by the m×nm\times n clause-variable incidence matrix in row order. These encodings retain isolated vertices, unused variables, empty clauses, and repeated clauses. Malformed strings are excluded from the associated languages.

    Concept map
    4 concepts; 6 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax783278.ArcKayles
    2import Lax783278.PositiveCNF
    3import Lax434930.PolynomialTime
    4
    5/-!
    6---
    7title: Binary encodings of graphs and positive CNF formulas
    8type: definition
    9---
    10A graph on nn labeled vertices is encoded by 1n01^n0 followed by its
    11n×nn\times n adjacency matrix in row order. A formula on nn variables
    12with mm clauses is encoded by 1n0 1m01^n0\,1^m0 followed by the m×nm\times n
    13clause-variable incidence matrix in row order. These encodings retain
    14isolated vertices, unused variables, empty clauses, and repeated clauses.
    15Malformed strings are excluded from the associated languages.
    16-/
    17
    18namespace Lax783278.Encoding
    19
    20open scoped Classical
    21
    22open Lax434930.PolynomialTime
    23
    24structure Graph where
    25 vertices : ℕ
    26 graph : SimpleGraph (Fin vertices)
    27
    28noncomputable def graphWord (G : Graph) : Word :=
    29 List.replicate G.vertices true ++ [false] ++
    30 (List.finRange G.vertices).flatMap fun u =>
    31 (List.finRange G.vertices).map fun v => decide (G.graph.Adj u v)
    32
    33def formulaWord (φ : PositiveCNF.Formula) : Word :=
    34 List.replicate φ.nvars true ++ [false] ++
    35 List.replicate φ.clauses.length true ++ [false] ++
    36 φ.clauses.flatMap fun C =>
    37 (List.finRange φ.nvars).map fun x => decide (x ∈ C)
    38
    39def arcKayles : Language :=
    40 {w | ∃ G : Graph, graphWord G = w ∧ ArcKayles.Winning G.graph Finset.univ}
    41
    42def positiveCNF : Language :=
    43 {w | ∃ φ : PositiveCNF.Formula, formulaWord φ = w ∧ PositiveCNF.FirstWins φ}
    44
    45end Lax783278.Encoding
    46

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…