wiedijk_100_theorems.friendship_graphs
⟷
Archive.Wiedijk100Theorems.FriendshipGraphs
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)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -88,7 +88,7 @@ variable (R)
theorem adjMatrix_sq_of_ne {v w : V} (hvw : v ≠ w) : (G.adjMatrix R ^ 2) v w = 1 :=
by
rw [sq, ← Nat.cast_one, ← hG hvw]
- simp [common_neighbors, neighbor_finset_eq_filter, Finset.filter_filter, and_comm', ←
+ simp [common_neighbors, neighbor_finset_eq_filter, Finset.filter_filter, and_comm, ←
neighbor_finset_def]
#align theorems_100.friendship.adj_matrix_sq_of_ne Theorems100.Friendship.adjMatrix_sq_of_ne
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -244,7 +244,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
by
-- get a prime factor of d - 1
let p : ℕ := (d - 1).minFac
- have p_dvd_d_pred := (ZMod.nat_cast_zmod_eq_zero_iff_dvd _ _).mpr (d - 1).minFac_dvd
+ have p_dvd_d_pred := (ZMod.natCast_zmod_eq_zero_iff_dvd _ _).mpr (d - 1).minFac_dvd
have dpos : 0 < d := by linarith
have d_cast : ↑(d - 1) = (d : ℤ) - 1 := by norm_cast
haveI : Fact p.prime := ⟨Nat.minFac_prime (by linarith)⟩
@@ -264,7 +264,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
rw [adj_matrix_pow_mod_p_of_regular hG dmod hd hp2]
dsimp only [Fintype.card] at Vmod
simp only [Matrix.trace, Matrix.diag, mul_one, nsmul_eq_mul, LinearMap.coe_mk, sum_const]
- rw [Vmod, ← Nat.cast_one, ZMod.nat_cast_zmod_eq_zero_iff_dvd, Nat.dvd_one, Nat.minFac_eq_one_iff]
+ rw [Vmod, ← Nat.cast_one, ZMod.natCast_zmod_eq_zero_iff_dvd, Nat.dvd_one, Nat.minFac_eq_one_iff]
linarith
#align theorems_100.friendship.false_of_three_le_degree Theorems100.Friendship.false_of_three_le_degree
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -5,8 +5,8 @@ Authors: Aaron Anderson, Jalex Stark, Kyle Miller
-/
import Combinatorics.SimpleGraph.AdjMatrix
import LinearAlgebra.Matrix.Charpoly.FiniteField
-import Data.Int.Modeq
-import Data.Zmod.Basic
+import Data.Int.ModEq
+import Data.ZMod.Basic
import Tactic.IntervalCases
#align_import wiedijk_100_theorems.friendship_graphs from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
@@ -97,7 +97,7 @@ theorem adjMatrix_sq_of_ne {v w : V} (hvw : v ≠ w) : (G.adjMatrix R ^ 2) v w =
theorem adjMatrix_pow_three_of_not_adj {v w : V} (non_adj : ¬G.Adj v w) :
(G.adjMatrix R ^ 3) v w = degree G v :=
by
- rw [pow_succ, mul_eq_mul, adj_matrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
+ rw [pow_succ', mul_eq_mul, adj_matrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
apply sum_congr rfl
intro x hx
rw [adj_matrix_sq_of_ne _ hG, Nat.cast_one]
@@ -119,7 +119,7 @@ theorem degree_eq_of_not_adj {v w : V} (hvw : ¬G.Adj v w) : degree G v = degree
adj_matrix_pow_three_of_not_adj ℕ hG hvw, ←
adj_matrix_pow_three_of_not_adj ℕ hG fun h => hvw (G.symm h)]
conv_lhs => rw [← transpose_adj_matrix]
- simp only [pow_succ, sq, mul_eq_mul, ← transpose_mul, transpose_apply]
+ simp only [pow_succ', sq, mul_eq_mul, ← transpose_mul, transpose_apply]
simp only [← mul_eq_mul, mul_assoc]
#align theorems_100.friendship.degree_eq_of_not_adj Theorems100.Friendship.degree_eq_of_not_adj
@@ -229,7 +229,7 @@ theorem adjMatrix_pow_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)
iterate 2 cases' k with k; · exfalso; linarith
induction' k with k hind
· exact adj_matrix_sq_mod_p_of_regular hG dmod hd
- rw [pow_succ, hind (Nat.le_add_left 2 k)]
+ rw [pow_succ', hind (Nat.le_add_left 2 k)]
exact adj_matrix_mul_const_one_mod_p_of_regular dmod hd
#align theorems_100.friendship.adj_matrix_pow_mod_p_of_regular Theorems100.Friendship.adjMatrix_pow_mod_p_of_regular
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -102,7 +102,7 @@ theorem adjMatrix_pow_three_of_not_adj {v w : V} (non_adj : ¬G.Adj v w) :
intro x hx
rw [adj_matrix_sq_of_ne _ hG, Nat.cast_one]
rintro ⟨rfl⟩
- rw [mem_neighbor_finset] at hx
+ rw [mem_neighbor_finset] at hx
exact non_adj hx
#align theorems_100.friendship.adj_matrix_pow_three_of_not_adj Theorems100.Friendship.adjMatrix_pow_three_of_not_adj
@@ -155,8 +155,8 @@ theorem is_regular_of_not_existsPolitician (hG' : ¬ExistsPolitician G) :
use G.degree v
intro x
by_cases hvx : G.adj v x; swap; · exact (degree_eq_of_not_adj hG hvx).symm
- dsimp only [Theorems100.ExistsPolitician] at hG'
- push_neg at hG'
+ dsimp only [Theorems100.ExistsPolitician] at hG'
+ push_neg at hG'
rcases hG' v with ⟨w, hvw', hvw⟩
rcases hG' x with ⟨y, hxy', hxy⟩
by_cases hxw : G.adj x w
@@ -172,7 +172,7 @@ theorem is_regular_of_not_existsPolitician (hG' : ¬ExistsPolitician G) :
by
intro x hx
have h' := mem_univ (Subtype.mk x hx)
- rw [h, mem_singleton] at h'
+ rw [h, mem_singleton] at h'
injection h'
apply hxy'
rw [key ((mem_common_neighbors G).mpr ⟨hvx, G.symm hxw⟩),
@@ -262,7 +262,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
rw [trace_adj_matrix, zero_pow (Fact.out p.prime).Pos]
-- but the trace is 1 mod p when computed the other way
rw [adj_matrix_pow_mod_p_of_regular hG dmod hd hp2]
- dsimp only [Fintype.card] at Vmod
+ dsimp only [Fintype.card] at Vmod
simp only [Matrix.trace, Matrix.diag, mul_one, nsmul_eq_mul, LinearMap.coe_mk, sum_const]
rw [Vmod, ← Nat.cast_one, ZMod.nat_cast_zmod_eq_zero_iff_dvd, Nat.dvd_one, Nat.minFac_eq_one_iff]
linarith
@@ -275,12 +275,12 @@ theorem existsPolitician_of_degree_le_one (hd : G.IsRegularOfDegree d) (hd1 : d
by
have sq : d * d = d := by interval_cases <;> norm_num
have h := card_of_regular hG hd
- rw [sq] at h
+ rw [sq] at h
have : Fintype.card V ≤ 1 := by
cases' Fintype.card V with n
· exact zero_le _
· have : n = 0 := by
- rw [Nat.succ_sub_succ_eq_sub, tsub_zero] at h
+ rw [Nat.succ_sub_succ_eq_sub, tsub_zero] at h
linarith
subst n
use Classical.arbitrary V
@@ -304,7 +304,7 @@ theorem neighborFinset_eq_of_degree_eq_two (hd : G.IsRegularOfDegree 2) (v : V)
· have hfr := card_of_regular hG hd
linarith
· exact Finset.card_erase_of_mem (Finset.mem_univ _)
- · dsimp [is_regular_of_degree, degree] at hd
+ · dsimp [is_regular_of_degree, degree] at hd
rw [hd]
#align theorems_100.friendship.neighbor_finset_eq_of_degree_eq_two Theorems100.Friendship.neighborFinset_eq_of_degree_eq_two
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,11 +3,11 @@ 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
-/
-import Mathbin.Combinatorics.SimpleGraph.AdjMatrix
-import Mathbin.LinearAlgebra.Matrix.Charpoly.FiniteField
-import Mathbin.Data.Int.Modeq
-import Mathbin.Data.Zmod.Basic
-import Mathbin.Tactic.IntervalCases
+import Combinatorics.SimpleGraph.AdjMatrix
+import LinearAlgebra.Matrix.Charpoly.FiniteField
+import Data.Int.Modeq
+import Data.Zmod.Basic
+import Tactic.IntervalCases
#align_import wiedijk_100_theorems.friendship_graphs from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -212,14 +212,14 @@ theorem card_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1) (hd : G.IsRegu
end Nonempty
-theorem adjMatrix_sq_mul_const_one_of_regular (hd : G.IsRegularOfDegree d) :
+theorem adjMatrix_sq_hMul_const_one_of_regular (hd : G.IsRegularOfDegree d) :
(G.adjMatrix R * fun _ _ => 1) = fun _ _ => d := by ext x; simp [← hd x, degree]
-#align theorems_100.friendship.adj_matrix_sq_mul_const_one_of_regular Theorems100.Friendship.adjMatrix_sq_mul_const_one_of_regular
+#align theorems_100.friendship.adj_matrix_sq_mul_const_one_of_regular Theorems100.Friendship.adjMatrix_sq_hMul_const_one_of_regular
-theorem adjMatrix_mul_const_one_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)
+theorem adjMatrix_hMul_const_one_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)
(hd : G.IsRegularOfDegree d) : (G.adjMatrix (ZMod p) * fun _ _ => 1) = fun _ _ => 1 := by
rw [adj_matrix_sq_mul_const_one_of_regular hd, dmod]
-#align theorems_100.friendship.adj_matrix_mul_const_one_mod_p_of_regular Theorems100.Friendship.adjMatrix_mul_const_one_mod_p_of_regular
+#align theorems_100.friendship.adj_matrix_mul_const_one_mod_p_of_regular Theorems100.Friendship.adjMatrix_hMul_const_one_mod_p_of_regular
/-- Modulo a factor of `d-1`, the square and all higher powers of the adjacency matrix
of a `d`-regular friendship graph reduce to the matrix whose entries are all 1. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,11 +2,6 @@
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
-
-! This file was ported from Lean 3 source module wiedijk_100_theorems.friendship_graphs
-! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Combinatorics.SimpleGraph.AdjMatrix
import Mathbin.LinearAlgebra.Matrix.Charpoly.FiniteField
@@ -14,6 +9,8 @@ import Mathbin.Data.Int.Modeq
import Mathbin.Data.Zmod.Basic
import Mathbin.Tactic.IntervalCases
+#align_import wiedijk_100_theorems.friendship_graphs from "leanprover-community/mathlib"@"08b081ea92d80e3a41f899eea36ef6d56e0f1db0"
+
/-!
# The Friendship Theorem
mathlib commit https://github.com/leanprover-community/mathlib/commit/bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller
! This file was ported from Lean 3 source module wiedijk_100_theorems.friendship_graphs
-! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
+! leanprover-community/mathlib commit 08b081ea92d80e3a41f899eea36ef6d56e0f1db0
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -17,6 +17,9 @@ import Mathbin.Tactic.IntervalCases
/-!
# The Friendship Theorem
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
## Definitions and Statement
- A `friendship` graph is one in which any two distinct vertices have exactly one neighbor in common
- A `politician`, at least in the context of this problem, is a vertex in a graph which is adjacent
mathlib commit https://github.com/leanprover-community/mathlib/commit/2a0ce625dbb0ffbc7d1316597de0b25c1ec75303
@@ -130,7 +130,7 @@ theorem degree_eq_of_not_adj {v w : V} (hvw : ¬G.Adj v w) : degree G v = degree
theorem adjMatrix_sq_of_regular (hd : G.IsRegularOfDegree d) :
G.adjMatrix R ^ 2 = fun v w => if v = w then d else 1 :=
by
- ext (v w); by_cases h : v = w
+ ext v w; by_cases h : v = w
· rw [h, sq, mul_eq_mul, adj_matrix_mul_self_apply_self, hd]; simp
· rw [adj_matrix_sq_of_ne R hG h, if_neg h]
#align theorems_100.friendship.adj_matrix_sq_of_regular Theorems100.Friendship.adjMatrix_sq_of_regular
mathlib commit https://github.com/leanprover-community/mathlib/commit/893964fc28cefbcffc7cb784ed00a2895b4e65cf
@@ -3,8 +3,8 @@ 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
-! This file was ported from Lean 3 source module «100-theorems-list».«83_friendship_graphs»
-! leanprover-community/mathlib commit 328375597f2c0dd00522d9c2e5a33b6a6128feeb
+! This file was ported from Lean 3 source module wiedijk_100_theorems.friendship_graphs
+! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
nat_cast
/int_cast
/rat_cast
to natCast
/intCast
/ratCast
(#11486)
Now that I am defining NNRat.cast
, I want a definitive answer to this naming issue. Plenty of lemmas in mathlib already use natCast
/intCast
/ratCast
over nat_cast
/int_cast
/rat_cast
, and this matches with the general expectation that underscore-separated name parts correspond to a single declaration.
@@ -240,7 +240,7 @@ variable [Nonempty V]
theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : False := by
-- get a prime factor of d - 1
let p : ℕ := (d - 1).minFac
- have p_dvd_d_pred := (ZMod.nat_cast_zmod_eq_zero_iff_dvd _ _).mpr (d - 1).minFac_dvd
+ have p_dvd_d_pred := (ZMod.natCast_zmod_eq_zero_iff_dvd _ _).mpr (d - 1).minFac_dvd
have dpos : 1 ≤ d := by linarith
have d_cast : ↑(d - 1) = (d : ℤ) - 1 := by norm_cast
haveI : Fact p.Prime := ⟨Nat.minFac_prime (by linarith)⟩
@@ -260,7 +260,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
dsimp only [Fintype.card] at Vmod
simp only [Matrix.trace, Matrix.diag, mul_one, nsmul_eq_mul, LinearMap.coe_mk, sum_const,
of_apply, Ne]
- rw [Vmod, ← Nat.cast_one (R := ZMod (Nat.minFac (d - 1))), ZMod.nat_cast_zmod_eq_zero_iff_dvd,
+ rw [Vmod, ← Nat.cast_one (R := ZMod (Nat.minFac (d - 1))), ZMod.natCast_zmod_eq_zero_iff_dvd,
Nat.dvd_one, Nat.minFac_eq_one_iff]
linarith
#align theorems_100.friendship.false_of_three_le_degree Theorems100.Friendship.false_of_three_le_degree
@@ -181,7 +181,7 @@ theorem card_of_regular (hd : G.IsRegularOfDegree d) : d + (Fintype.card V - 1)
trans ((G.adjMatrix ℕ ^ 2) *ᵥ (fun _ => 1)) v
· rw [adjMatrix_sq_of_regular hG hd, mulVec, dotProduct, ← insert_erase (mem_univ v)]
simp only [sum_insert, mul_one, if_true, Nat.cast_id, eq_self_iff_true, mem_erase, not_true,
- Ne.def, not_false_iff, add_right_inj, false_and_iff, of_apply]
+ Ne, not_false_iff, add_right_inj, false_and_iff, of_apply]
rw [Finset.sum_const_nat, card_erase_of_mem (mem_univ v), mul_one]; · rfl
intro x hx; simp [(ne_of_mem_erase hx).symm]
· rw [sq, ← mulVec_mulVec]
@@ -259,7 +259,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
rw [adjMatrix_pow_mod_p_of_regular hG dmod hd hp2]
dsimp only [Fintype.card] at Vmod
simp only [Matrix.trace, Matrix.diag, mul_one, nsmul_eq_mul, LinearMap.coe_mk, sum_const,
- of_apply, Ne.def]
+ of_apply, Ne]
rw [Vmod, ← Nat.cast_one (R := ZMod (Nat.minFac (d - 1))), ZMod.nat_cast_zmod_eq_zero_iff_dvd,
Nat.dvd_one, Nat.minFac_eq_one_iff]
linarith
We change the following field in the definition of an additive commutative monoid:
nsmul_succ : ∀ (n : ℕ) (x : G),
- AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+ AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x
where the latter is more natural
We adjust the definitions of ^
in monoids, groups, etc.
Originally there was a warning comment about why this natural order was preferred
use
x * npowRec n x
and notnpowRec n x * x
in the definition to make sure that definitional unfolding ofnpowRec
is blocked, to avoid deep recursion issues.
but it seems to no longer apply.
Remarks on the PR :
pow_succ
and pow_succ'
have switched their meanings.Ideal.IsPrime.mul_mem_pow
which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul
.@@ -93,7 +93,7 @@ theorem adjMatrix_sq_of_ne {v w : V} (hvw : v ≠ w) :
We use it to show that nonadjacent vertices have equal degrees. -/
theorem adjMatrix_pow_three_of_not_adj {v w : V} (non_adj : ¬G.Adj v w) :
(G.adjMatrix R ^ 3 : Matrix V V R) v w = degree G v := by
- rw [pow_succ, adjMatrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
+ rw [pow_succ', adjMatrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
apply sum_congr rfl
intro x hx
rw [adjMatrix_sq_of_ne _ hG, Nat.cast_one]
@@ -226,7 +226,7 @@ theorem adjMatrix_pow_mod_p_of_regular {p : ℕ} (dmod : (d : ZMod p) = 1)
| k + 2 =>
induction' k with k hind
· exact adjMatrix_sq_mod_p_of_regular hG dmod hd
- rw [pow_succ, hind (Nat.le_add_left 2 k)]
+ rw [pow_succ', hind (Nat.le_add_left 2 k)]
exact adjMatrix_mul_const_one_mod_p_of_regular dmod hd
#align theorems_100.friendship.adj_matrix_pow_mod_p_of_regular Theorems100.Friendship.adjMatrix_pow_mod_p_of_regular
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>
@@ -178,7 +178,7 @@ theorem isRegularOf_not_existsPolitician (hG' : ¬ExistsPolitician G) :
This essentially means that the graph has `d ^ 2 - d + 1` vertices. -/
theorem card_of_regular (hd : G.IsRegularOfDegree d) : d + (Fintype.card V - 1) = d * d := by
have v := Classical.arbitrary V
- trans (G.adjMatrix ℕ ^ 2).mulVec (fun _ => 1) v
+ trans ((G.adjMatrix ℕ ^ 2) *ᵥ (fun _ => 1)) v
· rw [adjMatrix_sq_of_regular hG hd, mulVec, dotProduct, ← insert_erase (mem_univ v)]
simp only [sum_insert, mul_one, if_true, Nat.cast_id, eq_self_iff_true, mem_erase, not_true,
Ne.def, not_false_iff, add_right_inj, false_and_iff, of_apply]
f ^ n
(#9617)
This involves moving lemmas from Algebra.GroupPower.Ring
to Algebra.GroupWithZero.Basic
and changing some 0 < n
assumptions to n ≠ 0
.
From LeanAPAP
@@ -254,7 +254,7 @@ theorem false_of_three_le_degree (hd : G.IsRegularOfDegree d) (h : 3 ≤ d) : Fa
have := ZMod.trace_pow_card (G.adjMatrix (ZMod p))
contrapose! this; clear this
-- the trace is 0 mod p when computed one way
- rw [trace_adjMatrix, zero_pow (Fact.out (p := p.Prime)).pos]
+ rw [trace_adjMatrix, zero_pow this.out.ne_zero]
-- but the trace is 1 mod p when computed the other way
rw [adjMatrix_pow_mod_p_of_regular hG dmod hd hp2]
dsimp only [Fintype.card] at Vmod
⬝
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).
@@ -93,7 +93,7 @@ theorem adjMatrix_sq_of_ne {v w : V} (hvw : v ≠ w) :
We use it to show that nonadjacent vertices have equal degrees. -/
theorem adjMatrix_pow_three_of_not_adj {v w : V} (non_adj : ¬G.Adj v w) :
(G.adjMatrix R ^ 3 : Matrix V V R) v w = degree G v := by
- rw [pow_succ, mul_eq_mul, adjMatrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
+ rw [pow_succ, adjMatrix_mul_apply, degree, card_eq_sum_ones, Nat.cast_sum]
apply sum_congr rfl
intro x hx
rw [adjMatrix_sq_of_ne _ hG, Nat.cast_one]
@@ -114,8 +114,8 @@ theorem degree_eq_of_not_adj {v w : V} (hvw : ¬G.Adj v w) : degree G v = degree
← adjMatrix_pow_three_of_not_adj ℕ hG hvw,
← adjMatrix_pow_three_of_not_adj ℕ hG fun h => hvw (G.symm h)]
conv_lhs => rw [← transpose_adjMatrix]
- simp only [pow_succ _ 2, sq, mul_eq_mul, ← transpose_mul, transpose_apply]
- simp only [← mul_eq_mul, mul_assoc]
+ simp only [pow_succ _ 2, sq, ← transpose_mul, transpose_apply]
+ simp only [mul_assoc]
#align theorems_100.friendship.degree_eq_of_not_adj Theorems100.Friendship.degree_eq_of_not_adj
/-- Let `A` be the adjacency matrix of a graph `G`.
@@ -125,7 +125,7 @@ theorem degree_eq_of_not_adj {v w : V} (hvw : ¬G.Adj v w) : degree G v = degree
theorem adjMatrix_sq_of_regular (hd : G.IsRegularOfDegree d) :
G.adjMatrix R ^ 2 = of fun v w => if v = w then (d : R) else (1 : R) := by
ext (v w); by_cases h : v = w
- · rw [h, sq, mul_eq_mul, adjMatrix_mul_self_apply_self, hd]; simp
+ · rw [h, sq, adjMatrix_mul_self_apply_self, hd]; simp
· rw [adjMatrix_sq_of_ne R hG h, of_apply, if_neg h]
#align theorems_100.friendship.adj_matrix_sq_of_regular Theorems100.Friendship.adjMatrix_sq_of_regular
@@ -184,7 +184,7 @@ theorem card_of_regular (hd : G.IsRegularOfDegree d) : d + (Fintype.card V - 1)
Ne.def, not_false_iff, add_right_inj, false_and_iff, of_apply]
rw [Finset.sum_const_nat, card_erase_of_mem (mem_univ v), mul_one]; · rfl
intro x hx; simp [(ne_of_mem_erase hx).symm]
- · rw [sq, mul_eq_mul, ← mulVec_mulVec]
+ · rw [sq, ← mulVec_mulVec]
simp only [adjMatrix_mulVec_const_apply_of_regular hd, neighborFinset,
card_neighborSet_eq_degree, hd v, Function.const_def, adjMatrix_mulVec_apply _ _ (mulVec _ _),
mul_one, sum_const, Set.toFinset_card, Algebra.id.smul_eq_mul, Nat.cast_id]
@@ -206,7 +206,7 @@ end Nonempty
theorem adjMatrix_sq_mul_const_one_of_regular (hd : G.IsRegularOfDegree d) :
G.adjMatrix R * of (fun _ _ => 1) = of (fun _ _ => (d : R)) := by
ext x
- simp only [← hd x, degree, mul_eq_mul, adjMatrix_mul_apply, sum_const, Nat.smul_one_eq_coe,
+ simp only [← hd x, degree, adjMatrix_mul_apply, sum_const, Nat.smul_one_eq_coe,
of_apply]
#align theorems_100.friendship.adj_matrix_sq_mul_const_one_of_regular Theorems100.Friendship.adjMatrix_sq_mul_const_one_of_regular
@@ -2,11 +2,6 @@
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
-
-! This file was ported from Lean 3 source module wiedijk_100_theorems.friendship_graphs
-! leanprover-community/mathlib commit 5563b1b49e86e135e8c7b556da5ad2f5ff881cad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Combinatorics.SimpleGraph.AdjMatrix
import Mathlib.LinearAlgebra.Matrix.Charpoly.FiniteField
@@ -14,6 +9,8 @@ import Mathlib.Data.Int.ModEq
import Mathlib.Data.ZMod.Basic
import Mathlib.Tactic.IntervalCases
+#align_import wiedijk_100_theorems.friendship_graphs from "leanprover-community/mathlib"@"5563b1b49e86e135e8c7b556da5ad2f5ff881cad"
+
/-!
# The Friendship Theorem
The unported dependencies are