Documentation

CslibFrontier.Algorithms.ShortestPaths.NegativeTriangle

Negative triangles #

A weighted tripartite graph with parts I, J, K is given by three matrices over MinTropical R: A : Matrix I K _ holds the weights of the edges between I and K, B : Matrix K J _ those between K and J, and C : Matrix I J _ those between I and J. The tropical zero 0 = ⊤ means that there is no edge. A triple (i, j, k) is a negative triangle if w(i, k) + w(k, j) + w(i, j) < 0 in R; a missing edge has weight ⊤, so a negative triangle uses three edges. This is the negative triangle problem of Vassilevska Williams and Williams over the (min,+) structure, in its tripartite form (Section 2, "Negative Triangles Over Structures").

The pair (i, j) lies on a negative triangle exactly when (A * B) i j + C i j < 0, because the (min,+) product entry (A * B) i j is the minimum of w(i, k) + w(k, j) over k (onNegTriangle_iff). This is the link between negative triangles and (min,+) products used in both directions of the equivalence.

Padding a graph with isolated vertices (padIsolated) creates no negative triangles (onNegTriangle_padIsolated); it lets the blocking reduction run on any number of vertices.

Main definitions #

Main results #

References #

def Cslib.Algorithms.ShortestPaths.IsNegTriangle {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) (k : K) :

(i, j, k) is a negative triangle of the tripartite graph (A, B, C): the weights of the edges i k, k j and i j add up to a negative number.

Instances For
    def Cslib.Algorithms.ShortestPaths.OnNegTriangle {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) :

    The pair (i, j) lies on a negative triangle.

    Instances For
      def Cslib.Algorithms.ShortestPaths.HasNegTriangle {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) :

      The tripartite graph (A, B, C) has a negative triangle.

      Instances For
        def Cslib.Algorithms.ShortestPaths.IsNegTriangleAnswer {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) :
        Option (I × J × K) → Prop

        The specification of negative triangle finding: none means that there is no negative triangle, and some (i, j, k) means that (i, j, k) is one.

        @[instance_reducible]
        instance Cslib.Algorithms.ShortestPaths.instDecidableIsNegTriangle {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) (k : K) :
        Decidable (IsNegTriangle A B C i j k)
        @[instance_reducible]
        instance Cslib.Algorithms.ShortestPaths.instDecidableOnNegTriangleOfFintype {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} [Fintype K] (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) :
        @[instance_reducible]
        theorem Cslib.Algorithms.ShortestPaths.IsNegTriangle.ne_zero_left {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} {A : Matrix I K (MinTropical R)} {B : Matrix K J (MinTropical R)} {C : Matrix I J (MinTropical R)} {i : I} {j : J} {k : K} (h : IsNegTriangle A B C i j k) :
        A i k ≠ 0
        theorem Cslib.Algorithms.ShortestPaths.IsNegTriangle.ne_zero_right {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} {A : Matrix I K (MinTropical R)} {B : Matrix K J (MinTropical R)} {C : Matrix I J (MinTropical R)} {i : I} {j : J} {k : K} (h : IsNegTriangle A B C i j k) :
        C i j ≠ 0
        theorem Cslib.Algorithms.ShortestPaths.isNegTriangle_submatrix {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} {I' : Type u_5} {J' : Type u_6} {K' : Type u_7} (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (f : I' → I) (g : J' → J) (h : K' → K) (i : I') (j : J') (k : K') :
        IsNegTriangle (A.submatrix f h) (B.submatrix h g) (C.submatrix f g) i j k ↔ IsNegTriangle A B C (f i) (g j) (h k)

        Relabelling the three parts maps negative triangles to negative triangles.

        Padding with isolated vertices #

        def Cslib.Algorithms.ShortestPaths.padIsolated {α : Type u_5} [Zero α] {I₀ : Type u_6} {I₁ : Type u_7} {J₀ : Type u_8} {J₁ : Type u_9} {U : Type u_10} {V : Type u_11} (e : U ≃ I₀ ⊕ I₁) (e' : V ≃ J₀ ⊕ J₁) (A : Matrix I₀ J₀ α) :
        Matrix U V α

        Add isolated vertices: padIsolated e e' A is A on the image of Sum.inl and 0 (no edge) elsewhere, relabelled along e : U ≃ I₀ ⊕ I₁ and e' : V ≃ J₀ ⊕ J₁.

        theorem Cslib.Algorithms.ShortestPaths.padIsolated_apply_inl {α : Type u_5} [Zero α] {I₀ : Type u_6} {I₁ : Type u_7} {J₀ : Type u_8} {J₁ : Type u_9} {U : Type u_10} {V : Type u_11} (e : U ≃ I₀ ⊕ I₁) (e' : V ≃ J₀ ⊕ J₁) (A : Matrix I₀ J₀ α) (i : I₀) (j : J₀) :
        padIsolated e e' A (e.symm (Sum.inl i)) (e'.symm (Sum.inl j)) = A i j
        theorem Cslib.Algorithms.ShortestPaths.padIsolated_apply_eq_zero {α : Type u_5} [Zero α] {I₀ : Type u_6} {I₁ : Type u_7} {J₀ : Type u_8} {J₁ : Type u_9} {U : Type u_10} {V : Type u_11} (e : U ≃ I₀ ⊕ I₁) (e' : V ≃ J₀ ⊕ J₁) (A : Matrix I₀ J₀ α) {u : U} {v : V} (h : padIsolated e e' A u v ≠ 0) :
        ∃ (i : I₀) (j : J₀), e u = Sum.inl i ∧ e' v = Sum.inl j
        theorem Cslib.Algorithms.ShortestPaths.padIsolated_forall {α : Type u_5} [Zero α] {I₀ : Type u_6} {I₁ : Type u_7} {J₀ : Type u_8} {J₁ : Type u_9} {U : Type u_10} {V : Type u_11} {p : α → Prop} (h0 : p 0) (e : U ≃ I₀ ⊕ I₁) (e' : V ≃ J₀ ⊕ J₁) {A : Matrix I₀ J₀ α} (hA : ∀ (i : I₀) (j : J₀), p (A i j)) (u : U) (v : V) :
        p (padIsolated e e' A u v)

        Every entry of padIsolated e e' A is either 0 or an entry of A, so any entry predicate closed under 0 is preserved by padding.

        theorem Cslib.Algorithms.ShortestPaths.onNegTriangle_padIsolated {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} {I₁ : Type u_5} {J₁ : Type u_6} {K₁ : Type u_7} {U : Type u_8} {V : Type u_9} {W : Type u_10} (eI : U ≃ I ⊕ I₁) (eJ : V ≃ J ⊕ J₁) (eK : W ≃ K ⊕ K₁) (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) :
        OnNegTriangle (padIsolated eI eK A) (padIsolated eK eJ B) (padIsolated eI eJ C) (eI.symm (Sum.inl i)) (eJ.symm (Sum.inl j)) ↔ OnNegTriangle A B C i j

        Isolated vertices create no negative triangles. After padding all three parts, the pairs of original vertices on a negative triangle are exactly the original ones.

        theorem Cslib.Algorithms.ShortestPaths.onNegTriangle_iff {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} [Fintype K] (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) (i : I) (j : J) :
        OnNegTriangle A B C i j ↔ MinTropical.untrop ((A * B) i j) + MinTropical.untrop (C i j) < 0

        Negative triangles and (min,+) products. The pair (i, j) lies on a negative triangle iff (A * B) i j + C i j < 0.

        theorem Cslib.Algorithms.ShortestPaths.hasNegTriangle_iff {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {I : Type u_2} {J : Type u_3} {K : Type u_4} [Fintype K] (A : Matrix I K (MinTropical R)) (B : Matrix K J (MinTropical R)) (C : Matrix I J (MinTropical R)) :
        HasNegTriangle A B C ↔ ∃ (i : I) (j : J), MinTropical.untrop ((A * B) i j) + MinTropical.untrop (C i j) < 0

        The tripartite graph has a negative triangle iff (A * B) i j + C i j < 0 for some (i, j).

        Bounded entries #

        Every finite entry of A lies in [-W, W]; ⊤ (no edge) entries are allowed. This is the weight range {-W, …, W} ∪ {∞} of Vassilevska Williams and Williams with maxint W, without -∞.

        Increasing the bound preserves FiniteEntriesBounded.

        theorem Cslib.Algorithms.ShortestPaths.FiniteEntriesBounded.submatrix {I : Type u_2} {J : Type u_3} {I' : Type u_11} {J' : Type u_12} {A : Matrix I J (MinTropical (WithTop ℤ))} {M : ℕ} (hA : FiniteEntriesBounded A M) (f : I' → I) (g : J' → J) :

        Taking a submatrix preserves FiniteEntriesBounded.

        theorem Cslib.Algorithms.ShortestPaths.FiniteEntriesBounded.padIsolated {I : Type u_2} {J : Type u_3} {I₁ : Type u_5} {J₁ : Type u_6} {U : Type u_8} {V : Type u_9} (e : U ≃ I ⊕ I₁) (e' : V ≃ J ⊕ J₁) {A : Matrix I J (MinTropical (WithTop ℤ))} {M : ℕ} (hA : FiniteEntriesBounded A M) :

        Padding with isolated vertices (0 = ⊤, no edge) preserves FiniteEntriesBounded.

        theorem Cslib.Algorithms.ShortestPaths.FiniteEntriesBounded.mask {I : Type u_2} {J : Type u_3} {A : Matrix I J (MinTropical (WithTop ℤ))} {M : ℕ} (hA : FiniteEntriesBounded A M) (p : I → J → Bool) :
        FiniteEntriesBounded (Matrix.of fun (i : I) (j : J) => if p i j = true then 0 else A i j) M

        Masking entries to 0 (⊤, no edge) preserves FiniteEntriesBounded.

        theorem Cslib.Algorithms.ShortestPaths.FiniteEntriesBounded.mul {I : Type u_2} {J : Type u_3} {K : Type u_4} [Fintype K] {A : Matrix I K (MinTropical (WithTop ℤ))} {B : Matrix K J (MinTropical (WithTop ℤ))} {M : ℕ} (hA : FiniteEntriesBounded A M) (hB : FiniteEntriesBounded B M) :

        If the finite entries of A and B lie in [-M, M], those of the (min,+) product A * B lie in [-2M, 2M].