Construction sequences

Lax185574.ConstructionSequences · concepts/Lax185574/ConstructionSequences.lean · lax-185574

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

    For colors P, Q and a partial graph G, the partial graphs merge_{P,Q}(G) (for P ≠ Q), resolve⁺{P,Q}(G) and resolve⁻{P,Q}(G) are obtained from G by leaving everything unchanged, apart from the following:

    • merge_{P,Q}(G): P^H = P^G ∪ Q^G and Q^H = ∅, for P ≠ Q;
    • resolve⁺_{P,Q}(G): E(H) = E(G) ∪ (P^G Q^G ∖ N(G));
    • resolve⁻_{P,Q}(G): N(H) = N(G) ∪ (P^G Q^G ∖ E(G)).

    Here P^G Q^G is the set of pairs xy of distinct vertices with x ∈ P^G and y ∈ Q^G. After either resolve, every pair in P^G Q^G is resolved.

    An initial partial graph has no resolved pairs, and every part is a singleton. A construction sequence of a graph G = (V, E) is a sequence G₁, …, G_λ of partial graphs with vertex set V such that G₁ is initial, every step is one merge or one resolve, and G_λ has a single part, E(G_λ) = E and N(G_λ) = (V choose 2) ∖ E.

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

    In the paper

    • page 40 of this submission's paper
    • page 7 of this submission's paper

    Lean source view on GitHub

    1import Lax185574.PartialGraphs
    2
    3/-!
    4---
    5title: Construction sequences
    6type: definition
    7---
    8For colors P, Q and a partial graph G, the partial graphs merge_{P,Q}(G)
    9(for P ≠ Q), resolve⁺_{P,Q}(G) and resolve⁻_{P,Q}(G) are obtained from G
    10by leaving everything unchanged, apart from the following:
    11
    12- merge_{P,Q}(G): P^H = P^G ∪ Q^G and Q^H = ∅, for P ≠ Q;
    13- resolve⁺_{P,Q}(G): E(H) = E(G) ∪ (P^G Q^G ∖ N(G));
    14- resolve⁻_{P,Q}(G): N(H) = N(G) ∪ (P^G Q^G ∖ E(G)).
    15
    16Here P^G Q^G is the set of pairs xy of distinct vertices with x ∈ P^G and
    17y ∈ Q^G. After either resolve, every pair in P^G Q^G is resolved.
    18
    19An *initial* partial graph has no resolved pairs, and every part is a
    20singleton. A *construction sequence* of a graph G = (V, E) is a sequence
    21G₁, …, G_λ of partial graphs with vertex set V such that G₁ is initial,
    22every step is one merge or one resolve, and G_λ has a single part,
    23E(G_λ) = E and N(G_λ) = (V choose 2) ∖ E.
    24
    25# Formalization notes
    26
    27A sequence is a nonempty list of partial graphs. Its first entry is G₁,
    28and the step condition relates consecutive entries `s[t]` and `s[t+1]`.
    29"Every part is a singleton" says that the coloring is injective, and "a
    30single part" says that all vertices have the same color. The colors P
    31and Q of a step are arbitrary natural numbers, as in the paper. A resolve naming a color that no vertex
    32has, or a merge whose second color no vertex has, changes nothing, and
    33is still counted as a step. Such steps only lengthen a sequence. The pairs `P^G Q^G` are built with `SimpleGraph.fromRel`,
    34which symmetrizes the relation and removes the diagonal.
    35
    36The paper defines construction sequences twice, in the technical
    37overview through merges and resolves of parts, and in the preliminaries
    38of the model-checking part through the operators on colors above. Both
    39passages describe the same sequences. A merge of two distinct parts is a
    40merge of their colors, and a resolve of two parts is a resolve of their
    41colors.
    42
    43Algorithms receive and produce a construction sequence on `Fin n` as a
    44`Script`: the colors of the initial partial graph, which has no resolved
    45pairs, and the list of the steps. `Script.run` is the sequence it
    46produces, the initial partial graph followed by the results of the
    47steps. The derived encoding of `Lax185574.Encoding` writes a script as
    48n, the n colors, the number of steps, and then each step as three
    49numbers, an opcode (0 for a merge, 1 for a positive resolve and 2 for a
    50negative resolve) followed by the colors P and Q. Nothing in a script
    51forces its colors to be distinct, or its sequence to be a construction
    52sequence of a particular graph. Those are properties of the sequence,
    53stated through `IsConstructionSequence` where they are needed.
    54-/
    55
    56namespace Lax185574.ConstructionSequences
    57
    58open Lax185574.PartialGraphs
    59
    60universe z
    61
    62variable {V : Type z}
    63
    64/-- The pairs `P^G Q^G`: distinct vertices, one of color `P` and the
    65other of color `Q`. -/
    66def between (G : PartialGraph V) (P Q : ℕ) : SimpleGraph V :=
    67 SimpleGraph.fromRel fun x y => G.color x = P ∧ G.color y = Q
    68
    69/-- `merge_{P,Q}(G)`: the vertices of color `Q` get color `P`. -/
    70def merge (G : PartialGraph V) (P Q : ℕ) : PartialGraph V :=
    71 { G with color := fun v => if G.color v = Q then P else G.color v }
    72
    73/-- `resolve⁺_{P,Q}(G)`: the unresolved pairs in `P^G Q^G` become
    74edges. -/
    75def resolvePos (G : PartialGraph V) (P Q : ℕ) : PartialGraph V where
    76 edge := G.edge ⊔ (between G P Q \ G.nonEdge)
    77 nonEdge := G.nonEdge
    78 disjoint := disjoint_sup_left.2 ⟨G.disjoint, disjoint_sdiff_self_left⟩
    79 color := G.color
    80
    81/-- `resolve⁻_{P,Q}(G)`: the unresolved pairs in `P^G Q^G` become
    82non-edges. -/
    83def resolveNeg (G : PartialGraph V) (P Q : ℕ) : PartialGraph V where
    84 edge := G.edge
    85 nonEdge := G.nonEdge ⊔ (between G P Q \ G.edge)
    86 disjoint := disjoint_sup_right.2 ⟨G.disjoint, disjoint_sdiff_self_right⟩
    87 color := G.color
    88
    89/-- An initial partial graph: no resolved pairs, and every part is a
    90singleton. -/
    91def IsInitial (G : PartialGraph V) : Prop :=
    92 G.edge = ⊥ ∧ G.nonEdge = ⊥ ∧ Function.Injective G.color
    93
    94/-- `H` is obtained from `G` by one merge or one resolve. -/
    95def IsStep (G H : PartialGraph V) : Prop :=
    96 ∃ P Q : ℕ, (P ≠ Q ∧ H = merge G P Q) ∨ H = resolvePos G P Q ∨
    97 H = resolveNeg G P Q
    98
    99/-- `s` is a construction sequence of the graph `G`: it starts with an
    100initial partial graph, each entry is obtained from the previous one by
    101one merge or one resolve, and the last entry has a single part, the
    102edges of `G` as edges and the non-edges of `G` as non-edges. -/
    103def IsConstructionSequence (G : SimpleGraph V) (s : List (PartialGraph V)) :
    104 Prop :=
    105 ∃ h : s ≠ [],
    106 IsInitial (s.head h) ∧
    107 (∀ (t : ℕ) (ht : t + 1 < s.length), IsStep s[t] s[t + 1]) ∧
    108 (∀ u v : V, (s.getLast h).color u = (s.getLast h).color v) ∧
    109 (s.getLast h).edge = G ∧ (s.getLast h).nonEdge = Gᶜ
    110
    111open Lax185574.Encoding
    112
    113/-- One step of a construction sequence. -/
    114inductive Step
    115 /-- `merge_{P,Q}`. -/
    116 | merge (P Q : ℕ)
    117 /-- `resolve⁺_{P,Q}`. -/
    118 | resolvePos (P Q : ℕ)
    119 /-- `resolve⁻_{P,Q}`. -/
    120 | resolveNeg (P Q : ℕ)
    121 deriving Encode
    122
    123/-- The partial graph obtained by applying a step. -/
    124def apply (G : PartialGraph V) : Step → PartialGraph V
    125 | .merge P Q => merge G P Q
    126 | .resolvePos P Q => resolvePos G P Q
    127 | .resolveNeg P Q => resolveNeg G P Q
    128
    129/-- The partial graph with no resolved pairs and the given colors. -/
    130def unresolved (color : V → ℕ) : PartialGraph V where
    131 edge := ⊥
    132 nonEdge := ⊥
    133 disjoint := disjoint_bot_left
    134 color := color
    135
    136/-- A construction script on `Fin n`: the colors of the initial partial
    137graph, which has no resolved pairs, and the steps. -/
    138structure Script (n : ℕ) where
    139 /-- The colors of the initial partial graph. -/
    140 colors : Fin n → ℕ
    141 /-- The steps, in order. -/
    142 steps : List Step
    143 deriving Encode
    144
    145/-- The sequence produced by a script: the initial partial graph
    146followed by the results of the steps. -/
    147def Script.run {n : ℕ} (σ : Script n) : List (PartialGraph (Fin n)) :=
    148 σ.steps.scanl apply (unresolved σ.colors)
    149
    150/-- Every number in the encoding of the script `σ` is at most the
    151length of the encoding plus `n`. This holds when the colors of the
    152initial partial graph and of the steps are vertices. It lets an
    153algorithm pass the script on to another one, whose word length depends
    154on the numbers of its input. -/
    155def Script.HasSmallNumbers {n : ℕ} (σ : Script n) : Prop :=
    156 ∀ v ∈ encode σ, v ≤ (encode σ).length + n
    157
    158/-- The list `y` encodes the sequence `s` of partial graphs on `n`
    159vertices: it is the encoding of a script that produces `s`. -/
    160def EncodesSequence {n : ℕ} (y : List ℕ) (s : List (PartialGraph (Fin n))) :
    161 Prop :=
    162 ∃ σ : Script n, y = encode σ ∧ s = σ.run
    163
    164end Lax185574.ConstructionSequences
    165
    Formalization notes

    A sequence is a nonempty list of partial graphs. Its first entry is G₁, and the step condition relates consecutive entries s[t]s[t] and s[t+1]s[t+1]. "Every part is a singleton" says that the coloring is injective, and "a single part" says that all vertices have the same color. The colors P and Q of a step are arbitrary natural numbers, as in the paper. A resolve naming a color that no vertex has, or a merge whose second color no vertex has, changes nothing, and is still counted as a step. Such steps only lengthen a sequence. The pairs PGQGP^G Q^G are built with SimpleGraph.fromRelSimpleGraph.fromRel, which symmetrizes the relation and removes the diagonal.

    The paper defines construction sequences twice, in the technical overview through merges and resolves of parts, and in the preliminaries of the model-checking part through the operators on colors above. Both passages describe the same sequences. A merge of two distinct parts is a merge of their colors, and a resolve of two parts is a resolve of their colors.

    Algorithms receive and produce a construction sequence on FinnFin n as a ScriptScript: the colors of the initial partial graph, which has no resolved pairs, and the list of the steps. Script.runScript.run is the sequence it produces, the initial partial graph followed by the results of the steps. The derived encoding of Lax185574.EncodingLax185574.Encoding writes a script as n, the n colors, the number of steps, and then each step as three numbers, an opcode (0 for a merge, 1 for a positive resolve and 2 for a negative resolve) followed by the colors P and Q. Nothing in a script forces its colors to be distinct, or its sequence to be a construction sequence of a particular graph. Those are properties of the sequence, stated through IsConstructionSequenceIsConstructionSequence where they are needed.

    Discussion

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

    Loading discussion…