Graphs with a supplied contraction sequence
Lax528502.ContractionInput · concepts/Lax528502/ContractionInput.lean · lax-528502
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Number the vertices from to . Write and the adjacency matrix of the graph in row order. Append the number of merges and, for each partition from the singletons to the last partition, its equivalence matrix in the same order. An entry is precisely when the two vertices belong to the same part. There are such matrices for a nonempty graph and 1 empty matrix for the empty graph. The input thus has polynomial size in and does not depend on a choice of names for the parts.
Concept map
Lean source view on GitHub
| 1 | import Lax228581.TwinWidth |
| 2 | import Mathlib.Data.List.OfFn |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Graphs with a supplied contraction sequence |
| 7 | type: definition |
| 8 | --- |
| 9 | Number the vertices from to . Write and the adjacency matrix of |
| 10 | the graph in row order. Append the number of merges and, for each partition |
| 11 | from the singletons to the last partition, its equivalence matrix in the same |
| 12 | order. An entry is precisely when the two vertices belong to the same part. |
| 13 | There are such matrices for a nonempty graph and 1 empty matrix for the |
| 14 | empty graph. The input thus has polynomial size in and does not depend on |
| 15 | a choice of names for the parts. |
| 16 | -/ |
| 17 | |
| 18 | namespace Lax528502.ContractionInput |
| 19 | |
| 20 | open Lax228581.TwinWidth |
| 21 | |
| 22 | /-- The incidence matrix of a relation on numbered rows and columns. -/ |
| 23 | noncomputable def matrix (m n : ℕ) (R : Fin m → Fin n → Prop) : List ℕ := by |
| 24 | classical |
| 25 | exact (List.ofFn fun i => List.ofFn fun j => if R i j then 1 else 0).flatten |
| 26 | |
| 27 | /-- The graph alone, as a prefix of an instance with a contraction sequence. -/ |
| 28 | noncomputable def graph {V : Type} {n : ℕ} (order : Fin n ≃ V) (G : SimpleGraph V) : List ℕ := |
| 29 | n :: matrix n n (fun i j => G.Adj (order i) (order j)) |
| 30 | |
| 31 | /-- An explicit graph and its supplied partition sequence, in the given vertex order. -/ |
| 32 | noncomputable def encode {V : Type} [Fintype V] [DecidableEq V] {n d : ℕ} (order : Fin n ≃ V) |
| 33 | (G : SimpleGraph V) (S : PartitionSequence G d) : List ℕ := |
| 34 | graph order G ++ ([S.stepCount] ++ |
| 35 | (List.range (S.stepCount + 1)).flatMap fun k => |
| 36 | matrix n n fun i j => ∃ B ∈ S.partition k, order i ∈ B ∧ order j ∈ B) |
| 37 | |
| 38 | /-- The physical input convention of the polynomial-time word RAM. -/ |
| 39 | def tape (x : List ℕ) : List ℕ := x.length :: x |
| 40 | |
| 41 | end Lax528502.ContractionInput |
| 42 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments