Binary encoding of graph decision instances
Lax762056.GraphEncoding · concepts/Lax762056/GraphEncoding.lean · lax-762056
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 Lax762056.GraphEncoding |
| 17 | |
| 18 | open List Turing Lax434930.PolynomialTime |
| 19 | |
| 20 | structure Instance where |
| 21 | order : ℕ |
| 22 | graph : SimpleGraph (Fin order) |
| 23 | threshold : ℕ |
| 24 | |
| 25 | def unary (n : ℕ) : Word := replicate n true ++ [false] |
| 26 | |
| 27 | noncomputable def encode (I : Instance) : Word := by |
| 28 | classical |
| 29 | exact unary I.order ++ |
| 30 | (finRange I.order).flatMap (fun u => |
| 31 | (finRange I.order).map (fun v => decide (I.graph.Adj u v))) ++ |
| 32 | unary I.threshold |
| 33 | |
| 34 | def PolynomialTime (f : Instance → Instance) : Prop := |
| 35 | Nonempty (TM2ComputableInPolyTime encode encode f) |
| 36 | |
| 37 | end Lax762056.GraphEncoding |
| 38 |
Builds on
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments