combinatorics.simple_graph.adj_matrix
⟷
Mathlib.Combinatorics.SimpleGraph.AdjMatrix
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -331,8 +331,8 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
· rintro ⟨x, hx⟩ - ⟨y, hy⟩ - hxy
rw [disjoint_iff_inf_le]
intro p hp
- simp only [inf_eq_inter, mem_inter, mem_map, Function.Embedding.coeFn_mk, exists_prop] at hp
- <;>
+ simp only [inf_eq_inter, mem_inter, mem_map, Function.Embedding.coeFn_mk, exists_prop] at
+ hp <;>
obtain ⟨⟨px, hpx, rfl⟩, ⟨py, hpy, hp⟩⟩ := hp
cases hp
simpa using hxy
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,10 +3,10 @@ Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
-/
-import Mathbin.Combinatorics.SimpleGraph.Basic
-import Mathbin.Combinatorics.SimpleGraph.Connectivity
-import Mathbin.LinearAlgebra.Matrix.Trace
-import Mathbin.LinearAlgebra.Matrix.Symmetric
+import Combinatorics.SimpleGraph.Basic
+import Combinatorics.SimpleGraph.Connectivity
+import LinearAlgebra.Matrix.Trace
+import LinearAlgebra.Matrix.Symmetric
#align_import combinatorics.simple_graph.adj_matrix from "leanprover-community/mathlib"@"75be6b616681ab6ca66d798ead117e75cd64f125"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,17 +2,14 @@
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
-
-! This file was ported from Lean 3 source module combinatorics.simple_graph.adj_matrix
-! leanprover-community/mathlib commit 75be6b616681ab6ca66d798ead117e75cd64f125
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Combinatorics.SimpleGraph.Basic
import Mathbin.Combinatorics.SimpleGraph.Connectivity
import Mathbin.LinearAlgebra.Matrix.Trace
import Mathbin.LinearAlgebra.Matrix.Symmetric
+#align_import combinatorics.simple_graph.adj_matrix from "leanprover-community/mathlib"@"75be6b616681ab6ca66d798ead117e75cd64f125"
+
/-!
# Adjacency Matrices
mathlib commit https://github.com/leanprover-community/mathlib/commit/2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
@@ -159,7 +159,7 @@ theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
#print Matrix.IsAdjMatrix.toGraph_compl_eq /-
theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by
- ext (v w)
+ ext v w
cases' h.zero_or_one v w with h h <;> by_cases hvw : v = w <;> simp [Matrix.compl, h, hvw]
#align matrix.is_adj_matrix.to_graph_compl_eq Matrix.IsAdjMatrix.toGraph_compl_eq
-/
@@ -355,7 +355,7 @@ variable {A : Matrix V V α} (h : IsAdjMatrix A)
then the adjacency matrix of the graph induced by `A` is itself. -/
theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A :=
by
- ext (i j)
+ ext i j
obtain h' | h' := h.zero_or_one i j <;> simp [h']
#align matrix.is_adj_matrix.adj_matrix_to_graph_eq Matrix.IsAdjMatrix.adjMatrix_toGraph_eq
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -68,21 +68,28 @@ namespace IsAdjMatrix
variable {A : Matrix V V α}
+#print Matrix.IsAdjMatrix.apply_diag_ne /-
@[simp]
theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) : ¬A i i = 1 :=
by simp [h.apply_diag i]
#align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_ne
+-/
+#print Matrix.IsAdjMatrix.apply_ne_one_iff /-
@[simp]
theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 1 ↔ A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h]
#align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iff
+-/
+#print Matrix.IsAdjMatrix.apply_ne_zero_iff /-
@[simp]
theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 0 ↔ A i j = 1 := by rw [← apply_ne_one_iff h, Classical.not_not]
#align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iff
+-/
+#print Matrix.IsAdjMatrix.toGraph /-
/-- For `A : matrix V V α` and `h : is_adj_matrix A`,
`h.to_graph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
@@ -92,6 +99,7 @@ def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGra
symm i j hij := by rwa [h.symm.apply i j]
loopless i := by simp [h]
#align matrix.is_adj_matrix.to_graph Matrix.IsAdjMatrix.toGraph
+-/
instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix A) :
DecidableRel h.toGraph.Adj := by simp only [to_graph]; infer_instance
@@ -148,11 +156,13 @@ theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
#align matrix.is_adj_matrix.compl Matrix.IsAdjMatrix.compl
-/
+#print Matrix.IsAdjMatrix.toGraph_compl_eq /-
theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by
ext (v w)
cases' h.zero_or_one v w with h h <;> by_cases hvw : v = w <;> simp [Matrix.compl, h, hvw]
#align matrix.is_adj_matrix.to_graph_compl_eq Matrix.IsAdjMatrix.toGraph_compl_eq
+-/
end IsAdjMatrix
@@ -211,6 +221,7 @@ theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix
#align simple_graph.is_adj_matrix_adj_matrix SimpleGraph.isAdjMatrix_adjMatrix
-/
+#print SimpleGraph.toGraph_adjMatrix_eq /-
/-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
(G.isAdjMatrix_adjMatrix α).toGraph = G := by
@@ -218,27 +229,35 @@ theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
simp only [is_adj_matrix.to_graph_adj, adj_matrix_apply, ite_eq_left_iff, zero_ne_one]
apply Classical.not_not
#align simple_graph.to_graph_adj_matrix_eq SimpleGraph.toGraph_adjMatrix_eq
+-/
variable {α} [Fintype V]
+#print SimpleGraph.adjMatrix_dotProduct /-
@[simp]
theorem adjMatrix_dotProduct [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct (G.adjMatrix α v) vec = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter]
#align simple_graph.adj_matrix_dot_product SimpleGraph.adjMatrix_dotProduct
+-/
+#print SimpleGraph.dotProduct_adjMatrix /-
@[simp]
theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct vec (G.adjMatrix α v) = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter, Finset.sum_apply]
#align simple_graph.dot_product_adj_matrix SimpleGraph.dotProduct_adjMatrix
+-/
+#print SimpleGraph.adjMatrix_mulVec_apply /-
@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).mulVec vec) v = ∑ u in G.neighborFinset v, vec u := by
rw [mul_vec, adj_matrix_dot_product]
#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_apply
+-/
+#print SimpleGraph.adjMatrix_vecMul_apply /-
@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).vecMul vec) v = ∑ u in G.neighborFinset v, vec u :=
@@ -247,44 +266,58 @@ theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
refine' congr rfl _; ext
rw [← transpose_apply (adj_matrix α G) x v, transpose_adj_matrix]
#align simple_graph.adj_matrix_vec_mul_apply SimpleGraph.adjMatrix_vecMul_apply
+-/
+#print SimpleGraph.adjMatrix_mul_apply /-
@[simp]
theorem adjMatrix_mul_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(G.adjMatrix α ⬝ M) v w = ∑ u in G.neighborFinset v, M u w := by
simp [mul_apply, neighbor_finset_eq_filter, sum_filter]
#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_apply
+-/
+#print SimpleGraph.mul_adjMatrix_apply /-
@[simp]
theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(M ⬝ G.adjMatrix α) v w = ∑ u in G.neighborFinset w, M v u := by
simp [mul_apply, neighbor_finset_eq_filter, sum_filter, adj_comm]
#align simple_graph.mul_adj_matrix_apply SimpleGraph.mul_adjMatrix_apply
+-/
variable (α)
+#print SimpleGraph.trace_adjMatrix /-
@[simp]
theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix α) = 0 := by
simp [Matrix.trace]
#align simple_graph.trace_adj_matrix SimpleGraph.trace_adjMatrix
+-/
variable {α}
+#print SimpleGraph.adjMatrix_mul_self_apply_self /-
theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
(G.adjMatrix α ⬝ G.adjMatrix α) i i = degree G i := by simp [degree]
#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_self
+-/
variable {G}
+#print SimpleGraph.adjMatrix_mulVec_const_apply /-
@[simp]
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
(G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp [degree]
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
+-/
+#print SimpleGraph.adjMatrix_mulVec_const_apply_of_regular /-
theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α).mulVec (Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
+-/
+#print SimpleGraph.adjMatrix_pow_apply_eq_card_walk /-
theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ) (u v : V) :
(G.adjMatrix α ^ n) u v = Fintype.card {p : G.Walk u v | p.length = n} :=
by
@@ -307,6 +340,7 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
cases hp
simpa using hxy
#align simple_graph.adj_matrix_pow_apply_eq_card_walk SimpleGraph.adjMatrix_pow_apply_eq_card_walk
+-/
end SimpleGraph
@@ -316,6 +350,7 @@ variable [MulZeroOneClass α] [Nontrivial α]
variable {A : Matrix V V α} (h : IsAdjMatrix A)
+#print Matrix.IsAdjMatrix.adjMatrix_toGraph_eq /-
/-- If `A` is qualified as an adjacency matrix,
then the adjacency matrix of the graph induced by `A` is itself. -/
theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A :=
@@ -323,6 +358,7 @@ theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A :=
ext (i j)
obtain h' | h' := h.zero_or_one i j <;> simp [h']
#align matrix.is_adj_matrix.adj_matrix_to_graph_eq Matrix.IsAdjMatrix.adjMatrix_toGraph_eq
+-/
end Matrix.IsAdjMatrix
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -286,7 +286,7 @@ theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ) (u v : V) :
- (G.adjMatrix α ^ n) u v = Fintype.card { p : G.Walk u v | p.length = n } :=
+ (G.adjMatrix α ^ n) u v = Fintype.card {p : G.Walk u v | p.length = n} :=
by
rw [card_set_walk_length_eq]
induction' n with n ih generalizing u v
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -301,8 +301,8 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
· rintro ⟨x, hx⟩ - ⟨y, hy⟩ - hxy
rw [disjoint_iff_inf_le]
intro p hp
- simp only [inf_eq_inter, mem_inter, mem_map, Function.Embedding.coeFn_mk, exists_prop] at
- hp <;>
+ simp only [inf_eq_inter, mem_inter, mem_map, Function.Embedding.coeFn_mk, exists_prop] at hp
+ <;>
obtain ⟨⟨px, hpx, rfl⟩, ⟨py, hpy, hp⟩⟩ := hp
cases hp
simpa using hxy
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -44,7 +44,7 @@ properties to computational properties of the matrix.
-/
-open BigOperators Matrix
+open scoped BigOperators Matrix
open Finset Matrix SimpleGraph
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -68,45 +68,21 @@ namespace IsAdjMatrix
variable {A : Matrix V V α}
-/- warning: matrix.is_adj_matrix.apply_diag_ne -> Matrix.IsAdjMatrix.apply_diag_ne is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V), Not (Eq.{succ u2} α (A i i) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V), Not (Eq.{succ u2} α (A i i) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_neₓ'. -/
@[simp]
theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) : ¬A i i = 1 :=
by simp [h.apply_diag i]
#align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_ne
-/- warning: matrix.is_adj_matrix.apply_ne_one_iff -> Matrix.IsAdjMatrix.apply_ne_one_iff is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)))))))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α _inst_1)))))
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iffₓ'. -/
@[simp]
theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 1 ↔ A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h]
#align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iff
-/- warning: matrix.is_adj_matrix.apply_ne_zero_iff -> Matrix.IsAdjMatrix.apply_ne_zero_iff is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1))))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α _inst_1))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iffₓ'. -/
@[simp]
theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 0 ↔ A i j = 1 := by rw [← apply_ne_one_iff h, Classical.not_not]
#align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iff
-/- warning: matrix.is_adj_matrix.to_graph -> Matrix.IsAdjMatrix.toGraph is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (SimpleGraph.{u1} V)
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (SimpleGraph.{u1} V)
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.to_graph Matrix.IsAdjMatrix.toGraphₓ'. -/
/-- For `A : matrix V V α` and `h : is_adj_matrix A`,
`h.to_graph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
@@ -172,12 +148,6 @@ theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
#align matrix.is_adj_matrix.compl Matrix.IsAdjMatrix.compl
-/
-/- warning: matrix.is_adj_matrix.to_graph_compl_eq -> Matrix.IsAdjMatrix.toGraph_compl_eq is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} V] {A : Matrix.{u1, u1, u2} V V α} [_inst_3 : MulZeroOneClass.{u2} α] [_inst_4 : Nontrivial.{u2} α] (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) A), Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (Matrix.compl.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A) _inst_3 _inst_4 (Matrix.IsAdjMatrix.compl.{u1, u2} V α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) h)) (HasCompl.compl.{u1} (SimpleGraph.{u1} V) (SimpleGraph.hasCompl.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_3 _inst_4 h))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} V] {A : Matrix.{u1, u1, u2} V V α} [_inst_3 : MulZeroOneClass.{u2} α] [_inst_4 : Nontrivial.{u2} α] (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) A), Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (Matrix.compl.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A) _inst_3 _inst_4 (Matrix.IsAdjMatrix.compl.{u1, u2} V α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) h)) (HasCompl.compl.{u1} (SimpleGraph.{u1} V) (SimpleGraph.hasCompl.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_3 _inst_4 h))
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.to_graph_compl_eq Matrix.IsAdjMatrix.toGraph_compl_eqₓ'. -/
theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by
ext (v w)
@@ -241,12 +211,6 @@ theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix
#align simple_graph.is_adj_matrix_adj_matrix SimpleGraph.isAdjMatrix_adjMatrix
-/
-/- warning: simple_graph.to_graph_adj_matrix_eq -> SimpleGraph.toGraph_adjMatrix_eq is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : MulZeroOneClass.{u2} α] [_inst_3 : Nontrivial.{u2} α], Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))) _inst_2 _inst_3 (SimpleGraph.isAdjMatrix_adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))) G
-but is expected to have type
- forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : MulZeroOneClass.{u2} α] [_inst_3 : Nontrivial.{u2} α], Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))) _inst_2 _inst_3 (SimpleGraph.isAdjMatrix_adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))) G
-Case conversion may be inaccurate. Consider using '#align simple_graph.to_graph_adj_matrix_eq SimpleGraph.toGraph_adjMatrix_eqₓ'. -/
/-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
(G.isAdjMatrix_adjMatrix α).toGraph = G := by
@@ -257,48 +221,24 @@ theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
variable {α} [Fintype V]
-/- warning: simple_graph.adj_matrix_dot_product -> SimpleGraph.adjMatrix_dotProduct is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3))) v) vec) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3) v) vec) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_dot_product SimpleGraph.adjMatrix_dotProductₓ'. -/
@[simp]
theorem adjMatrix_dotProduct [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct (G.adjMatrix α v) vec = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter]
#align simple_graph.adj_matrix_dot_product SimpleGraph.adjMatrix_dotProduct
-/- warning: simple_graph.dot_product_adj_matrix -> SimpleGraph.dotProduct_adjMatrix is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3))) v)) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3) v)) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-Case conversion may be inaccurate. Consider using '#align simple_graph.dot_product_adj_matrix SimpleGraph.dotProduct_adjMatrixₓ'. -/
@[simp]
theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct vec (G.adjMatrix α v) = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter, Finset.sum_apply]
#align simple_graph.dot_product_adj_matrix SimpleGraph.dotProduct_adjMatrix
-/- warning: simple_graph.adj_matrix_mul_vec_apply -> SimpleGraph.adjMatrix_mulVec_apply is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) vec v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) vec v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_applyₓ'. -/
@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).mulVec vec) v = ∑ u in G.neighborFinset v, vec u := by
rw [mul_vec, adj_matrix_dot_product]
#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_apply
-/- warning: simple_graph.adj_matrix_vec_mul_apply -> SimpleGraph.adjMatrix_vecMul_apply is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.vecMul.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.vecMul.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_vec_mul_apply SimpleGraph.adjMatrix_vecMul_applyₓ'. -/
@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).vecMul vec) v = ∑ u in G.neighborFinset v, vec u :=
@@ -308,24 +248,12 @@ theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
rw [← transpose_apply (adj_matrix α G) x v, transpose_adj_matrix]
#align simple_graph.adj_matrix_vec_mul_apply SimpleGraph.adjMatrix_vecMul_apply
-/- warning: simple_graph.adj_matrix_mul_apply -> SimpleGraph.adjMatrix_mul_apply is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) M v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => M u w))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) M v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => M u w))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_applyₓ'. -/
@[simp]
theorem adjMatrix_mul_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(G.adjMatrix α ⬝ M) v w = ∑ u in G.neighborFinset v, M u w := by
simp [mul_apply, neighbor_finset_eq_filter, sum_filter]
#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_apply
-/- warning: simple_graph.mul_adj_matrix_apply -> SimpleGraph.mul_adjMatrix_apply is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) M (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G w (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) w)) (fun (u : V) => M v u))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) M (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G w (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) w)) (fun (u : V) => M v u))
-Case conversion may be inaccurate. Consider using '#align simple_graph.mul_adj_matrix_apply SimpleGraph.mul_adjMatrix_applyₓ'. -/
@[simp]
theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(M ⬝ G.adjMatrix α) v w = ∑ u in G.neighborFinset w, M v u := by
@@ -334,12 +262,6 @@ theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V)
variable (α)
-/- warning: simple_graph.trace_adj_matrix -> SimpleGraph.trace_adjMatrix is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : AddCommMonoid.{u2} α] [_inst_4 : One.{u2} α], Eq.{succ u2} α (Matrix.trace.{u1, u2} V α _inst_2 _inst_3 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))) _inst_4)) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))))))
-but is expected to have type
- forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : AddCommMonoid.{u2} α] [_inst_4 : One.{u2} α], Eq.{succ u2} α (Matrix.trace.{u1, u2} V α _inst_2 _inst_3 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3)) _inst_4)) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))))
-Case conversion may be inaccurate. Consider using '#align simple_graph.trace_adj_matrix SimpleGraph.trace_adjMatrixₓ'. -/
@[simp]
theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix α) = 0 := by
simp [Matrix.trace]
@@ -347,46 +269,22 @@ theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix
variable {α}
-/- warning: simple_graph.adj_matrix_mul_self_apply_self -> SimpleGraph.adjMatrix_mul_self_apply_self is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (i : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) i i) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))))) (SimpleGraph.degree.{u1} V G i (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) i)))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (i : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) i i) (Nat.cast.{u2} α (NonAssocSemiring.toNatCast.{u2} α _inst_3) (SimpleGraph.degree.{u1} V G i (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) i)))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_selfₓ'. -/
theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
(G.adjMatrix α ⬝ G.adjMatrix α) i i = degree G i := by simp [degree]
#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_self
variable {G}
-/- warning: simple_graph.adj_matrix_mul_vec_const_apply -> SimpleGraph.adjMatrix_mulVec_const_apply is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {a : α} {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))))) (SimpleGraph.degree.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v))) a)
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {a : α} {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u2} α (Semiring.toMonoidWithZero.{u2} α _inst_3)) (Semiring.toOne.{u2} α _inst_3)) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (Nat.cast.{u2} α (Semiring.toNatCast.{u2} α _inst_3) (SimpleGraph.degree.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v))) a)
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_applyₓ'. -/
@[simp]
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
(G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp [degree]
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
-/- warning: simple_graph.adj_matrix_mul_vec_const_apply_of_regular -> SimpleGraph.adjMatrix_mulVec_const_apply_of_regular is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {d : Nat} {a : α}, (SimpleGraph.IsRegularOfDegree.{u1} V G (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) d) -> (forall {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))))) d) a))
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {d : Nat} {a : α}, (SimpleGraph.IsRegularOfDegree.{u1} V G (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) d) -> (forall {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u2} α (Semiring.toMonoidWithZero.{u2} α _inst_3)) (Semiring.toOne.{u2} α _inst_3)) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (Nat.cast.{u2} α (Semiring.toNatCast.{u2} α _inst_3) d) a))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regularₓ'. -/
theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α).mulVec (Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
-/- warning: simple_graph.adj_matrix_pow_apply_eq_card_walk -> SimpleGraph.adjMatrix_pow_apply_eq_card_walk is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : DecidableEq.{succ u1} V] [_inst_4 : Semiring.{u2} α] (n : Nat) (u : V) (v : V), Eq.{succ u2} α (HPow.hPow.{max u1 u2, 0, max u1 u2} (Matrix.{u1, u1, u2} V V α) Nat (Matrix.{u1, u1, u2} V V α) (instHPow.{max u1 u2, 0} (Matrix.{u1, u1, u2} V V α) Nat (Monoid.Pow.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (MonoidWithZero.toMonoid.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (Semiring.toMonoidWithZero.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (Matrix.semiring.{u2, u1} V α _inst_4 _inst_2 (fun (a : V) (b : V) => _inst_3 a b)))))) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4))))) n u v) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4))))))) (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} (SimpleGraph.Walk.{u1} V G u v)) Type.{u1} (Set.hasCoeToSort.{u1} (SimpleGraph.Walk.{u1} V G u v)) (setOf.{u1} (SimpleGraph.Walk.{u1} V G u v) (fun (p : SimpleGraph.Walk.{u1} V G u v) => Eq.{1} Nat (SimpleGraph.Walk.length.{u1} V G u v p) n))) (SimpleGraph.fintypeSetWalkLength.{u1} V G (fun (a : V) (b : V) => _inst_3 a b) (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) u v n)))
-but is expected to have type
- forall {V : Type.{u2}} {α : Type.{u1}} {G : SimpleGraph.{u2} V} [_inst_1 : DecidableRel.{succ u2} V (SimpleGraph.Adj.{u2} V G)] [_inst_2 : Fintype.{u2} V] [_inst_3 : DecidableEq.{succ u2} V] [_inst_4 : Semiring.{u1} α] (n : Nat) (u : V) (v : V), Eq.{succ u1} α (HPow.hPow.{max u2 u1, 0, max u2 u1} (Matrix.{u2, u2, u1} V V α) Nat (Matrix.{u2, u2, u1} V V α) (instHPow.{max u2 u1, 0} (Matrix.{u2, u2, u1} V V α) Nat (Monoid.Pow.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (MonoidWithZero.toMonoid.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (Semiring.toMonoidWithZero.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (Matrix.semiring.{u1, u2} V α _inst_4 _inst_2 (fun (a : V) (b : V) => _inst_3 a b)))))) (SimpleGraph.adjMatrix.{u2, u1} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_4)) (Semiring.toOne.{u1} α _inst_4)) n u v) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α _inst_4) (Fintype.card.{u2} (Set.Elem.{u2} (SimpleGraph.Walk.{u2} V G u v) (setOf.{u2} (SimpleGraph.Walk.{u2} V G u v) (fun (p : SimpleGraph.Walk.{u2} V G u v) => Eq.{1} Nat (SimpleGraph.Walk.length.{u2} V G u v p) n))) (SimpleGraph.fintypeSetWalkLength.{u2} V G (fun (a : V) (b : V) => _inst_3 a b) (fun (v : V) => SimpleGraph.neighborSetFintype.{u2} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) u v n)))
-Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_pow_apply_eq_card_walk SimpleGraph.adjMatrix_pow_apply_eq_card_walkₓ'. -/
theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ) (u v : V) :
(G.adjMatrix α ^ n) u v = Fintype.card { p : G.Walk u v | p.length = n } :=
by
@@ -418,12 +316,6 @@ variable [MulZeroOneClass α] [Nontrivial α]
variable {A : Matrix V V α} (h : IsAdjMatrix A)
-/- warning: matrix.is_adj_matrix.adj_matrix_to_graph_eq -> Matrix.IsAdjMatrix.adjMatrix_toGraph_eq is a dubious translation:
-lean 3 declaration is
- forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α] {A : Matrix.{u1, u1, u2} V V α} (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) [_inst_3 : DecidableEq.{succ u2} α], Eq.{succ (max u1 u2)} (Matrix.{u1, u1, u2} V V α) (SimpleGraph.adjMatrix.{u1, u2} V α (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_1 _inst_2 h) (fun (a : V) (b : V) => Matrix.IsAdjMatrix.Adj.decidableRel.{u1, u2} V α A _inst_1 _inst_2 (fun (a : α) (b : α) => _inst_3 a b) h a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))) A
-but is expected to have type
- forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α] {A : Matrix.{u1, u1, u2} V V α} (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) [_inst_3 : DecidableEq.{succ u2} α], Eq.{max (succ u1) (succ u2)} (Matrix.{u1, u1, u2} V V α) (SimpleGraph.adjMatrix.{u1, u2} V α (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_1 _inst_2 h) (fun (a : V) (b : V) => Matrix.IsAdjMatrix.instDecidableRelAdjToGraph.{u1, u2} V α A _inst_1 _inst_2 (fun (a : α) (b : α) => _inst_3 a b) h a b) (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))) A
-Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.adj_matrix_to_graph_eq Matrix.IsAdjMatrix.adjMatrix_toGraph_eqₓ'. -/
/-- If `A` is qualified as an adjacency matrix,
then the adjacency matrix of the graph induced by `A` is itself. -/
theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -118,9 +118,7 @@ def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGra
#align matrix.is_adj_matrix.to_graph Matrix.IsAdjMatrix.toGraph
instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix A) :
- DecidableRel h.toGraph.Adj := by
- simp only [to_graph]
- infer_instance
+ DecidableRel h.toGraph.Adj := by simp only [to_graph]; infer_instance
end IsAdjMatrix
@@ -144,18 +142,14 @@ theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 := by simp
#print Matrix.compl_apply /-
@[simp]
-theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 :=
- by
- unfold compl
- split_ifs <;> simp
+theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 := by
+ unfold compl; split_ifs <;> simp
#align matrix.compl_apply Matrix.compl_apply
-/
#print Matrix.isSymm_compl /-
@[simp]
-theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm :=
- by
- ext
+theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm := by ext;
simp [compl, h.apply, eq_comm]
#align matrix.is_symm_compl Matrix.isSymm_compl
-/
@@ -225,9 +219,7 @@ theorem adjMatrix_apply (v w : V) [Zero α] [One α] :
#print SimpleGraph.transpose_adjMatrix /-
@[simp]
-theorem transpose_adjMatrix [Zero α] [One α] : (G.adjMatrix α)ᵀ = G.adjMatrix α :=
- by
- ext
+theorem transpose_adjMatrix [Zero α] [One α] : (G.adjMatrix α)ᵀ = G.adjMatrix α := by ext;
simp [adj_comm]
#align simple_graph.transpose_adj_matrix SimpleGraph.transpose_adjMatrix
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/e3fb84046afd187b710170887195d50bada934ee
@@ -403,7 +403,7 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
· obtain rfl | h := eq_or_ne u v <;> simp [finset_walk_length, *]
· nth_rw 1 [Nat.succ_eq_one_add]
simp only [pow_add, pow_one, finset_walk_length, ih, mul_eq_mul, adj_matrix_mul_apply]
- rw [Finset.card_bunionᵢ]
+ rw [Finset.card_biUnion]
· norm_cast
simp only [Nat.cast_sum, card_map, neighbor_finset_def]
apply Finset.sum_toFinset_eq_subtype
mathlib commit https://github.com/leanprover-community/mathlib/commit/5ec62c8106221a3f9160e4e4fcc3eed79fe213e9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
! This file was ported from Lean 3 source module combinatorics.simple_graph.adj_matrix
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
+! leanprover-community/mathlib commit 75be6b616681ab6ca66d798ead117e75cd64f125
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -16,6 +16,9 @@ import Mathbin.LinearAlgebra.Matrix.Symmetric
/-!
# Adjacency Matrices
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
This module defines the adjacency matrix of a graph, and provides theorems connecting graph
properties to computational properties of the matrix.
mathlib commit https://github.com/leanprover-community/mathlib/commit/1a4df69ca1a9a0e5e26bfe12e2b92814216016d0
@@ -49,6 +49,7 @@ variable {V α β : Type _}
namespace Matrix
+#print Matrix.IsAdjMatrix /-
/-- `A : matrix V V α` is qualified as an "adjacency matrix" if
(1) every entry of `A` is `0` or `1`,
(2) `A` is symmetric,
@@ -58,26 +59,51 @@ structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
symm : A.IsSymm := by obviously
apply_diag : ∀ i, A i i = 0 := by obviously
#align matrix.is_adj_matrix Matrix.IsAdjMatrix
+-/
namespace IsAdjMatrix
variable {A : Matrix V V α}
+/- warning: matrix.is_adj_matrix.apply_diag_ne -> Matrix.IsAdjMatrix.apply_diag_ne is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V), Not (Eq.{succ u2} α (A i i) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V), Not (Eq.{succ u2} α (A i i) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_neₓ'. -/
@[simp]
theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) : ¬A i i = 1 :=
by simp [h.apply_diag i]
#align matrix.is_adj_matrix.apply_diag_ne Matrix.IsAdjMatrix.apply_diag_ne
+/- warning: matrix.is_adj_matrix.apply_ne_one_iff -> Matrix.IsAdjMatrix.apply_ne_one_iff is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)))))))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α _inst_1)))))
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iffₓ'. -/
@[simp]
theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 1 ↔ A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h]
#align matrix.is_adj_matrix.apply_ne_one_iff Matrix.IsAdjMatrix.apply_ne_one_iff
+/- warning: matrix.is_adj_matrix.apply_ne_zero_iff -> Matrix.IsAdjMatrix.apply_ne_zero_iff is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1))))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (OfNat.mk.{u2} α 1 (One.one.{u2} α (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)))))))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (forall (i : V) (j : V), Iff (Not (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (MulZeroOneClass.toZero.{u2} α _inst_1))))) (Eq.{succ u2} α (A i j) (OfNat.ofNat.{u2} α 1 (One.toOfNat1.{u2} α (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))))))
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iffₓ'. -/
@[simp]
theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
¬A i j = 0 ↔ A i j = 1 := by rw [← apply_ne_one_iff h, Classical.not_not]
#align matrix.is_adj_matrix.apply_ne_zero_iff Matrix.IsAdjMatrix.apply_ne_zero_iff
+/- warning: matrix.is_adj_matrix.to_graph -> Matrix.IsAdjMatrix.toGraph is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (SimpleGraph.{u1} V)
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {A : Matrix.{u1, u1, u2} V V α} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α], (Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) -> (SimpleGraph.{u1} V)
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.to_graph Matrix.IsAdjMatrix.toGraphₓ'. -/
/-- For `A : matrix V V α` and `h : is_adj_matrix A`,
`h.to_graph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
@@ -95,48 +121,66 @@ instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix
end IsAdjMatrix
+#print Matrix.compl /-
/-- For `A : matrix V V α`, `A.compl` is supposed to be the adjacency matrix of
the complement graph of the graph induced by `A.adj_matrix`. -/
def compl [Zero α] [One α] [DecidableEq α] [DecidableEq V] (A : Matrix V V α) : Matrix V V α :=
fun i j => ite (i = j) 0 (ite (A i j = 0) 1 0)
#align matrix.compl Matrix.compl
+-/
section Compl
variable [DecidableEq α] [DecidableEq V] (A : Matrix V V α)
+#print Matrix.compl_apply_diag /-
@[simp]
theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 := by simp [compl]
#align matrix.compl_apply_diag Matrix.compl_apply_diag
+-/
+#print Matrix.compl_apply /-
@[simp]
theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 :=
by
unfold compl
split_ifs <;> simp
#align matrix.compl_apply Matrix.compl_apply
+-/
+#print Matrix.isSymm_compl /-
@[simp]
theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm :=
by
ext
simp [compl, h.apply, eq_comm]
#align matrix.is_symm_compl Matrix.isSymm_compl
+-/
+#print Matrix.isAdjMatrix_compl /-
@[simp]
theorem isAdjMatrix_compl [Zero α] [One α] (h : A.IsSymm) : IsAdjMatrix A.compl :=
{ symm := by simp [h] }
#align matrix.is_adj_matrix_compl Matrix.isAdjMatrix_compl
+-/
namespace IsAdjMatrix
variable {A}
+#print Matrix.IsAdjMatrix.compl /-
@[simp]
theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
isAdjMatrix_compl A h.symm
#align matrix.is_adj_matrix.compl Matrix.IsAdjMatrix.compl
+-/
+/- warning: matrix.is_adj_matrix.to_graph_compl_eq -> Matrix.IsAdjMatrix.toGraph_compl_eq is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} V] {A : Matrix.{u1, u1, u2} V V α} [_inst_3 : MulZeroOneClass.{u2} α] [_inst_4 : Nontrivial.{u2} α] (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) A), Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (Matrix.compl.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A) _inst_3 _inst_4 (Matrix.IsAdjMatrix.compl.{u1, u2} V α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_3)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) h)) (HasCompl.compl.{u1} (SimpleGraph.{u1} V) (SimpleGraph.hasCompl.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_3 _inst_4 h))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u1} V] {A : Matrix.{u1, u1, u2} V V α} [_inst_3 : MulZeroOneClass.{u2} α] [_inst_4 : Nontrivial.{u2} α] (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) A), Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (Matrix.compl.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A) _inst_3 _inst_4 (Matrix.IsAdjMatrix.compl.{u1, u2} V α (fun (a : α) (b : α) => _inst_1 a b) (fun (a : V) (b : V) => _inst_2 a b) A (MulZeroOneClass.toZero.{u2} α _inst_3) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_3)) h)) (HasCompl.compl.{u1} (SimpleGraph.{u1} V) (SimpleGraph.hasCompl.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_3 _inst_4 h))
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.to_graph_compl_eq Matrix.IsAdjMatrix.toGraph_compl_eqₓ'. -/
theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by
ext (v w)
@@ -157,41 +201,57 @@ variable (G : SimpleGraph V) [DecidableRel G.Adj]
variable (α)
+#print SimpleGraph.adjMatrix /-
/-- `adj_matrix G α` is the matrix `A` such that `A i j = (1 : α)` if `i` and `j` are
adjacent in the simple graph `G`, and otherwise `A i j = 0`. -/
def adjMatrix [Zero α] [One α] : Matrix V V α :=
of fun i j => if G.Adj i j then (1 : α) else 0
#align simple_graph.adj_matrix SimpleGraph.adjMatrix
+-/
variable {α}
+#print SimpleGraph.adjMatrix_apply /-
-- TODO: set as an equation lemma for `adj_matrix`, see mathlib4#3024
@[simp]
theorem adjMatrix_apply (v w : V) [Zero α] [One α] :
G.adjMatrix α v w = if G.Adj v w then 1 else 0 :=
rfl
#align simple_graph.adj_matrix_apply SimpleGraph.adjMatrix_apply
+-/
+#print SimpleGraph.transpose_adjMatrix /-
@[simp]
theorem transpose_adjMatrix [Zero α] [One α] : (G.adjMatrix α)ᵀ = G.adjMatrix α :=
by
ext
simp [adj_comm]
#align simple_graph.transpose_adj_matrix SimpleGraph.transpose_adjMatrix
+-/
+#print SimpleGraph.isSymm_adjMatrix /-
@[simp]
theorem isSymm_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsSymm :=
transpose_adjMatrix G
#align simple_graph.is_symm_adj_matrix SimpleGraph.isSymm_adjMatrix
+-/
variable (α)
+#print SimpleGraph.isAdjMatrix_adjMatrix /-
/-- The adjacency matrix of `G` is an adjacency matrix. -/
@[simp]
theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix :=
{ zero_or_one := fun i j => by by_cases G.adj i j <;> simp [h] }
#align simple_graph.is_adj_matrix_adj_matrix SimpleGraph.isAdjMatrix_adjMatrix
+-/
+/- warning: simple_graph.to_graph_adj_matrix_eq -> SimpleGraph.toGraph_adjMatrix_eq is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : MulZeroOneClass.{u2} α] [_inst_3 : Nontrivial.{u2} α], Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))) _inst_2 _inst_3 (SimpleGraph.isAdjMatrix_adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_2)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))) G
+but is expected to have type
+ forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : MulZeroOneClass.{u2} α] [_inst_3 : Nontrivial.{u2} α], Eq.{succ u1} (SimpleGraph.{u1} V) (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2))) _inst_2 _inst_3 (SimpleGraph.isAdjMatrix_adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α _inst_2) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_2)))) G
+Case conversion may be inaccurate. Consider using '#align simple_graph.to_graph_adj_matrix_eq SimpleGraph.toGraph_adjMatrix_eqₓ'. -/
/-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
(G.isAdjMatrix_adjMatrix α).toGraph = G := by
@@ -202,24 +262,48 @@ theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
variable {α} [Fintype V]
+/- warning: simple_graph.adj_matrix_dot_product -> SimpleGraph.adjMatrix_dotProduct is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3))) v) vec) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3) v) vec) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_dot_product SimpleGraph.adjMatrix_dotProductₓ'. -/
@[simp]
theorem adjMatrix_dotProduct [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct (G.adjMatrix α v) vec = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter]
#align simple_graph.adj_matrix_dot_product SimpleGraph.adjMatrix_dotProduct
+/- warning: simple_graph.dot_product_adj_matrix -> SimpleGraph.dotProduct_adjMatrix is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3))) v)) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.dotProduct.{u2, u1} V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3) v)) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+Case conversion may be inaccurate. Consider using '#align simple_graph.dot_product_adj_matrix SimpleGraph.dotProduct_adjMatrixₓ'. -/
@[simp]
theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :
dotProduct vec (G.adjMatrix α v) = ∑ u in G.neighborFinset v, vec u := by
simp [neighbor_finset_eq_filter, dot_product, sum_filter, Finset.sum_apply]
#align simple_graph.dot_product_adj_matrix SimpleGraph.dotProduct_adjMatrix
+/- warning: simple_graph.adj_matrix_mul_vec_apply -> SimpleGraph.adjMatrix_mulVec_apply is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) vec v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) vec v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_applyₓ'. -/
@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).mulVec vec) v = ∑ u in G.neighborFinset v, vec u := by
rw [mul_vec, adj_matrix_dot_product]
#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_apply
+/- warning: simple_graph.adj_matrix_vec_mul_apply -> SimpleGraph.adjMatrix_vecMul_apply is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.vecMul.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (v : V) (vec : V -> α), Eq.{succ u2} α (Matrix.vecMul.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3) _inst_2 vec (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) v) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => vec u))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_vec_mul_apply SimpleGraph.adjMatrix_vecMul_applyₓ'. -/
@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).vecMul vec) v = ∑ u in G.neighborFinset v, vec u :=
@@ -229,12 +313,24 @@ theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
rw [← transpose_apply (adj_matrix α G) x v, transpose_adj_matrix]
#align simple_graph.adj_matrix_vec_mul_apply SimpleGraph.adjMatrix_vecMul_apply
+/- warning: simple_graph.adj_matrix_mul_apply -> SimpleGraph.adjMatrix_mul_apply is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) M v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => M u w))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) M v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v)) (fun (u : V) => M u w))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_applyₓ'. -/
@[simp]
theorem adjMatrix_mul_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(G.adjMatrix α ⬝ M) v w = ∑ u in G.neighborFinset v, M u w := by
simp [mul_apply, neighbor_finset_eq_filter, sum_filter]
#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_apply
+/- warning: simple_graph.mul_adj_matrix_apply -> SimpleGraph.mul_adjMatrix_apply is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) M (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G w (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) w)) (fun (u : V) => M v u))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (M : Matrix.{u1, u1, u2} V V α) (v : V) (w : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) M (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) v w) (Finset.sum.{u2, u1} α V (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.neighborFinset.{u1} V G w (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) w)) (fun (u : V) => M v u))
+Case conversion may be inaccurate. Consider using '#align simple_graph.mul_adj_matrix_apply SimpleGraph.mul_adjMatrix_applyₓ'. -/
@[simp]
theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
(M ⬝ G.adjMatrix α) v w = ∑ u in G.neighborFinset w, M v u := by
@@ -243,6 +339,12 @@ theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V)
variable (α)
+/- warning: simple_graph.trace_adj_matrix -> SimpleGraph.trace_adjMatrix is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : AddCommMonoid.{u2} α] [_inst_4 : One.{u2} α], Eq.{succ u2} α (Matrix.trace.{u1, u2} V α _inst_2 _inst_3 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))) _inst_4)) (OfNat.ofNat.{u2} α 0 (OfNat.mk.{u2} α 0 (Zero.zero.{u2} α (AddZeroClass.toHasZero.{u2} α (AddMonoid.toAddZeroClass.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))))))
+but is expected to have type
+ forall {V : Type.{u1}} (α : Type.{u2}) (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : AddCommMonoid.{u2} α] [_inst_4 : One.{u2} α], Eq.{succ u2} α (Matrix.trace.{u1, u2} V α _inst_2 _inst_3 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3)) _inst_4)) (OfNat.ofNat.{u2} α 0 (Zero.toOfNat0.{u2} α (AddMonoid.toZero.{u2} α (AddCommMonoid.toAddMonoid.{u2} α _inst_3))))
+Case conversion may be inaccurate. Consider using '#align simple_graph.trace_adj_matrix SimpleGraph.trace_adjMatrixₓ'. -/
@[simp]
theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix α) = 0 := by
simp [Matrix.trace]
@@ -250,22 +352,46 @@ theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix
variable {α}
+/- warning: simple_graph.adj_matrix_mul_self_apply_self -> SimpleGraph.adjMatrix_mul_self_apply_self is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (i : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))) i i) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α _inst_3)))))) (SimpleGraph.degree.{u1} V G i (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) i)))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} (G : SimpleGraph.{u1} V) [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : NonAssocSemiring.{u2} α] (i : V), Eq.{succ u2} α (Matrix.mul.{u2, u1, u1, u1} V V V α _inst_2 (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroOneClass.toZero.{u2} α (NonAssocSemiring.toMulZeroOneClass.{u2} α _inst_3)) (NonAssocSemiring.toOne.{u2} α _inst_3)) i i) (Nat.cast.{u2} α (NonAssocSemiring.toNatCast.{u2} α _inst_3) (SimpleGraph.degree.{u1} V G i (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) i)))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_selfₓ'. -/
theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
(G.adjMatrix α ⬝ G.adjMatrix α) i i = degree G i := by simp [degree]
#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_self
variable {G}
+/- warning: simple_graph.adj_matrix_mul_vec_const_apply -> SimpleGraph.adjMatrix_mulVec_const_apply is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {a : α} {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))))) (SimpleGraph.degree.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v))) a)
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {a : α} {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u2} α (Semiring.toMonoidWithZero.{u2} α _inst_3)) (Semiring.toOne.{u2} α _inst_3)) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (Nat.cast.{u2} α (Semiring.toNatCast.{u2} α _inst_3) (SimpleGraph.degree.{u1} V G v (SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v))) a)
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_applyₓ'. -/
@[simp]
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
(G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp [degree]
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
+/- warning: simple_graph.adj_matrix_mul_vec_const_apply_of_regular -> SimpleGraph.adjMatrix_mulVec_const_apply_of_regular is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {d : Nat} {a : α}, (SimpleGraph.IsRegularOfDegree.{u1} V G (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) d) -> (forall {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (Distrib.toHasMul.{u2} α (NonUnitalNonAssocSemiring.toDistrib.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3))))))) d) a))
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : Semiring.{u2} α] {d : Nat} {a : α}, (SimpleGraph.IsRegularOfDegree.{u1} V G (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) d) -> (forall {v : V}, Eq.{succ u2} α (Matrix.mulVec.{u2, u1, u1} V V α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)) _inst_2 (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u2} α (Semiring.toMonoidWithZero.{u2} α _inst_3)) (Semiring.toOne.{u2} α _inst_3)) (Function.const.{succ u2, succ u1} α V a) v) (HMul.hMul.{u2, u2, u2} α α α (instHMul.{u2} α (NonUnitalNonAssocSemiring.toMul.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_3)))) (Nat.cast.{u2} α (Semiring.toNatCast.{u2} α _inst_3) d) a))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regularₓ'. -/
theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α).mulVec (Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
+/- warning: simple_graph.adj_matrix_pow_apply_eq_card_walk -> SimpleGraph.adjMatrix_pow_apply_eq_card_walk is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} {G : SimpleGraph.{u1} V} [_inst_1 : DecidableRel.{succ u1} V (SimpleGraph.Adj.{u1} V G)] [_inst_2 : Fintype.{u1} V] [_inst_3 : DecidableEq.{succ u1} V] [_inst_4 : Semiring.{u2} α] (n : Nat) (u : V) (v : V), Eq.{succ u2} α (HPow.hPow.{max u1 u2, 0, max u1 u2} (Matrix.{u1, u1, u2} V V α) Nat (Matrix.{u1, u1, u2} V V α) (instHPow.{max u1 u2, 0} (Matrix.{u1, u1, u2} V V α) Nat (Monoid.Pow.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (MonoidWithZero.toMonoid.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (Semiring.toMonoidWithZero.{max u1 u2} (Matrix.{u1, u1, u2} V V α) (Matrix.semiring.{u2, u1} V α _inst_4 _inst_2 (fun (a : V) (b : V) => _inst_3 a b)))))) (SimpleGraph.adjMatrix.{u1, u2} V α G (fun (a : V) (b : V) => _inst_1 a b) (MulZeroClass.toHasZero.{u2} α (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} α (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4)))) (AddMonoidWithOne.toOne.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4))))) n u v) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat α (HasLiftT.mk.{1, succ u2} Nat α (CoeTCₓ.coe.{1, succ u2} Nat α (Nat.castCoe.{u2} α (AddMonoidWithOne.toNatCast.{u2} α (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} α (NonAssocSemiring.toAddCommMonoidWithOne.{u2} α (Semiring.toNonAssocSemiring.{u2} α _inst_4))))))) (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} (SimpleGraph.Walk.{u1} V G u v)) Type.{u1} (Set.hasCoeToSort.{u1} (SimpleGraph.Walk.{u1} V G u v)) (setOf.{u1} (SimpleGraph.Walk.{u1} V G u v) (fun (p : SimpleGraph.Walk.{u1} V G u v) => Eq.{1} Nat (SimpleGraph.Walk.length.{u1} V G u v p) n))) (SimpleGraph.fintypeSetWalkLength.{u1} V G (fun (a : V) (b : V) => _inst_3 a b) (fun (v : V) => SimpleGraph.neighborSetFintype.{u1} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) u v n)))
+but is expected to have type
+ forall {V : Type.{u2}} {α : Type.{u1}} {G : SimpleGraph.{u2} V} [_inst_1 : DecidableRel.{succ u2} V (SimpleGraph.Adj.{u2} V G)] [_inst_2 : Fintype.{u2} V] [_inst_3 : DecidableEq.{succ u2} V] [_inst_4 : Semiring.{u1} α] (n : Nat) (u : V) (v : V), Eq.{succ u1} α (HPow.hPow.{max u2 u1, 0, max u2 u1} (Matrix.{u2, u2, u1} V V α) Nat (Matrix.{u2, u2, u1} V V α) (instHPow.{max u2 u1, 0} (Matrix.{u2, u2, u1} V V α) Nat (Monoid.Pow.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (MonoidWithZero.toMonoid.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (Semiring.toMonoidWithZero.{max u2 u1} (Matrix.{u2, u2, u1} V V α) (Matrix.semiring.{u1, u2} V α _inst_4 _inst_2 (fun (a : V) (b : V) => _inst_3 a b)))))) (SimpleGraph.adjMatrix.{u2, u1} V α G (fun (a : V) (b : V) => _inst_1 a b) (MonoidWithZero.toZero.{u1} α (Semiring.toMonoidWithZero.{u1} α _inst_4)) (Semiring.toOne.{u1} α _inst_4)) n u v) (Nat.cast.{u1} α (Semiring.toNatCast.{u1} α _inst_4) (Fintype.card.{u2} (Set.Elem.{u2} (SimpleGraph.Walk.{u2} V G u v) (setOf.{u2} (SimpleGraph.Walk.{u2} V G u v) (fun (p : SimpleGraph.Walk.{u2} V G u v) => Eq.{1} Nat (SimpleGraph.Walk.length.{u2} V G u v p) n))) (SimpleGraph.fintypeSetWalkLength.{u2} V G (fun (a : V) (b : V) => _inst_3 a b) (fun (v : V) => SimpleGraph.neighborSetFintype.{u2} V G _inst_2 (fun (a : V) (b : V) => _inst_1 a b) v) u v n)))
+Case conversion may be inaccurate. Consider using '#align simple_graph.adj_matrix_pow_apply_eq_card_walk SimpleGraph.adjMatrix_pow_apply_eq_card_walkₓ'. -/
theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ) (u v : V) :
(G.adjMatrix α ^ n) u v = Fintype.card { p : G.Walk u v | p.length = n } :=
by
@@ -297,6 +423,12 @@ variable [MulZeroOneClass α] [Nontrivial α]
variable {A : Matrix V V α} (h : IsAdjMatrix A)
+/- warning: matrix.is_adj_matrix.adj_matrix_to_graph_eq -> Matrix.IsAdjMatrix.adjMatrix_toGraph_eq is a dubious translation:
+lean 3 declaration is
+ forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α] {A : Matrix.{u1, u1, u2} V V α} (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) [_inst_3 : DecidableEq.{succ u2} α], Eq.{succ (max u1 u2)} (Matrix.{u1, u1, u2} V V α) (SimpleGraph.adjMatrix.{u1, u2} V α (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_1 _inst_2 h) (fun (a : V) (b : V) => Matrix.IsAdjMatrix.Adj.decidableRel.{u1, u2} V α A _inst_1 _inst_2 (fun (a : α) (b : α) => _inst_3 a b) h a b) (MulZeroClass.toHasZero.{u2} α (MulZeroOneClass.toMulZeroClass.{u2} α _inst_1)) (MulOneClass.toHasOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))) A
+but is expected to have type
+ forall {V : Type.{u1}} {α : Type.{u2}} [_inst_1 : MulZeroOneClass.{u2} α] [_inst_2 : Nontrivial.{u2} α] {A : Matrix.{u1, u1, u2} V V α} (h : Matrix.IsAdjMatrix.{u1, u2} V α (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1)) A) [_inst_3 : DecidableEq.{succ u2} α], Eq.{max (succ u1) (succ u2)} (Matrix.{u1, u1, u2} V V α) (SimpleGraph.adjMatrix.{u1, u2} V α (Matrix.IsAdjMatrix.toGraph.{u1, u2} V α A _inst_1 _inst_2 h) (fun (a : V) (b : V) => Matrix.IsAdjMatrix.instDecidableRelAdjToGraph.{u1, u2} V α A _inst_1 _inst_2 (fun (a : α) (b : α) => _inst_3 a b) h a b) (MulZeroOneClass.toZero.{u2} α _inst_1) (MulOneClass.toOne.{u2} α (MulZeroOneClass.toMulOneClass.{u2} α _inst_1))) A
+Case conversion may be inaccurate. Consider using '#align matrix.is_adj_matrix.adj_matrix_to_graph_eq Matrix.IsAdjMatrix.adjMatrix_toGraph_eqₓ'. -/
/-- If `A` is qualified as an adjacency matrix,
then the adjacency matrix of the graph induced by `A` is itself. -/
theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/172bf2812857f5e56938cc148b7a539f52f84ca9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
! This file was ported from Lean 3 source module combinatorics.simple_graph.adj_matrix
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
+! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -159,12 +159,13 @@ variable (α)
/-- `adj_matrix G α` is the matrix `A` such that `A i j = (1 : α)` if `i` and `j` are
adjacent in the simple graph `G`, and otherwise `A i j = 0`. -/
-def adjMatrix [Zero α] [One α] : Matrix V V α
- | i, j => if G.Adj i j then 1 else 0
+def adjMatrix [Zero α] [One α] : Matrix V V α :=
+ of fun i j => if G.Adj i j then (1 : α) else 0
#align simple_graph.adj_matrix SimpleGraph.adjMatrix
variable {α}
+-- TODO: set as an equation lemma for `adj_matrix`, see mathlib4#3024
@[simp]
theorem adjMatrix_apply (v w : V) [Zero α] [One α] :
G.adjMatrix α v w = if G.Adj v w then 1 else 0 :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -248,11 +248,11 @@ theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
variable {G}
-- @[simp] -- Porting note (#10618): simp can prove this
-theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
+theorem adjMatrix_mulVec_const_apply [NonAssocSemiring α] {a : α} {v : V} :
(G.adjMatrix α *ᵥ Function.const _ a) v = G.degree v * a := by simp
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
-theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
+theorem adjMatrix_mulVec_const_apply_of_regular [NonAssocSemiring α] {d : ℕ} {a : α}
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α *ᵥ Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
@@ -278,21 +278,20 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
simp at hxy
#align simple_graph.adj_matrix_pow_apply_eq_card_walk SimpleGraph.adjMatrix_pow_apply_eq_card_walk
-/-- The sum of the identity, `G.adjMatrix ℕ` and `(G.adjMatrix ℕ).compl` is the all-ones matrix. -/
-theorem one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes [DecidableEq V] :
- 1 + G.adjMatrix ℕ + (G.adjMatrix ℕ).compl = Matrix.of fun _ _ ↦ 1 := by
+/-- The sum of the identity, the adjacency matrix, and its complement is the all-ones matrix. -/
+theorem one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes [DecidableEq V] [DecidableEq α]
+ [NonAssocSemiring α] : 1 + G.adjMatrix α + (G.adjMatrix α).compl = Matrix.of fun _ _ ↦ 1 := by
ext i j
unfold Matrix.compl
rw [of_apply, add_apply, adjMatrix_apply, add_apply, adjMatrix_apply, one_apply]
by_cases h : G.Adj i j
- · rw [if_pos h, if_neg one_ne_zero, if_neg (G.ne_of_adj h), if_neg (G.ne_of_adj h), zero_add,
- add_zero]
+ · aesop
· rw [if_neg h]
by_cases heq : i = j
· repeat rw [if_pos heq, add_zero]
· rw [if_neg heq, if_neg heq, zero_add, zero_add, if_pos (refl 0)]
-theorem dotProduct_mulVec_adjMatrix [Ring α] (vec : V → α) :
+theorem dotProduct_mulVec_adjMatrix [NonAssocSemiring α] (vec : V → α) :
vec ⬝ᵥ (G.adjMatrix α).mulVec vec =
∑ i : V, ∑ j : V, if G.Adj i j then vec i * vec j else 0 := by
simp only [dotProduct, mulVec, adjMatrix_apply, ite_mul, one_mul, zero_mul, mul_sum, mul_ite,
Empty lines were removed by executing the following Python script twice
import os
import re
# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
for filename in files:
if filename.endswith('.lean'):
file_path = os.path.join(dir_path, filename)
# Open the file and read its contents
with open(file_path, 'r') as file:
content = file.read()
# Use a regular expression to replace sequences of "variable" lines separated by empty lines
# with sequences without empty lines
modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)
# Write the modified content back to the file
with open(file_path, 'w') as file:
file.write(modified_content)
@@ -148,7 +148,6 @@ open Matrix
namespace SimpleGraph
variable (G : SimpleGraph V) [DecidableRel G.Adj]
-
variable (α)
/-- `adjMatrix G α` is the matrix `A` such that `A i j = (1 : α)` if `i` and `j` are
@@ -304,7 +303,6 @@ end SimpleGraph
namespace Matrix.IsAdjMatrix
variable [MulZeroOneClass α] [Nontrivial α]
-
variable {A : Matrix V V α} (h : IsAdjMatrix A)
/-- If `A` is qualified as an adjacency matrix,
Contains the definition of the graph laplacian and proofs of some its properties, including that it is positive semidefinite and that the dimension of its nullspace equals the number of connected components of the graph.
Co-authored-by: awueth <83429722+awueth@users.noreply.github.com>
@@ -293,6 +293,12 @@ theorem one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes [DecidableEq V] :
· repeat rw [if_pos heq, add_zero]
· rw [if_neg heq, if_neg heq, zero_add, zero_add, if_pos (refl 0)]
+theorem dotProduct_mulVec_adjMatrix [Ring α] (vec : V → α) :
+ vec ⬝ᵥ (G.adjMatrix α).mulVec vec =
+ ∑ i : V, ∑ j : V, if G.Adj i j then vec i * vec j else 0 := by
+ simp only [dotProduct, mulVec, adjMatrix_apply, ite_mul, one_mul, zero_mul, mul_sum, mul_ite,
+ mul_zero]
+
end SimpleGraph
namespace Matrix.IsAdjMatrix
adjMatrix
with its compl
(#10992)
This is an equation that is used in many graph theory proofs. In particular, I want to use it in the proof of the Hoffman-Singleton theorem.
Co-authored-by: Rida <106540880+Rida-Hamadani@users.noreply.github.com> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>
@@ -279,6 +279,20 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
simp at hxy
#align simple_graph.adj_matrix_pow_apply_eq_card_walk SimpleGraph.adjMatrix_pow_apply_eq_card_walk
+/-- The sum of the identity, `G.adjMatrix ℕ` and `(G.adjMatrix ℕ).compl` is the all-ones matrix. -/
+theorem one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes [DecidableEq V] :
+ 1 + G.adjMatrix ℕ + (G.adjMatrix ℕ).compl = Matrix.of fun _ _ ↦ 1 := by
+ ext i j
+ unfold Matrix.compl
+ rw [of_apply, add_apply, adjMatrix_apply, add_apply, adjMatrix_apply, one_apply]
+ by_cases h : G.Adj i j
+ · rw [if_pos h, if_neg one_ne_zero, if_neg (G.ne_of_adj h), if_neg (G.ne_of_adj h), zero_add,
+ add_zero]
+ · rw [if_neg h]
+ by_cases heq : i = j
+ · repeat rw [if_pos heq, add_zero]
+ · rw [if_neg heq, if_neg heq, zero_add, zero_add, if_pos (refl 0)]
+
end SimpleGraph
namespace Matrix.IsAdjMatrix
@@ -248,7 +248,7 @@ theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
variable {G}
--- @[simp] -- Porting note: simp can prove this
+-- @[simp] -- Porting note (#10618): simp can prove this
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
(G.adjMatrix α *ᵥ Function.const _ a) v = G.degree v * a := by simp
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
Matrix.mulVec
and Matrix.vecMul
get infix notation (#10297)
Zulip discussion: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Notation.20for.20mul_vec.20and.20vec_mul
Co-authored-by: Martin Dvorak <mdvorak@ista.ac.at>
@@ -209,13 +209,13 @@ theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :
@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
- ((G.adjMatrix α).mulVec vec) v = ∑ u in G.neighborFinset v, vec u := by
+ (G.adjMatrix α *ᵥ vec) v = ∑ u in G.neighborFinset v, vec u := by
rw [mulVec, adjMatrix_dotProduct]
#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_apply
@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
- ((G.adjMatrix α).vecMul vec) v = ∑ u in G.neighborFinset v, vec u := by
+ (vec ᵥ* G.adjMatrix α) v = ∑ u in G.neighborFinset v, vec u := by
simp only [← dotProduct_adjMatrix, vecMul]
refine' congr rfl _; ext x
rw [← transpose_apply (adjMatrix α G) x v, transpose_adjMatrix]
@@ -250,11 +250,11 @@ variable {G}
-- @[simp] -- Porting note: simp can prove this
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
- (G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp
+ (G.adjMatrix α *ᵥ Function.const _ a) v = G.degree v * a := by simp
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
- (hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α).mulVec (Function.const _ a) v = d * a :=
+ (hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α *ᵥ Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
Remove some unnecessary arguments in simp
calls, which will become problematic when the simp
algorithm changes in leanprover/lean4#3124.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -243,14 +243,14 @@ theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix
variable {α}
theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
- (G.adjMatrix α * G.adjMatrix α) i i = degree G i := by simp [degree]
+ (G.adjMatrix α * G.adjMatrix α) i i = degree G i := by simp
#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_self
variable {G}
-- @[simp] -- Porting note: simp can prove this
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
- (G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp [degree]
+ (G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply
theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
I've also got a change to make this required, but I'd like to land this first.
@@ -182,7 +182,7 @@ variable (α)
/-- The adjacency matrix of `G` is an adjacency matrix. -/
@[simp]
theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix :=
- { zero_or_one := fun i j => by by_cases G.Adj i j <;> simp [h] }
+ { zero_or_one := fun i j => by by_cases h : G.Adj i j <;> simp [h] }
#align simple_graph.is_adj_matrix_adj_matrix SimpleGraph.isAdjMatrix_adjMatrix
/-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
SimpleGraph.Adj
projection (#8179)
simps
was generating lemmas named _Adj
. This PR makes it generate _adj
instead, to follow the naming convention.
@@ -189,7 +189,7 @@ theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix
theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
(G.isAdjMatrix_adjMatrix α).toGraph = G := by
ext
- simp only [IsAdjMatrix.toGraph_Adj, adjMatrix_apply, ite_eq_left_iff, zero_ne_one]
+ simp only [IsAdjMatrix.toGraph_adj, adjMatrix_apply, ite_eq_left_iff, zero_ne_one]
apply Classical.not_not
#align simple_graph.to_graph_adj_matrix_eq SimpleGraph.toGraph_adjMatrix_eq
⬝
notation in favor of HMul
(#6487)
The main difficulty here is that *
has a slightly difference precedence to ⬝
. notably around smul
and neg
.
The other annoyance is that ↑U ⬝ A ⬝ ↑U⁻¹ : Matrix m m 𝔸
now has to be written U.val * A * (U⁻¹).val
in order to typecheck.
A downside of this change to consider: if you have a goal of A * (B * C) = (A * B) * C
, mul_assoc
now gives the illusion of matching, when in fact Matrix.mul_assoc
is needed. Previously the distinct symbol made it easy to avoid this mistake.
On the flipside, there is now no need to rewrite by Matrix.mul_eq_mul
all the time (indeed, the lemma is now removed).
@@ -223,13 +223,13 @@ theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
@[simp]
theorem adjMatrix_mul_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
- (G.adjMatrix α ⬝ M) v w = ∑ u in G.neighborFinset v, M u w := by
+ (G.adjMatrix α * M) v w = ∑ u in G.neighborFinset v, M u w := by
simp [mul_apply, neighborFinset_eq_filter, sum_filter]
#align simple_graph.adj_matrix_mul_apply SimpleGraph.adjMatrix_mul_apply
@[simp]
theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
- (M ⬝ G.adjMatrix α) v w = ∑ u in G.neighborFinset w, M v u := by
+ (M * G.adjMatrix α) v w = ∑ u in G.neighborFinset w, M v u := by
simp [mul_apply, neighborFinset_eq_filter, sum_filter, adj_comm]
#align simple_graph.mul_adj_matrix_apply SimpleGraph.mul_adjMatrix_apply
@@ -243,7 +243,7 @@ theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix
variable {α}
theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
- (G.adjMatrix α ⬝ G.adjMatrix α) i i = degree G i := by simp [degree]
+ (G.adjMatrix α * G.adjMatrix α) i i = degree G i := by simp [degree]
#align simple_graph.adj_matrix_mul_self_apply_self SimpleGraph.adjMatrix_mul_self_apply_self
variable {G}
@@ -264,7 +264,7 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
induction' n with n ih generalizing u v
· obtain rfl | h := eq_or_ne u v <;> simp [finsetWalkLength, *]
· nth_rw 1 [Nat.succ_eq_one_add]
- simp only [pow_add, pow_one, finsetWalkLength, ih, mul_eq_mul, adjMatrix_mul_apply]
+ simp only [pow_add, pow_one, finsetWalkLength, ih, adjMatrix_mul_apply]
rw [Finset.card_biUnion]
· norm_cast
simp only [Nat.cast_sum, card_map, neighborFinset_def]
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -42,7 +42,7 @@ open BigOperators Matrix
open Finset Matrix SimpleGraph
-variable {V α β : Type _}
+variable {V α β : Type*}
namespace Matrix
@@ -2,17 +2,14 @@
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
-
-! This file was ported from Lean 3 source module combinatorics.simple_graph.adj_matrix
-! leanprover-community/mathlib commit 3e068ece210655b7b9a9477c3aff38a492400aa1
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Combinatorics.SimpleGraph.Connectivity
import Mathlib.LinearAlgebra.Matrix.Trace
import Mathlib.LinearAlgebra.Matrix.Symmetric
+#align_import combinatorics.simple_graph.adj_matrix from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
+
/-!
# Adjacency Matrices
ext
(#5258)
Co-authored-by: Xavier Roblot <46200072+xroblot@users.noreply.github.com> Co-authored-by: Joël Riou <joel.riou@universite-paris-saclay.fr> Co-authored-by: Riccardo Brasca <riccardo.brasca@gmail.com> Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com> Co-authored-by: Pol'tta / Miyahara Kō <pol_tta@outlook.jp> Co-authored-by: Jason Yuen <jason_yuen2007@hotmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Jireh Loreaux <loreaujy@gmail.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: Heather Macbeth <25316162+hrmacbeth@users.noreply.github.com> Co-authored-by: Jujian Zhang <jujian.zhang1998@outlook.com> Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>
@@ -136,7 +136,7 @@ theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphᶜ := by
- ext (v w)
+ ext v w
cases' h.zero_or_one v w with h h <;> by_cases hvw : v = w <;> simp [Matrix.compl, h, hvw]
#align matrix.is_adj_matrix.to_graph_compl_eq Matrix.IsAdjMatrix.toGraph_compl_eq
@@ -293,7 +293,7 @@ variable {A : Matrix V V α} (h : IsAdjMatrix A)
/-- If `A` is qualified as an adjacency matrix,
then the adjacency matrix of the graph induced by `A` is itself. -/
theorem adjMatrix_toGraph_eq [DecidableEq α] : h.toGraph.adjMatrix α = A := by
- ext (i j)
+ ext i j
obtain h' | h' := h.zero_or_one i j <;> simp [h']
#align matrix.is_adj_matrix.adj_matrix_to_graph_eq Matrix.IsAdjMatrix.adjMatrix_toGraph_eq
sSup
/iSup
(#3938)
As discussed on Zulip
supₛ
→ sSup
infₛ
→ sInf
supᵢ
→ iSup
infᵢ
→ iInf
bsupₛ
→ bsSup
binfₛ
→ bsInf
bsupᵢ
→ biSup
binfᵢ
→ biInf
csupₛ
→ csSup
cinfₛ
→ csInf
csupᵢ
→ ciSup
cinfᵢ
→ ciInf
unionₛ
→ sUnion
interₛ
→ sInter
unionᵢ
→ iUnion
interᵢ
→ iInter
bunionₛ
→ bsUnion
binterₛ
→ bsInter
bunionᵢ
→ biUnion
binterᵢ
→ biInter
Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>
@@ -268,7 +268,7 @@ theorem adjMatrix_pow_apply_eq_card_walk [DecidableEq V] [Semiring α] (n : ℕ)
· obtain rfl | h := eq_or_ne u v <;> simp [finsetWalkLength, *]
· nth_rw 1 [Nat.succ_eq_one_add]
simp only [pow_add, pow_one, finsetWalkLength, ih, mul_eq_mul, adjMatrix_mul_apply]
- rw [Finset.card_bunionᵢ]
+ rw [Finset.card_biUnion]
· norm_cast
simp only [Nat.cast_sum, card_map, neighborFinset_def]
apply Finset.sum_toFinset_eq_subtype
The unported dependencies are