Documentation

Complexitylib.Models.FiniteAutomaton.OneWayLiveness.Internal.Wiring

One-way-liveness proof: Wiring #

Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a. Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Combinatorics/Automata/Wiring.lean

Module and namespace names, imports, and formatting are adapted to complexitylib. The machine definitions are shared through Models.FiniteAutomaton.Defs.

A perfect matching of ports, represented by a symmetric fixed-point-free relation.

  • symm {x y : P} : self.link x y → self.link y x
  • irrefl (x : P) : ¬self.link x x
  • unique (x : P) : ∃! y : P, self.link x y
Instances For
    theorem Complexity.FiniteAutomaton.Pairing.ext {P : Type u_1} {x y : Pairing P} (link : x.link = y.link) :
    x = y
    noncomputable def Complexity.FiniteAutomaton.Pairing.mate {P : Type u_1} (a : Pairing P) (x : P) :
    P

    The unique port paired with the given port.

    Equations
    Instances For
      theorem Complexity.FiniteAutomaton.Pairing.eq_mate {P : Type u_1} (a : Pairing P) {x y : P} (h : a.link x y) :
      y = a.mate x
      theorem Complexity.FiniteAutomaton.Pairing.mate_ne {P : Type u_1} (a : Pairing P) (x : P) :
      a.mate x ≠ x
      def Complexity.FiniteAutomaton.Pairing.Compatible {P : Type u_1} (a : Pairing P) {C : Type u_2} (color : P → C) :

      An assignment obeys all wire equalities.

      Equations
      Instances For

        The equivalence relation whose classes are the pairs.

        Equations
        Instances For
          theorem Complexity.FiniteAutomaton.Pairing.connected_symm {P : Type u_1} (a : Pairing P) {x y : P} (h : a.connected x y) :
          a.connected y x
          theorem Complexity.FiniteAutomaton.Pairing.connected_trans {P : Type u_1} (a : Pairing P) {x y z : P} (h : a.connected x y) (k : a.connected y z) :
          a.connected x z
          noncomputable def Complexity.FiniteAutomaton.Pairing.testColor {P : Type u_1} (a : Pairing P) (x y : P) :

          The Boolean indicator of the pairing component containing a chosen port.

          Equations
          Instances For
            @[simp]
            theorem Complexity.FiniteAutomaton.Pairing.eq_of_compatible {P : Type u_1} (a : Pairing P) {b : Pairing P} (h : ∀ (c : P → Bool), a.Compatible c ↔ b.Compatible c) :
            a = b

            Two-color constraints remember an entire matching, not just rank or connectivity among one side of its ports.

            theorem Complexity.FiniteAutomaton.FiniteWiring.leaves_card_le_two {V : Type u_1} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] (hc : G.Connected) (hd : ∀ (v : V), G.degree v ≤ 2) :
            {v : V | G.degree v = 1}.card ≤ 2

            A finite connected graph with degrees at most two has at most two leaves. The proof uses the degree-sum formula and the edge-count bound for a connected graph.

            theorem Complexity.FiniteAutomaton.FiniteWiring.unique_other_leaf {V : Type u_1} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] (hc : G.Connected) (hd : ∀ (v : V), G.degree v ≤ 2) (x : V) (hx : G.degree x = 1) :
            ∃! y : V, y ≠ x ∧ G.degree y = 1

            In a finite connected graph of maximum degree two, a leaf has exactly one other leaf.

            Passing to a connected component preserves every vertex degree.

            theorem Complexity.FiniteAutomaton.FiniteWiring.unique_reachable_leaf {V : Type u_1} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] (hd : ∀ (v : V), G.degree v ≤ 2) (x : V) (hx : G.degree x = 1) :
            ∃! y : V, y ≠ x ∧ G.degree y = 1 ∧ G.Reachable x y

            Maximum degree two makes the reachable boundary pairing unique, even when other connected components are cycles.

            noncomputable def Complexity.FiniteAutomaton.FiniteWiring.boundaryPairing {V : Type u_1} [Fintype V] (G : SimpleGraph V) {P : Type u_2} (port : P ↪ V) [DecidableRel G.Adj] (hd : ∀ (v : V), G.degree v ≤ 2) (hb : ∀ (v : V), G.degree v = 1 ↔ ∃ (p : P), port p = v) :

            Contract all path components onto their boundary. The degree assumptions are precisely degree one at the exposed ports and degree zero or two elsewhere. Closed components disappear.

            Equations
            Instances For
              theorem Complexity.FiniteAutomaton.FiniteWiring.color_eq_of_reachable {V : Type u_1} (G : SimpleGraph V) {C : Type u_2} (color : V → C) (hc : ∀ (x y : V), G.Adj x y → color x = color y) {x y : V} (h : G.Reachable x y) :
              color x = color y

              Edge-compatible colors are constant along any finite path.

              theorem Complexity.FiniteAutomaton.FiniteWiring.coloring_extension {V : Type u_1} [Fintype V] (G : SimpleGraph V) {P : Type u_2} (port : P ↪ V) [DecidableRel G.Adj] (hd : ∀ (v : V), G.degree v ≤ 2) (hb : ∀ (v : V), G.degree v = 1 ↔ ∃ (p : P), port p = v) (color : P → Bool) :
              (boundaryPairing G port hd hb).Compatible color ↔ ∃ (c : V → Bool), (∀ (p : P), c (port p) = color p) ∧ ∀ (x y : V), G.Adj x y → c x = c y

              Every compatible boundary coloring extends through the wiring. This justifies replacing a cell's wiring by its boundary matching.

              def Complexity.FiniteAutomaton.Pairing.glueAdj {A : Type u_1} {B : Type u_2} {C : Type u_3} (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) :
              (A ⊕ B) ⊕ B ⊕ C → (A ⊕ B) ⊕ B ⊕ C → Prop

              Adjacency in the glued pairing graph.

              Equations
              Instances For
                def Complexity.FiniteAutomaton.Pairing.glueGraph {A : Type u_1} {B : Type u_2} {C : Type u_3} (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) :
                SimpleGraph ((A ⊕ B) ⊕ B ⊕ C)

                Keep the two copies of the interface separate and join them by edges. This subdivision avoids parallel edges without changing boundary paths.

                Equations
                Instances For
                  def Complexity.FiniteAutomaton.Pairing.outer {A : Type u_1} {B : Type u_2} {C : Type u_3} :
                  A ⊕ C ↪ (A ⊕ B) ⊕ B ⊕ C

                  Embed the external ports into the disjoint union of two glued diagrams.

                  Equations
                  Instances For
                    @[instance_reducible]
                    noncomputable instance Complexity.FiniteAutomaton.Pairing.glueDec {A : Type u_1} {B : Type u_2} {C : Type u_3} (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) :
                    Equations
                    theorem Complexity.FiniteAutomaton.Pairing.glue_degree_LL {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (i : A) :
                    theorem Complexity.FiniteAutomaton.Pairing.glue_degree_RR {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (i : C) :
                    theorem Complexity.FiniteAutomaton.Pairing.glue_degree_LR {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (i : B) :
                    theorem Complexity.FiniteAutomaton.Pairing.glue_degree_RL {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (i : B) :
                    theorem Complexity.FiniteAutomaton.Pairing.glue_degree_le_two {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (v : (A ⊕ B) ⊕ B ⊕ C) :
                    (a.glueGraph b).degree v ≤ 2
                    theorem Complexity.FiniteAutomaton.Pairing.glue_boundary {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (v : (A ⊕ B) ⊕ B ⊕ C) :
                    (a.glueGraph b).degree v = 1 ↔ ∃ (p : A ⊕ C), outer p = v
                    noncomputable def Complexity.FiniteAutomaton.Pairing.compose {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) :
                    Pairing (A ⊕ C)

                    Glue along the common interface and pair the surviving external ports.

                    Equations
                    Instances For
                      theorem Complexity.FiniteAutomaton.Pairing.compose_compatible {A : Type u_1} {B : Type u_2} {C : Type u_3} [Fintype A] [Fintype B] [Fintype C] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (f : A → Bool) (g : C → Bool) :
                      (a.compose b).Compatible (Sum.elim f g) ↔ ∃ (k : B → Bool), a.Compatible (Sum.elim f k) ∧ b.Compatible (Sum.elim k g)

                      Boolean boundary behavior composes as ordinary relational composition.

                      def Complexity.FiniteAutomaton.Pairing.ofInvolution {P : Type u_1} (f : P → P) (hf : Function.Involutive f) (hn : ∀ (p : P), f p ≠ p) :

                      The perfect matching given by a fixed-point-free involution.

                      Equations
                      Instances For
                        def Complexity.FiniteAutomaton.Pairing.transport {P : Type u_1} {Q : Type u_2} (a : Pairing P) (e : P ≃ Q) :

                        Rename the ports of a pairing along an equivalence.

                        Equations
                        Instances For
                          def Complexity.FiniteAutomaton.Pairing.bijection {A : Type u_3} {B : Type u_4} (e : A ≃ B) :
                          Pairing (A ⊕ B)

                          A rectangular permutation diagram; arbitrary equivalences also allow renumbering finite port sets without changing the underlying diagram.

                          Equations
                          Instances For

                            The pairing that connects each left port to its equal right port.

                            Equations
                            Instances For
                              theorem Complexity.FiniteAutomaton.Pairing.bijection_compatible {A : Type u_3} {B : Type u_4} (e : A ≃ B) (f : A → Bool) (g : B → Bool) :
                              (bijection e).Compatible (Sum.elim f g) ↔ ∀ (x : A), f x = g (e x)
                              theorem Complexity.FiniteAutomaton.Pairing.ext_colors {A : Type u_3} {B : Type u_4} {a b : Pairing (A ⊕ B)} (h : ∀ (f : A → Bool) (g : B → Bool), a.Compatible (Sum.elim f g) ↔ b.Compatible (Sum.elim f g)) :
                              a = b
                              theorem Complexity.FiniteAutomaton.Pairing.connected_of_color_eq {P : Type u_1} (a : Pairing P) (x y : P) (h : ∀ (c : P → Bool), a.Compatible c → c x = c y) :
                              a.connected x y

                              The Boolean equality semantics is faithful even for a single pair.

                              theorem Complexity.FiniteAutomaton.Pairing.compose_assoc {A : Type u_3} {B : Type u_4} {C : Type u_5} {D : Type u_6} [Fintype A] [Fintype B] [Fintype C] [Fintype D] (a : Pairing (A ⊕ B)) (b : Pairing (B ⊕ C)) (c : Pairing (C ⊕ D)) :
                              (a.compose b).compose c = a.compose (b.compose c)