Multicoloured Clique
Lax470956.MulticolouredClique · concepts/Lax470956/MulticolouredClique.lean · lax-470956
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
An instance is a graph on vertices together with a colouring of its vertices by colours, in which adjacent vertices always receive different colours. It is a yes-instance if the graph contains a clique with one vertex of each colour — necessarily of size .
Parameterized by the number of colours, this problem is W[1]-complete. It is the standard starting point for parameterized hardness proofs, because a reduction from it may assume the vertices of a solution are distinguishable in advance, one per colour.
Concept map
Lean source view on GitHub
| 1 | import Lax271696.GraphEncoding |
| 2 | import Lax470956.ParameterizedComplexity |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Multicoloured Clique |
| 7 | type: definition |
| 8 | --- |
| 9 | An instance is a graph on vertices together with a colouring of its vertices by |
| 10 | colours, in which adjacent vertices always receive different colours. It is a |
| 11 | yes-instance if the graph contains a clique with one vertex of each colour — necessarily |
| 12 | of size . |
| 13 | |
| 14 | Parameterized by the number of colours, this problem is W[1]-complete. It is the |
| 15 | standard starting point for parameterized hardness proofs, because a reduction from it |
| 16 | may assume the vertices of a solution are distinguishable in advance, one per colour. |
| 17 | |
| 18 | # Formalization notes |
| 19 | |
| 20 | The graph is a mathlib `SimpleGraph (Fin n)` and is encoded by the compressed sparse row |
| 21 | format of `Lax271696.GraphEncoding`, so that an instance of this problem is an |
| 22 | instance of the format every other statement in the archive built on that encoding uses. |
| 23 | The colouring is appended as one entry per vertex, and the number of colours as a final |
| 24 | entry, following the convention that a parameterized instance carries its parameter at |
| 25 | the end of the word. |
| 26 | |
| 27 | That adjacent vertices differ in colour is a field of the instance rather than a |
| 28 | consequence: the source of this problem is a -partite graph with edges only between |
| 29 | distinct parts, and a reduction from it uses that the endpoints of an edge have two |
| 30 | different colours. It costs nothing, since an instance violating it has no multicoloured |
| 31 | clique through the offending edge anyway. |
| 32 | |
| 33 | The adjacency list of each vertex is required to be strictly increasing. The archive's |
| 34 | graph format does not ask for this — it lets a list name its neighbours in any order and |
| 35 | more than once — but sorted lists are the convention of the format in practice, and |
| 36 | the requirement is what lets a linear-time reduction enumerate the edges in a canonical |
| 37 | order by a single scan. Without it a reduction would first have to sort and deduplicate |
| 38 | its input; that is possible in linear time, but it is work about the input format rather |
| 39 | than about the problem, and restricting the admissible words only makes the source |
| 40 | problem easier to be reduced *from* in the sense that fewer words need handling — the |
| 41 | problem itself, a graph and a colouring, is unchanged. |
| 42 | |
| 43 | A solution is given as a function from colours to vertices rather than as a set, so that |
| 44 | "one vertex of each colour" is the statement that the function is a section of the |
| 45 | colouring, and the size of the clique needs no separate cardinality argument. |
| 46 | -/ |
| 47 | |
| 48 | namespace Lax470956.MulticolouredClique |
| 49 | |
| 50 | /-- An instance of Multicoloured Clique: a graph whose vertices are coloured so that |
| 51 | adjacent vertices differ in colour. -/ |
| 52 | structure Instance where |
| 53 | /-- The number `k` of colours, the parameter. -/ |
| 54 | colours : ℕ |
| 55 | /-- The number `n` of vertices. -/ |
| 56 | vertices : ℕ |
| 57 | /-- The graph. -/ |
| 58 | graph : SimpleGraph (Fin vertices) |
| 59 | /-- The colour of each vertex. -/ |
| 60 | colour : Fin vertices → Fin colours |
| 61 | /-- Adjacent vertices differ in colour. -/ |
| 62 | adj_colour_ne : ∀ u v, graph.Adj u v → colour u ≠ colour v |
| 63 | |
| 64 | /-- `G` contains a multicoloured clique: one vertex of each colour, pairwise adjacent. -/ |
| 65 | def Instance.HasMulticolouredClique (G : Instance) : Prop := |
| 66 | ∃ f : Fin G.colours → Fin G.vertices, |
| 67 | (∀ c, G.colour (f c) = c) ∧ ∀ c c', c ≠ c' → G.graph.Adj (f c) (f c') |
| 68 | |
| 69 | /-- The word `x` presents the instance `G`: a compressed sparse row block encoding the |
| 70 | graph, with each adjacency list strictly increasing, followed by one entry per vertex |
| 71 | giving its colour, followed by the number of colours. -/ |
| 72 | def EncodesInstance (x : List ℕ) (G : Instance) : Prop := |
| 73 | ∃ g, x = g ++ (List.ofFn fun v => (G.colour v : ℕ)) ++ [G.colours] ∧ |
| 74 | Lax271696.GraphEncoding.EncodesGraph g G.vertices G.graph ∧ |
| 75 | ∀ u < G.vertices, ∀ t, Lax271696.GraphEncoding.offset g u ≤ t → |
| 76 | t + 1 < Lax271696.GraphEncoding.offset g (u + 1) → |
| 77 | Lax271696.GraphEncoding.target g t < Lax271696.GraphEncoding.target g (t + 1) |
| 78 | |
| 79 | /-- The words that encode an instance. -/ |
| 80 | def Instances : Set (List ℕ) := {x | ∃ G, EncodesInstance x G} |
| 81 | |
| 82 | /-- **Multicoloured Clique**, parameterized by the number of colours. The parameter is |
| 83 | the last entry of the word. -/ |
| 84 | def problem : ParameterizedComplexity.Problem where |
| 85 | Domain := Instances |
| 86 | Yes x := ∃ G, EncodesInstance x G ∧ G.HasMulticolouredClique |
| 87 | param x := x.getLast? |>.getD 0 |
| 88 | |
| 89 | end Lax470956.MulticolouredClique |
| 90 |
Formalization notes
The graph is a mathlib and is encoded by the compressed sparse row format of , so that an instance of this problem is an instance of the format every other statement in the archive built on that encoding uses. The colouring is appended as one entry per vertex, and the number of colours as a final entry, following the convention that a parameterized instance carries its parameter at the end of the word.
That adjacent vertices differ in colour is a field of the instance rather than a consequence: the source of this problem is a -partite graph with edges only between distinct parts, and a reduction from it uses that the endpoints of an edge have two different colours. It costs nothing, since an instance violating it has no multicoloured clique through the offending edge anyway.
The adjacency list of each vertex is required to be strictly increasing. The archive's graph format does not ask for this — it lets a list name its neighbours in any order and more than once — but sorted lists are the convention of the format in practice, and the requirement is what lets a linear-time reduction enumerate the edges in a canonical order by a single scan. Without it a reduction would first have to sort and deduplicate its input; that is possible in linear time, but it is work about the input format rather than about the problem, and restricting the admissible words only makes the source problem easier to be reduced from in the sense that fewer words need handling — the problem itself, a graph and a colouring, is unchanged.
A solution is given as a function from colours to vertices rather than as a set, so that "one vertex of each colour" is the statement that the function is a section of the colouring, and the size of the clique needs no separate cardinality argument.
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments