Graphs with a supplied contraction sequence

Lax528502.ContractionInput · concepts/Lax528502/ContractionInput.lean · lax-528502

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    Number the vertices from 00 to n−1n-1. Write nn 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 11 precisely when the two vertices belong to the same part. There are nn such matrices for a nonempty graph and 1 empty matrix for the empty graph. The input thus has polynomial size in nn and does not depend on a choice of names for the parts.

    Concept map
    2 concepts
    100%
    DefinitionThis conceptRelated conceptA → B: B builds on ADescendants are omitted for concepts with more than 10 descendants.

    Lean source view on GitHub

    1import Lax228581.TwinWidth
    2import Mathlib.Data.List.OfFn
    3
    4/-!
    5---
    6title: Graphs with a supplied contraction sequence
    7type: definition
    8---
    9Number the vertices from 00 to n−1n-1. Write nn and the adjacency matrix of
    10the graph in row order. Append the number of merges and, for each partition
    11from the singletons to the last partition, its equivalence matrix in the same
    12order. An entry is 11 precisely when the two vertices belong to the same part.
    13There are nn such matrices for a nonempty graph and 1 empty matrix for the
    14empty graph. The input thus has polynomial size in nn and does not depend on
    15a choice of names for the parts.
    16-/
    17
    18namespace Lax528502.ContractionInput
    19
    20open Lax228581.TwinWidth
    21
    22/-- The incidence matrix of a relation on numbered rows and columns. -/
    23noncomputable 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. -/
    28noncomputable 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. -/
    32noncomputable 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. -/
    39def tape (x : List ℕ) : List ℕ := x.length :: x
    40
    41end Lax528502.ContractionInput
    42

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…