File: Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean

full_name: Matrix.IsAdjMatrix.symm
code: /-- `A : Matrix V V α` is qualified as an "adjacency matrix" if
    (1) every entry of `A` is `0` or `1`,
    (2) `A` is symmetric,
    (3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
  zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
  symm : A.IsSymm := by aesop
  apply_diag : ∀ i, A i i = 0 := by aesop
goal: A.IsSymm

full_name: Matrix.IsAdjMatrix
code: /-- `A : Matrix V V α` is qualified as an "adjacency matrix" if
    (1) every entry of `A` is `0` or `1`,
    (2) `A` is symmetric,
    (3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
  zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
  symm : A.IsSymm := by aesop
  apply_diag : ∀ i, A i i = 0 := by aesop
goal: Prop

full_name: Matrix.IsAdjMatrix.zero_or_one
code: /-- `A : Matrix V V α` is qualified as an "adjacency matrix" if
    (1) every entry of `A` is `0` or `1`,
    (2) `A` is symmetric,
    (3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
  zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
  symm : A.IsSymm := by aesop
  apply_diag : ∀ i, A i i = 0 := by aesop
goal: A i j = 0 ∨ A i j = 1

full_name: Matrix.IsAdjMatrix.apply_diag
code: /-- `A : Matrix V V α` is qualified as an "adjacency matrix" if
    (1) every entry of `A` is `0` or `1`,
    (2) `A` is symmetric,
    (3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero α] [One α] (A : Matrix V V α) : Prop where
  zero_or_one : ∀ i j, A i j = 0 ∨ A i j = 1 := by aesop
  symm : A.IsSymm := by aesop
  apply_diag : ∀ i, A i i = 0 := by aesop
goal: A i i = 0

full_name: Matrix.IsAdjMatrix.apply_diag_ne
code: @[simp]
theorem apply_diag_ne [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i : V) :
    ¬A i i = 1 
goal: ¬A i i = 1

full_name: Matrix.IsAdjMatrix.apply_ne_one_iff
code: @[simp]
theorem apply_ne_one_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
    ¬A i j = 1 ↔ A i j = 0 
goal: ¬A i j = 1 ↔ A i j = 0

full_name: Matrix.IsAdjMatrix.apply_ne_zero_iff
code: @[simp]
theorem apply_ne_zero_iff [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) (i j : V) :
    ¬A i j = 0 ↔ A i j = 1 
goal: ¬A i j = 0 ↔ A i j = 1

full_name: Matrix.IsAdjMatrix.toGraph_adj
code: /-- For `A : Matrix V V α` and `h : IsAdjMatrix A`,
    `h.toGraph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGraph V 
goal: h.toGraph.Adj i j = (A i j = 1)

full_name: Matrix.IsAdjMatrix.toGraph
code: /-- For `A : Matrix V V α` and `h : IsAdjMatrix A`,
    `h.toGraph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
def toGraph [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) : SimpleGraph V 
goal: SimpleGraph V

full_name: Matrix.IsAdjMatrix.instDecidableRelAdjToGraphOfDecidableEq
code: instance [MulZeroOneClass α] [Nontrivial α] [DecidableEq α] (h : IsAdjMatrix A) :
    DecidableRel h.toGraph.Adj 
goal: DecidableRel h.toGraph.Adj

full_name: Matrix.compl
code: /-- For `A : Matrix V V α`, `A.compl` is supposed to be the adjacency matrix of
    the complement graph of the graph induced by `A.adjMatrix`. -/
def compl [Zero α] [One α] [DecidableEq α] [DecidableEq V] (A : Matrix V V α) : Matrix V V α 
goal: Matrix V V α

full_name: Matrix.compl_apply_diag
code: @[simp]
theorem compl_apply_diag [Zero α] [One α] (i : V) : A.compl i i = 0 
goal: A.compl i i = 0

full_name: Matrix.compl_apply
code: @[simp]
theorem compl_apply [Zero α] [One α] (i j : V) : A.compl i j = 0 ∨ A.compl i j = 1 
goal: A.compl i j = 0 ∨ A.compl i j = 1

full_name: Matrix.isSymm_compl
code: @[simp]
theorem isSymm_compl [Zero α] [One α] (h : A.IsSymm) : A.compl.IsSymm 
goal: A.compl.IsSymm

full_name: Matrix.isAdjMatrix_compl
code: @[simp]
theorem isAdjMatrix_compl [Zero α] [One α] (h : A.IsSymm) : IsAdjMatrix A.compl 
goal: A.compl.IsAdjMatrix

full_name: Matrix.IsAdjMatrix.compl
code: @[simp]
theorem compl [Zero α] [One α] (h : IsAdjMatrix A) : IsAdjMatrix A.compl 
goal: A.compl.IsAdjMatrix

full_name: Matrix.IsAdjMatrix.toGraph_compl_eq
code: theorem toGraph_compl_eq [MulZeroOneClass α] [Nontrivial α] (h : IsAdjMatrix A) :
    h.compl.toGraph = h.toGraphᶜ 
goal: ⋯.toGraph = h.toGraphᶜ

full_name: SimpleGraph.adjMatrix
code: /-- `adjMatrix 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 α 
goal: Matrix V V α

full_name: SimpleGraph.adjMatrix_apply
code: @[simp]
theorem adjMatrix_apply (v w : V) [Zero α] [One α] :
    G.adjMatrix α v w = if G.Adj v w then 1 else 0 
goal: SimpleGraph.adjMatrix α G v w = if G.Adj v w then 1 else 0

full_name: SimpleGraph.transpose_adjMatrix
code: @[simp]
theorem transpose_adjMatrix [Zero α] [One α] : (G.adjMatrix α)ᵀ = G.adjMatrix α 
goal: (SimpleGraph.adjMatrix α G)ᵀ = SimpleGraph.adjMatrix α G

full_name: SimpleGraph.isSymm_adjMatrix
code: @[simp]
theorem isSymm_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsSymm 
goal: (SimpleGraph.adjMatrix α G).IsSymm

full_name: SimpleGraph.isAdjMatrix_adjMatrix
code: /-- The adjacency matrix of `G` is an adjacency matrix. -/
@[simp]
theorem isAdjMatrix_adjMatrix [Zero α] [One α] : (G.adjMatrix α).IsAdjMatrix 
goal: (SimpleGraph.adjMatrix α G).IsAdjMatrix

full_name: SimpleGraph.toGraph_adjMatrix_eq
code: /-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
theorem toGraph_adjMatrix_eq [MulZeroOneClass α] [Nontrivial α] :
    (G.isAdjMatrix_adjMatrix α).toGraph = G 
goal: ⋯.toGraph = G

full_name: SimpleGraph.adjMatrix_dotProduct
code: @[simp]
theorem adjMatrix_dotProduct [NonAssocSemiring α] (v : V) (vec : V → α) :
    dotProduct (G.adjMatrix α v) vec = ∑ u ∈ G.neighborFinset v, vec u 
goal: SimpleGraph.adjMatrix α G v ⬝ᵥ vec = ∑ u ∈ G.neighborFinset v, vec u

full_name: SimpleGraph.dotProduct_adjMatrix
code: @[simp]
theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :
    dotProduct vec (G.adjMatrix α v) = ∑ u ∈ G.neighborFinset v, vec u 
goal: vec ⬝ᵥ SimpleGraph.adjMatrix α G v = ∑ u ∈ G.neighborFinset v, vec u

full_name: SimpleGraph.adjMatrix_mulVec_apply
code: @[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
    (G.adjMatrix α *ᵥ vec) v = ∑ u ∈ G.neighborFinset v, vec u 
goal: (SimpleGraph.adjMatrix α G *ᵥ vec) v = ∑ u ∈ G.neighborFinset v, vec u

full_name: SimpleGraph.adjMatrix_vecMul_apply
code: @[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
    (vec ᵥ* G.adjMatrix α) v = ∑ u ∈ G.neighborFinset v, vec u 
goal: (vec ᵥ* SimpleGraph.adjMatrix α G) v = ∑ u ∈ G.neighborFinset v, vec u

full_name: SimpleGraph.adjMatrix_mul_apply
code: @[simp]
theorem adjMatrix_mul_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
    (G.adjMatrix α * M) v w = ∑ u ∈ G.neighborFinset v, M u w 
goal: (SimpleGraph.adjMatrix α G * M) v w = ∑ u ∈ G.neighborFinset v, M u w

full_name: SimpleGraph.mul_adjMatrix_apply
code: @[simp]
theorem mul_adjMatrix_apply [NonAssocSemiring α] (M : Matrix V V α) (v w : V) :
    (M * G.adjMatrix α) v w = ∑ u ∈ G.neighborFinset w, M v u 
goal: (M * SimpleGraph.adjMatrix α G) v w = ∑ u ∈ G.neighborFinset w, M v u

full_name: SimpleGraph.trace_adjMatrix
code: @[simp]
theorem trace_adjMatrix [AddCommMonoid α] [One α] : Matrix.trace (G.adjMatrix α) = 0 
goal: (SimpleGraph.adjMatrix α G).trace = 0

full_name: SimpleGraph.adjMatrix_mul_self_apply_self
code: theorem adjMatrix_mul_self_apply_self [NonAssocSemiring α] (i : V) :
    (G.adjMatrix α * G.adjMatrix α) i i = degree G i 
goal: (SimpleGraph.adjMatrix α G * SimpleGraph.adjMatrix α G) i i = ↑(G.degree i)

full_name: SimpleGraph.adjMatrix_mulVec_const_apply
code: theorem adjMatrix_mulVec_const_apply [NonAssocSemiring α] {a : α} {v : V} :
    (G.adjMatrix α *ᵥ Function.const _ a) v = G.degree v * a 
goal: (SimpleGraph.adjMatrix α G *ᵥ Function.const V a) v = ↑(G.degree v) * a

full_name: SimpleGraph.adjMatrix_mulVec_const_apply_of_regular
code: theorem adjMatrix_mulVec_const_apply_of_regular [NonAssocSemiring α] {d : ℕ} {a : α}
    (hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α *ᵥ Function.const _ a) v = d * a 
goal: (SimpleGraph.adjMatrix α G *ᵥ Function.const V a) v = ↑d * a

full_name: SimpleGraph.adjMatrix_pow_apply_eq_card_walk
code: 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 } 
goal: (SimpleGraph.adjMatrix α G ^ n) u v = ↑(Fintype.card ↑{p | p.length = n})

full_name: SimpleGraph.one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes
code: /-- 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 
goal: 1 + SimpleGraph.adjMatrix α G + (SimpleGraph.adjMatrix α G).compl = Matrix.of fun x x => 1

full_name: SimpleGraph.dotProduct_mulVec_adjMatrix
code: theorem dotProduct_mulVec_adjMatrix [NonAssocSemiring α] (x y : V → α) :
    x ⬝ᵥ (G.adjMatrix α).mulVec y = ∑ i : V, ∑ j : V, if G.Adj i j then x i * y j else 0 
goal: x ⬝ᵥ SimpleGraph.adjMatrix α G *ᵥ y = ∑ i : V, ∑ j : V, if G.Adj i j then x i * y j else 0

full_name: Matrix.IsAdjMatrix.adjMatrix_toGraph_eq
code: /-- 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 
goal: SimpleGraph.adjMatrix α h.toGraph = A