The ordered-clique graph and its contraction sequence

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

proven

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

    Lemma

    The disjoint paths reduction assigns a position to each vertex and each arc, and one extra position to the dummy vertex. Incoming and outgoing arcs are processed in topological order by optional exchanges of two positions. Copies of the ordered cliques align each modified crossing edge with a block boundary. After deleting the dummy, merge the prefixes of the blocks from right to left and then contract consecutive blocks (Section 5).

    Concept map
    11 concepts; 1 descendant hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    Each proof establishes this claim relative to its assumptions.

    In the paper

    • page 16 of this submission's paper

    Lean source view on GitHub

    1import Lax528502.DisjointPaths
    2import Lax528502.ColoringGadgets
    3
    4/-!
    5---
    6title: The ordered-clique graph and its contraction sequence
    7type: lemma
    8---
    9The disjoint paths reduction assigns a position to each vertex and each arc,
    10and one extra position to the dummy vertex. Incoming and outgoing arcs are
    11processed in topological order by optional exchanges of two positions.
    12Copies of the ordered cliques align each modified crossing edge with a block
    13boundary. After deleting the dummy, merge the prefixes of the blocks from
    14right to left and then contract consecutive blocks (Section 5).
    15-/
    16
    17namespace Lax528502.CliqueConstruction
    18
    19open ColoringGadgets
    20
    21abbrev Step := EdgePattern ℕ
    22
    23/-- Exchange p and q optionally, restoring every intermediate position. -/
    24def exchange (p q : ℕ) : List Step :=
    25 let moves := (List.range (q - p - 1)).map fun i =>
    26 EdgePattern.swap (p + i) (p + i + 1)
    27 moves ++ [.choice (q - 1) q] ++ moves.reverse
    28
    29structure Plan where
    30 colors : ℕ
    31 steps : List Step
    32
    33/-- Number sources, sinks, and old vertices, add private terminal arcs, and
    34process the vertices in a topological order. All positions start at 0. -/
    35def plan (n : ℕ) (arcs terminals : List (ℕ × ℕ)) : Plan :=
    36 let pairs := terminals.zipIdx
    37 let old := fun v => 2 * terminals.length + v
    38 let vertices := pairs.map (fun (_, h) => 2*h) ++ (List.range n).map old ++
    39 pairs.map (fun (_, h) => 2*h+1)
    40 let edges := pairs.map (fun ((s,_), h) => (2*h, old s)) ++
    41 arcs.map (fun (u,v) => (old u, old v)) ++ pairs.map (fun ((_,t), h) => (old t, 2*h+1))
    42 let indexed := edges.zipIdx
    43 let transfers := fun v (arcsAtVertex : List ((ℕ × ℕ) × ℕ)) =>
    44 arcsAtVertex.flatMap fun (_, i) => exchange v (vertices.length + i)
    45 let route := vertices.flatMap fun v =>
    46 transfers v (indexed.filter fun ((_,t), _) => t == v) ++
    47 transfers v (indexed.filter fun ((s,_), _) => s == v)
    48 let active := vertices.length + edges.length
    49 let free := (List.range active).filter fun p => !(p < 2 * pairs.length && p % 2 == 1)
    50 let permute := free.flatMap fun p => (free.filter (p < ·)).flatMap (exchange p)
    51 let swaps := pairs.map fun (_, h) => EdgePattern.swap (2*h) (2*h+1)
    52 ⟨active + 1, .copy :: route ++ permute ++ swaps⟩
    53
    54/-- Insert at least one copy before each operation and at the closing edge.
    55If the left position is p, the new column has index p+2 modulo m=k−1. -/
    56def pad (m previous : ℕ) : List Step → List Step
    57 | [] => List.replicate (m - previous % m) .copy
    58 | step :: rest =>
    59 let copies := match step with
    60 | .copy => 1
    61 | .swap p _ | .choice p _ => 1 + (p % m + (m - previous % m)) % m
    62 List.replicate copies .copy ++ step :: pad m (previous + copies + 1) rest
    63
    64/-- Check the congruence of every special step and of the total column count. -/
    65def Aligned (m previous : ℕ) : List Step → Prop
    66 | [] => previous % m = 0
    67 | .copy :: xs => Aligned m (previous + 1) xs
    68 | .swap p _ :: xs | .choice p _ :: xs =>
    69 (previous + 1) % m = (p + 2) % m ∧ Aligned m (previous + 1) xs
    70
    71/-- Padding places every modified crossing edge at the prescribed block boundary. -/
    72axiom padding_aligns (m : ℕ) (hm : 0 < m) (previous : ℕ) (ops : List Step) :
    73 Aligned m previous (pad m previous ops)
    74
    75/-- Delete the dummy vertex of column 0 and use the vertex numbering C−1. -/
    76def vertexCount (k : ℕ) (steps : List Step) : ℕ := k * (steps.length + 1) - 1
    77
    78def graph (k : ℕ) (steps : List Step) : SimpleGraph (Fin (vertexCount k steps)) :=
    79 let column := fun (v : Fin (vertexCount k steps)) => (v.val + 1) / k
    80 let position := fun (v : Fin (vertexCount k steps)) => k - 1 - ((v.val + 1) % k)
    81 let forward := fun u v =>
    82 (column v = column u + 1 ∧ (steps[column u]?.getD .copy).Edge (position u) (position v)) ∨
    83 (column u = steps.length ∧ column v = 0 ∧ position u < position v)
    84 { Adj := fun u v => u ≠ v ∧ (column u = column v ∨ forward u v ∨ forward v u)
    85 symm := ⟨fun _ _ ⟨hne, h⟩ => ⟨hne.symm, h.elim (fun e => Or.inl e.symm)
    86 (fun e => Or.inr e.symm)⟩⟩
    87 loopless := ⟨fun _ h => h.1 rfl⟩ }
    88
    89/-- The pair (a,b) means that the part represented by b joins the part
    90represented by a. First grow every block prefix, then merge adjacent blocks. -/
    91def merges (blockSize blocks : ℕ) : List (ℕ × ℕ) :=
    92 let grow := (List.range (blockSize - 1)).flatMap fun j =>
    93 (List.range blocks).reverse.map fun i => (blockSize*i, blockSize*i+j+1)
    94 grow ++ (List.range (blocks - 1)).map fun i => (0, blockSize*(i+1))
    95
    96def representative (ms : List (ℕ × ℕ)) (v : ℕ) : ℕ :=
    97 ms.foldl (fun part (a,b) => if part = b then a else part) v
    98
    99/-- Serialize the graph, followed by the equivalence matrix after every
    100prefix of the merge list, in the coloring input format. -/
    101noncomputable def Plan.words (P : Plan) : List ℕ :=
    102 let k := P.colors
    103 let steps := pad (k-1) 0 P.steps
    104 let n := vertexCount k steps
    105 let ms := merges (k-1) (n / (k-1))
    106 let partitions := (List.range (ms.length + 1)).flatMap fun i =>
    107 let rep := representative (ms.take i)
    108 ContractionInput.matrix n n fun u v => rep u.val = rep v.val
    109 k :: ContractionInput.graph (Equiv.refl _) (graph k steps) ++ [ms.length] ++ partitions
    110
    111/-- The graph, color count, and explicit 2-sequence prescribed on a DAG input. -/
    112noncomputable def words (I : DisjointPaths.Instance) : List ℕ := by
    113 classical
    114 let arcs := (List.ofFn fun (u : Fin I.n) => (List.ofFn id).filterMap fun v =>
    115 if I.arc u v then some (u.val,v.val) else none).flatten
    116 exact (plan I.n arcs (I.terminals.map fun (s,t) => (s.val,t.val))).words
    117
    118end Lax528502.CliqueConstruction
    119
    Show Proof

    Discussion

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

    Loading discussion…