Binary encoding of graph decision instances
Lax222097.GraphEncoding · concepts/Lax222097/GraphEncoding.lean · lax-222097
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
An instance consists of a finite simple graph on and a threshold . Its encoding is , followed by the adjacency-matrix bits in row order, followed by . Polynomial running time is measured in the length of this word.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Combinatorics.SimpleGraph.Clique |
| 2 | import Mathlib.Data.List.FinRange |
| 3 | import Lax434930.PolynomialTime |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: Binary encoding of graph decision instances |
| 8 | type: definition |
| 9 | --- |
| 10 | An instance consists of a finite simple graph on and a |
| 11 | threshold . Its encoding is , followed by the adjacency-matrix |
| 12 | bits in row order, followed by . Polynomial running time is measured |
| 13 | in the length of this word. |
| 14 | -/ |
| 15 | |
| 16 | namespace Lax222097.GraphEncoding |
| 17 | |
| 18 | open scoped Classical |
| 19 | |
| 20 | open List Turing Lax434930.PolynomialTime |
| 21 | |
| 22 | /-- An input graph together with the requested solution-size threshold. -/ |
| 23 | structure Instance where |
| 24 | /-- The number of vertices. -/ |
| 25 | order : ℕ |
| 26 | /-- A simple graph on vertices numbered from zero to `order - 1`. -/ |
| 27 | graph : SimpleGraph (Fin order) |
| 28 | /-- The requested lower bound on the size of a solution. -/ |
| 29 | threshold : ℕ |
| 30 | |
| 31 | /-- Encode a natural number as that many one-bits followed by a zero-bit. -/ |
| 32 | def unary (n : ℕ) : Word := replicate n true ++ [false] |
| 33 | |
| 34 | /-- Write the vertex count, the adjacency matrix row by row, and the threshold. -/ |
| 35 | noncomputable def encode (I : Instance) : Word := |
| 36 | unary I.order ++ |
| 37 | (finRange I.order).flatMap (fun u => |
| 38 | (finRange I.order).map (fun v => decide (I.graph.Adj u v))) ++ |
| 39 | unary I.threshold |
| 40 | |
| 41 | /-- The instance transformation can be computed in polynomial time on these binary encodings. -/ |
| 42 | def PolynomialTime (f : Instance → Instance) : Prop := |
| 43 | Nonempty (TM2ComputableInPolyTime encode encode f) |
| 44 | |
| 45 | end Lax222097.GraphEncoding |
| 46 |
Builds on
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments