Binary encodings of graphs and positive CNF formulas
Lax689614.Encoding · concepts/Lax689614/Encoding.lean · lax-689614
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A graph on labeled vertices is encoded by followed by its adjacency matrix in row order. A formula on variables with clauses is encoded by followed by the 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
Lean source view on GitHub
| 1 | import Lax689614.ArcKayles |
| 2 | import Lax689614.PositiveCNF |
| 3 | import Lax434930.PolynomialTime |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: Binary encodings of graphs and positive CNF formulas |
| 8 | type: definition |
| 9 | --- |
| 10 | A graph on labeled vertices is encoded by followed by its |
| 11 | adjacency matrix in row order. A formula on variables |
| 12 | with clauses is encoded by followed by the |
| 13 | clause-variable incidence matrix in row order. These encodings retain |
| 14 | isolated vertices, unused variables, empty clauses, and repeated clauses. |
| 15 | Malformed strings are excluded from the associated languages. |
| 16 | -/ |
| 17 | |
| 18 | namespace Lax689614.Encoding |
| 19 | |
| 20 | open Lax434930.PolynomialTime |
| 21 | |
| 22 | structure Graph where |
| 23 | vertices : ℕ |
| 24 | graph : SimpleGraph (Fin vertices) |
| 25 | |
| 26 | noncomputable def graphWord (G : Graph) : Word := by |
| 27 | classical |
| 28 | exact List.replicate G.vertices true ++ [false] ++ |
| 29 | (List.finRange G.vertices).flatMap fun u => |
| 30 | (List.finRange G.vertices).map fun v => decide (G.graph.Adj u v) |
| 31 | |
| 32 | def formulaWord (φ : PositiveCNF.Formula) : Word := |
| 33 | List.replicate φ.nvars true ++ [false] ++ |
| 34 | List.replicate φ.clauses.length true ++ [false] ++ |
| 35 | φ.clauses.flatMap fun C => |
| 36 | (List.finRange φ.nvars).map fun x => decide (x ∈ C) |
| 37 | |
| 38 | def arcKayles : Language := |
| 39 | {w | ∃ G : Graph, graphWord G = w ∧ ArcKayles.Winning G.graph Finset.univ} |
| 40 | |
| 41 | def positiveCNF : Language := |
| 42 | {w | ∃ φ : PositiveCNF.Formula, formulaWord φ = w ∧ PositiveCNF.FirstWins φ} |
| 43 | |
| 44 | end Lax689614.Encoding |
| 45 |
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments