Binary encodings of graphs and positive CNF formulas
Lax783278.Encoding · concepts/Lax783278/Encoding.lean · lax-783278
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 Lax783278.ArcKayles |
| 2 | import Lax783278.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 Lax783278.Encoding |
| 19 | |
| 20 | open scoped Classical |
| 21 | |
| 22 | open Lax434930.PolynomialTime |
| 23 | |
| 24 | structure Graph where |
| 25 | vertices : ℕ |
| 26 | graph : SimpleGraph (Fin vertices) |
| 27 | |
| 28 | noncomputable 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 | |
| 33 | def 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 | |
| 39 | def arcKayles : Language := |
| 40 | {w | ∃ G : Graph, graphWord G = w ∧ ArcKayles.Winning G.graph Finset.univ} |
| 41 | |
| 42 | def positiveCNF : Language := |
| 43 | {w | ∃ φ : PositiveCNF.Formula, formulaWord φ = w ∧ PositiveCNF.FirstWins φ} |
| 44 | |
| 45 | end Lax783278.Encoding |
| 46 |
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments