diff --git a/FormalBook/Chapter_01.lean b/FormalBook/Chapter_01.lean index fa9c395..aeec633 100644 --- a/FormalBook/Chapter_01.lean +++ b/FormalBook/Chapter_01.lean @@ -3,10 +3,11 @@ Copyright 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching, Ralf Stephan -/ +import Mathlib.Algebra.Order.Ring.Star +import Mathlib.Data.Int.Lemmas +import Mathlib.Data.Int.Star import Mathlib.NumberTheory.LucasLehmer import Mathlib.NumberTheory.PrimeCounting -import Mathlib.NumberTheory.Fermat -import Mathlib.Analysis.SpecialFunctions.Pow.Real open Finset Nat open BigOperators @@ -27,7 +28,7 @@ open BigOperators -/ theorem infinity_of_primes₁ (S : Finset ℕ) (h : ∀ q ∈ S, Nat.Prime q): ∃ (p : ℕ), Nat.Prime p ∧ p ∉ S := by - let n := 1 + ∏ q in S, q + let n := 1 + ∏ q ∈ S, q /- "This `n` has a prime divisor": we pick the minimal one, the argument works with any prime divisor -/ let p := n.minFac @@ -36,8 +37,8 @@ theorem infinity_of_primes₁ (S : Finset ℕ) (h : ∀ q ∈ S, Nat.Prime q): (Finset.prod_pos fun q hq ↦ Prime.pos <| h q hq) refine ⟨hp, ?_⟩ by_contra a - have h_p_div_prod : p ∣ ∏ q in S, q := dvd_prod_of_mem (fun (i : ℕ) ↦ i) a - have h_p_div_diff : p ∣ n - ∏ q in S, q := dvd_sub' (minFac_dvd n) h_p_div_prod + have h_p_div_prod : p ∣ ∏ q ∈ S, q := dvd_prod_of_mem (fun (i : ℕ) ↦ i) a + have h_p_div_diff : p ∣ n - ∏ q ∈ S, q := dvd_sub (minFac_dvd n) h_p_div_prod have h_p_div_one : p ∣ 1 := by aesop exact Nat.Prime.not_dvd_one hp h_p_div_one @@ -52,7 +53,7 @@ local notation "F" => fermatNumber -- We actually prove something slighly stronger that what is in the book: -- also for n = 0, the statement is true. -- This is in mathlib as `fermatNumber_product` -lemma fermatProduct (n : ℕ) : ∏ k in range n, F k = F n - 2 := by +lemma fermatProduct (n : ℕ) : ∏ k ∈ range n, F k = F n - 2 := by induction' n with n hn · trivial · rw [prod_range_succ, hn] @@ -67,9 +68,9 @@ theorem infinity_of_primes₂ (k n : ℕ) (h : k < n) : Coprime (F n) (F k) := have h_n : m ∣ F n := (F n).gcd_dvd_left (F k) have h_k : m ∣ F k := (F n).gcd_dvd_right (F k) have h_m : m ∣ 2 := by - have h_m_prod : m ∣ (∏ k in range n, F k) := + have h_m_prod : m ∣ (∏ k ∈ range n, F k) := dvd_trans h_k (dvd_prod_of_mem F (mem_range.mpr h)) - have h_prod : (∏ k in range n, F k) + 2 = F n := by + have h_prod : (∏ k ∈ range n, F k) + 2 = F n := by rw [fermatProduct, Nat.sub_add_cancel] refine' le_of_lt _ simp [two_lt_fermatNumber] @@ -116,8 +117,7 @@ theorem infinity_of_primes₃: rw [modEq_iff_dvd, dvd_iff_exists_eq_mul_left] at * obtain ⟨c, hc⟩ := this use c - simp only [CharP.cast_eq_zero, ge_iff_le, gt_iff_lt, pow_pos, cast_pred, cast_pow, cast_ofNat, - zero_sub, neg_sub] at hc + simp only [CharP.cast_eq_zero, zero_sub] at hc simp [cast_one, cast_pow, cast_ofNat, hc.symm] have h_mod_q' : (2 : (ZMod q)) ^ p = 1 := by have := (ZMod.natCast_eq_natCast_iff _ _ _).mpr h_mod_q @@ -154,9 +154,9 @@ theorem infinity_of_primes₃: exact (totient_prime hq).symm refine ⟨q, minFac_prime <| Nat.ne_of_gt ?_, ?_⟩ · calc 1 < 2^2 - 1 := one_lt_succ_succ 1 - _ ≤ 2^p - 1 := sub_one_le_sub_one <| pow_le_pow_of_le_right (succ_pos 1) (Prime.two_le hp) + _ ≤ 2^p - 1 := sub_one_le_sub_one <| Nat.pow_le_pow_right (succ_pos 1) (Prime.two_le hp) · have h2q : 2 ≤ q := Prime.two_le <| minFac_prime <| Nat.ne_of_gt <| lt_of_succ_lt <| - Nat.sub_le_sub_right ((pow_le_pow_of_le_right (succ_pos 1) (Prime.two_le hp))) 1 + Nat.sub_le_sub_right ((Nat.pow_le_pow_right (succ_pos 1) (Prime.two_le hp))) 1 exact lt_of_le_of_lt (Nat.le_of_dvd (Nat.sub_pos_of_lt <| h2q) h_piv_div_q_sub_one) <| pred_lt <| Nat.ne_of_gt <| Nat.le_of_lt h2q @@ -181,11 +181,11 @@ theorem infinity_of_primes₄ : Tendsto π atTop atTop := by have H_log_le_primeCountingReal_add_one (n : ℕ) (x : ℝ) (hxge : x ≥ n) (hxlt : x < n + 1) : Real.log x ≤ primeCountingReal x + 1 := calc - Real.log x ≤ ∑ k in Icc 1 n, (k : ℝ)⁻¹ := by sorry + Real.log x ≤ ∑ k ∈ Icc 1 n, (k : ℝ)⁻¹ := by sorry _ ≤ (∑' m : (S₁ x), (m : ℝ)⁻¹) := by sorry - _ ≤ (∏ p in primesBelow ⌊x⌋.natAbs, (∑' k : ℕ, (p ^ k : ℝ)⁻¹)) := by sorry - _ ≤ (∏ k in Icc 1 (primeCountingReal x), (nth Nat.Prime k) / ((nth Nat.Prime k) - 1)) := by sorry - _ ≤ (∏ k in Icc 1 (primeCountingReal x), (k + 1) / k) := by sorry + _ ≤ (∏ p ∈ primesBelow ⌊x⌋.natAbs, (∑' k : ℕ, (p ^ k : ℝ)⁻¹)) := by sorry + _ ≤ (∏ k ∈ Icc 1 (primeCountingReal x), (nth Nat.Prime k) / ((nth Nat.Prime k) - 1)) := by sorry + _ ≤ (∏ k ∈ Icc 1 (primeCountingReal x), (k + 1) / k) := by sorry _ ≤ primeCountingReal x + 1 := by sorry sorry @@ -212,23 +212,23 @@ lemma H_P4_1 {k p: ℝ} (hk: k > 0) (hp: p ≥ k + 1): p / (p - 1) ≤ (k + 1) / @le_sub_iff_add_le] exact hp -lemma prod_Icc_succ_div (n : ℕ) (hn : 2 ≤ n) : (∏ x in Icc 1 n, ((x + 1) : ℝ) / x) = n + 1 := by - rw [← Nat.Ico_succ_right] +lemma prod_Icc_succ_div (n : ℕ) (hn : 2 ≤ n) : (∏ x ∈ Icc 1 n, ((x + 1) : ℝ) / x) = n + 1 := by + rw [← Finset.Ico_succ_right_eq_Icc] induction' n with n h · simp - · rw [Finset.prod_Ico_succ_top <| Nat.le_add_left 1 n] - norm_num + · simp only [succ_eq_succ, succ_eq_add_one] at h ⊢ + rw [Finset.prod_Ico_succ_top <| Nat.le_add_left 1 n] cases' lt_or_ge n 2 with _ h2 · interval_cases n · tauto · norm_num field_simp [Finset.prod_eq_zero_iff] at h ⊢ rw [h h2] - ring + norm_num -- Removed unnecessary assumption `(hpi3 : (π 3) = 2)` lemma H_P4_2 (x : ℕ) (hx : x ≥ 3) : - (∏ x in Icc 1 (π x), ((x + 1) : ℝ) / x) = (π x) + 1 := by + (∏ x ∈ Icc 1 (π x), ((x + 1) : ℝ) / x) = (π x) + 1 := by rw [prod_Icc_succ_div] exact Monotone.imp monotone_primeCounting hx @@ -334,7 +334,7 @@ using the sum of inverses of primes -/ -- see Archive.Wiedijk100Theorems.SumOfPrimeReciprocalsDiverges theorem infinity_of_primes₆ : - Tendsto (fun n ↦ ∑ p in Finset.filter (fun p ↦ Nat.Prime p) (range n), 1 / (p : ℝ)) + Tendsto (fun n ↦ ∑ p ∈ Finset.filter (fun p ↦ Nat.Prime p) (range n), 1 / (p : ℝ)) atTop atTop := by sorry diff --git a/FormalBook/Chapter_02.lean b/FormalBook/Chapter_02.lean index 49efdd8..3884217 100644 --- a/FormalBook/Chapter_02.lean +++ b/FormalBook/Chapter_02.lean @@ -50,7 +50,7 @@ theorem real_main_inequality {x : ℝ} (n_large : (512 : ℝ) ≤ x) : have h5 : 0 < x := lt_of_lt_of_le (by norm_num1) n_large rw [← div_le_one (rpow_pos_of_pos four_pos x), ← div_div_eq_mul_div, ← rpow_sub four_pos, ← mul_div 2 x, mul_div_left_comm, ← mul_one_sub, (by norm_num1 : (1 : ℝ) - 2 / 3 = 1 / 3), - mul_one_div, ← log_nonpos_iff (hf' x h5), ← hf x h5] + mul_one_div, ← log_nonpos_iff (hf' x h5).le, ← hf x h5] have h : ConcaveOn ℝ (Set.Ioi 0.5) f := by apply ConcaveOn.sub apply ConcaveOn.add @@ -76,7 +76,7 @@ theorem real_main_inequality {x : ℝ} (n_large : (512 : ℝ) ≤ x) : norm_num1 · have : sqrt (2 * 512) = 32 := (sqrt_eq_iff_mul_self_eq_of_pos (by norm_num1)).mpr (by norm_num1) - rw [hf _ (by norm_num1), log_nonpos_iff (hf' _ (by norm_num1)), this, + rw [hf _ (by norm_num1), log_nonpos_iff (hf' _ (by norm_num1)).le, this, div_le_one (by positivity)] conv in 512 => equals 2 ^ 9 => norm_num1 conv in 2 * 512 => equals 2 ^ 10 => norm_num1 @@ -96,7 +96,7 @@ open Nat theorem bertrand_main_inequality {n : ℕ} (n_large : 512 ≤ n) : n * (2 * n) ^ Nat.sqrt (2 * n) * 4 ^ (2 * n / 3) ≤ 4 ^ n := by rw [← @cast_le ℝ] - simp only [cast_add, cast_one, cast_mul, cast_pow, ← Real.rpow_natCast] + simp only [cast_mul, cast_pow, cast_ofNat, ← rpow_natCast] refine' _root_.trans ?_ (Bertrand.real_main_inequality (by exact_mod_cast n_large)) gcongr · have n2_pos : 0 < 2 * n := by positivity @@ -110,7 +110,7 @@ factorization of the central binomial coefficient only has factors at most `2 * -/ theorem centralBinom_factorization_small (n : ℕ) (n_large : 2 < n) (no_prime : ¬∃ p : ℕ, p.Prime ∧ n < p ∧ p ≤ 2 * n) : - centralBinom n = ∏ p in Finset.range (2 * n / 3 + 1), p ^ (centralBinom n).factorization p := by + centralBinom n = ∏ p ∈ Finset.range (2 * n / 3 + 1), p ^ (centralBinom n).factorization p := by refine' (Eq.trans _ n.prod_pow_factorization_centralBinom).symm apply Finset.prod_subset · exact Finset.range_subset.2 (add_le_add_right (Nat.div_le_self _ _) _) @@ -138,7 +138,7 @@ theorem centralBinom_le_of_no_bertrand_prime (n : ℕ) (n_big : 2 < n) have n2_pos : 1 ≤ 2 * n := mul_pos (zero_lt_two' ℕ) n_pos let S := (Finset.range (2 * n / 3 + 1)).filter Nat.Prime let f x := x ^ n.centralBinom.factorization x - have : ∏ x : ℕ in S, f x = ∏ x : ℕ in Finset.range (2 * n / 3 + 1), f x := by + have : ∏ x ∈ S, f x = ∏ x ∈ Finset.range (2 * n / 3 + 1), f x := by refine' Finset.prod_filter_of_ne fun p _ h => _ contrapose! h dsimp [f] diff --git a/FormalBook/Chapter_03.lean b/FormalBook/Chapter_03.lean index e22bd3d..fa874ef 100644 --- a/FormalBook/Chapter_03.lean +++ b/FormalBook/Chapter_03.lean @@ -3,11 +3,10 @@ Copyright 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching, Christopher Schmidt -/ +import Mathlib.Algebra.Order.Star.Basic import Mathlib.Analysis.Normed.Field.Lemmas -import Mathlib.Data.Int.Star -import Mathlib.Data.Rat.Star +import Mathlib.Data.Nat.Prime.Basic import Mathlib.Tactic.Qify ---import data.nat.sqrt --set_option trace.simp_lemmas true @@ -71,9 +70,10 @@ theorem prime_div_descFactorial (n k m l p : ℕ) (h_klen : k ≤ n) have h_fraction: (n.factorial / (k.factorial * (n - k).factorial)) = (n.factorial / (n - k).factorial) / k.factorial := by qify - field_simp + simp rw [mul_comm] - exact Or.inl rfl + norm_cast + exact (Nat.div_div_eq_div_mul n ! (n - k)! k !).symm rw [h_fraction] at h_pl_div_fac have h_pl_div_fac_part: p^l ∣ (n.factorial / (n - k).factorial) := by have h_eq_pl_with_k := exists_eq_mul_right_of_dvd h_pl_div_fac @@ -82,8 +82,7 @@ theorem prime_div_descFactorial (n k m l p : ℕ) (h_klen : k ≤ n) use (j * k.factorial) rw [(mul_rotate _ _ _).symm, ← h_eq] qify - field_simp - rw [mul_comm ((n - k)! : ℚ) _, mul_assoc] + aesop cases' h_eq_pl with j h_eq refine' Dvd.intro j _ rw [mul_comm] diff --git a/FormalBook/Chapter_05.lean b/FormalBook/Chapter_05.lean index 8403fcf..ea4c255 100644 --- a/FormalBook/Chapter_05.lean +++ b/FormalBook/Chapter_05.lean @@ -3,8 +3,8 @@ Copyright 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching, Nikolas Kuhn -/ -import Mathlib.Algebra.Polynomial.Basic -import Mathlib.Data.ZMod.Basic +import Mathlib.Algebra.Lie.OfAssociative +import Mathlib.RingTheory.LittleWedderburn open ZMod Finset open Polynomial (X) @@ -108,7 +108,7 @@ decomposition`X^p - 1 = (X - ζ) * (X - ζ ^ 2) * ... * (X - ζ ^ p)`. -/ lemma fact_B (p : ℕ) [Fact (Prime p)] (K : Type _) [Field K] (ζ : Kˣ) (h_1 : ζ ^ p = 1) (h_2 : ζ ≠ 1) : - X ^ (p - 1) - 1 = ∏ i in Icc 1 p, (X - (Polynomial.C (ζ : K)) ^ i) := by + X ^ (p - 1) - 1 = ∏ i ∈ Icc 1 p, (X - (Polynomial.C (ζ : K)) ^ i) := by sorry theorem quadratic_reciprocity_2 (p q : ℕ) (hp : p ≠ 2) (hq : q ≠ 2) diff --git a/FormalBook/Chapter_06.lean b/FormalBook/Chapter_06.lean index 20acb7c..ae35a86 100644 --- a/FormalBook/Chapter_06.lean +++ b/FormalBook/Chapter_06.lean @@ -3,10 +3,13 @@ Copyright 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching, Nick Kuhn -/ -import Mathlib.RingTheory.Henselian -import Mathlib.RingTheory.HopfAlgebra -import Mathlib.RingTheory.LittleWedderburn import Mathlib.Algebra.Lie.OfAssociative +import Mathlib.Algebra.Order.Ring.Star +import Mathlib.Data.Int.Star +import Mathlib.Data.Real.StarOrdered +import Mathlib.Deprecated.Order +import Mathlib.RingTheory.LittleWedderburn +import Mathlib.RingTheory.SimpleRing.Principal open Finset Subring Polynomial Complex BigOperators Nat /-! @@ -71,8 +74,8 @@ theorem h_lamb_gt_q_sub_one (q n : ℕ) (lamb : ℂ): have h_ineq : ‖((X - C lamb).eval (q : ℂ))‖^2 > ((q : ℝ) - 1)^2 := by calc - _ = ‖q - lamb‖^2 := by - simp only [eval_sub, eval_X, eval_C, norm_eq_abs] + _ = ‖q - lamb‖^2 := by sorry + --simp only [eval_sub, eval_X, eval_C, norm_eq_abs] _ = ‖(q : ℂ) - a - I*b‖^2 := by sorry _ = ‖(q : ℂ) - a‖^2 + ‖b‖^2 := by sorry _ = (q : ℝ)^2 - 2*‖a‖*q + ‖a‖^2 + ‖b‖^2 := by sorry @@ -81,9 +84,9 @@ theorem h_lamb_gt_q_sub_one (q n : ℕ) (lamb : ℂ): have : 0 ≤ ((q : ℝ) - 1)^2 := sq_nonneg ((q : ℝ) - 1) have g := (Real.sqrt_lt_sqrt_iff (sq_nonneg ((q : ℝ) - 1))).mpr (h_ineq) have : Real.sqrt (((q:ℝ) - 1) ^ 2) = ((q : ℝ) - 1) := by sorry - rw [this, norm_eq_abs, Real.sqrt_sq] at g + rw [this, Real.sqrt_sq] at g · exact g - · exact AbsoluteValue.nonneg Complex.abs (eval (↑q) (X - C lamb)) + · sorry lemma div_of_qpoly_div (k n q : ℕ) (hq : 1 < q) (hk : 0 < k) (hn : 0 < n) (H : q ^ k - 1 ∣ q ^ n - 1) : k ∣ n := by @@ -189,8 +192,8 @@ theorem wedderburn (h: Fintype R): IsField R := by have finclassa: ∀ (A : ConjClasses Rˣ), Fintype ↑(ConjClasses.carrier A) := fun _ ↦ ConjClasses.instFintypeElemCarrier - have : ∀ (A : ConjClasses Rˣ), Fintype ↑(Set.centralizer {Quotient.out' A}) := - fun _ ↦ setFintype (Set.centralizer {Quotient.out' _}) + have : ∀ (A : ConjClasses Rˣ), Fintype ↑(Set.centralizer {Quotient.out A}) := + fun _ ↦ setFintype (Set.centralizer {Quotient.out _}) letI fintypea : ∀ (A : ConjClasses Rˣ), Fintype ↑{A | have := finclassa A; Fintype.card ↑(ConjClasses.carrier A) > 1} := @@ -278,7 +281,7 @@ theorem wedderburn (h: Fintype R): IsField R := by by_contra have g : Polynomial.map (Int.castRingHom ℂ) (phi n) = - ∏ lamb in (primitiveRoots n ℂ), (X - C lamb) := by + ∏ lamb ∈ (primitiveRoots n ℂ), (X - C lamb) := by dsimp only [phi] simp only [map_cyclotomic] have := isPrimitiveRoot_exp n h_n diff --git a/FormalBook/Chapter_08.lean b/FormalBook/Chapter_08.lean index a381ab2..9ff0f09 100644 --- a/FormalBook/Chapter_08.lean +++ b/FormalBook/Chapter_08.lean @@ -4,11 +4,10 @@ Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching -/ import Mathlib.Tactic -import Mathlib.Data.Real.Basic -import Mathlib.Data.Complex.Exponential --- import Mathlib.Analysis.Calculus.IteratedDeriv --- import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic --- import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse +import Mathlib.Analysis.Calculus.IteratedDeriv.Defs +import Mathlib.Analysis.InnerProductSpace.Basic +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse + open Real (exp )--pi crccos) @@ -94,7 +93,7 @@ Let `n : ℕ`, `n ≥ 1` be fixed, and consider `f_aux n x = x ^ n * (1 - x) ^ n noncomputable def f_aux (n : ℕ) (x : ℝ) := x ^ n * (1 - x) ^ n / n.factorial -lemma lem_aux_i (n : ℕ) (x : ℝ) : ∃ c : ℕ → ℤ, f_aux n x = ∑ i in Icc n (2 * n), (c i) * x ^ i := by +lemma lem_aux_i (n : ℕ) (x : ℝ) : ∃ c : ℕ → ℤ, f_aux n x = ∑ i ∈ Icc n (2 * n), (c i) * x ^ i := by sorry lemma lem_aux_ii (n : ℕ) (x : ℝ) (h_1 : 0 < x) (h_2 : x < 0) : diff --git a/FormalBook/Chapter_20.lean b/FormalBook/Chapter_20.lean index 8c6ab9d..3e78d88 100644 --- a/FormalBook/Chapter_20.lean +++ b/FormalBook/Chapter_20.lean @@ -9,7 +9,6 @@ import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Combinatorics.Enumerative.DoubleCounting import Mathlib.Combinatorics.SimpleGraph.Clique import Mathlib.Combinatorics.SimpleGraph.DegreeSum -import Mathlib.Data.Real.StarOrdered open Real open RealInnerProductSpace @@ -82,7 +81,7 @@ theorem cauchy_schwarz_inequality (a b : V) : ⟪ a, b ⟫ ^ 2 ≤ ‖a‖ ^ 2 * have ha_sq : ‖a‖ ^ 2 ≠ 0 := by aesop have := discrim_lt_zero ha_sq this unfold discrim at this - have : (2 * inner a b) ^ 2 < 4 * ‖a‖ ^ 2 * ‖b‖ ^ 2 := by linarith + have : (2 * inner _ a b) ^ 2 < 4 * ‖a‖ ^ 2 * ‖b‖ ^ 2 := by linarith linarith diff --git a/FormalBook/Chapter_24.lean b/FormalBook/Chapter_24.lean index c7026e7..68309d9 100644 --- a/FormalBook/Chapter_24.lean +++ b/FormalBook/Chapter_24.lean @@ -3,9 +3,9 @@ Copyright 2022 Moritz Firsching. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Moritz Firsching -/ -import Mathlib.Data.Matrix.DoublyStochastic -import Mathlib.Data.Real.Basic +import Mathlib.Analysis.Convex.DoublyStochasticMatrix import Mathlib.LinearAlgebra.Matrix.Permanent + /-! # Van der Waerden's permanent conjecture diff --git a/FormalBook/Chapter_28.lean b/FormalBook/Chapter_28.lean index e011f02..fc181ed 100644 --- a/FormalBook/Chapter_28.lean +++ b/FormalBook/Chapter_28.lean @@ -60,7 +60,8 @@ lemma handshaking : ∑ v, d(v) = 2 * #E := by _ = ∑ v, #I(v) := by simp [G.card_incidenceFinset_eq_degree] _ = ∑ v, #{e ∈ E | v ∈ e} := by simp [G.incidenceFinset_eq_filter] _ = ∑ e ∈ E, #{v | v ∈ e} := Finset.sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow _ - _ = ∑ e ∈ E, 2 := Finset.sum_congr rfl (λ e he ↦ (G.card_filter_mem_of_mem_edgeFinset e he)) + -- FIXME: was (G.card_filter_mem_of_mem_edgeFinset e he)) but is commented out currently in Mathlib.EdgeFinset + _ = ∑ e ∈ E, 2 := Finset.sum_congr rfl (λ e he ↦ sorry) _ = 2 * ∑ e ∈ E, 1 := (Finset.mul_sum E (λ _ ↦ 1) 2).symm _ = 2 * #E := by rw [Finset.card_eq_sum_ones E] diff --git a/FormalBook/Mathlib/EdgeFinset.lean b/FormalBook/Mathlib/EdgeFinset.lean index 0ac9c52..d7345e1 100644 --- a/FormalBook/Mathlib/EdgeFinset.lean +++ b/FormalBook/Mathlib/EdgeFinset.lean @@ -29,9 +29,6 @@ theorem not_isDiag_iff_exists {z : Sym2 α} : ¬ z.IsDiag ↔ ∃ x y, x ≠ y · intro h; simpa using h x y · aesop -@[coe] -protected def toMultiset (z : Sym2 α) : Multiset α := - Sym2.lift ⟨fun x y => {x, y}, Multiset.pair_comm⟩ z instance : Coe (Sym2 α) (Multiset α) := ⟨Sym2.toMultiset⟩ @@ -39,8 +36,6 @@ instance : Coe (Sym2 α) (Multiset α) := ⟨Sym2.toMultiset⟩ variable [DecidableEq α] -@[coe] -protected def toFinset (z : Sym2 α) : Finset α := Multiset.toFinset z instance : Coe (Sym2 α) (Finset α) := ⟨Sym2.toFinset⟩ @@ -49,27 +44,18 @@ instance : Coe (Sym2 α) (Finset α) := ⟨Sym2.toFinset⟩ @[simp] lemma toFinset_toMultiset {s : Sym2 α} : (s : Multiset α).toFinset = (s : Finset α) := rfl -@[simp] lemma mem_toFinset {z : Sym2 α} {x : α} : x ∈ (z : Finset α) ↔ x ∈ z := by - induction z; simp - @[simp] lemma coe_toFinset {z : Sym2 α} : ((z : Finset α) : Set α) = z := by ext; simp lemma toFinset_eq [Fintype α] {e : Sym2 α} : (e : Finset α) = {v | v ∈ e}.toFinset := by ext; simp -lemma card_toFinset_of_isDiag {z : Sym2 α} (h : z.IsDiag) : (z : Finset α).card = 1 := by - obtain ⟨x, rfl⟩ := isDiag_iff_exists.mp h - simp [Finset.card_eq_one] lemma card_toFinset_mk_of_ne {x y : α} (h : x ≠ y) : s(x, y).toFinset.card = 2 := by rw [Finset.card_eq_two] use x, y, h simp -lemma card_toFinset_of_not_isDiag {z : Sym2 α} (h : ¬z.IsDiag) : z.toFinset.card = 2 := by - induction z with | _ x y => exact card_toFinset_mk_of_ne h - lemma one_le_card_toFinset {z : Sym2 α} : 1 ≤ z.toFinset.card := by induction z; simp @@ -88,14 +74,18 @@ namespace SimpleGraph variable {α : Type*} {G : SimpleGraph α} [DecidableEq α] -lemma card_toFinset_of_mem_edgeSet (e : Sym2 α) (he : e ∈ G.edgeSet) : - (e : Finset α).card = 2 := - Sym2.card_toFinset_of_not_isDiag (not_isDiag_of_mem_edgeSet _ he) +-- lemma card_toFinset_of_mem_edgeSet (e : Sym2 α) (he : e ∈ G.edgeSet) : +-- (e : Finset α).card = 2 := by +-- refine Sym2.card_toFinset_of_not_isDiag ?_ + +-- have := (not_isDiag_of_mem_edgeSet _ he) + +-- sorry -lemma card_filter_mem_of_mem_edgeSet [Fintype α] (e : Sym2 α) (he : e ∈ G.edgeSet) : - Finset.card {v | v ∈ e} = 2 := by - rw [← SimpleGraph.card_toFinset_of_mem_edgeSet _ he] - congr; ext; simp +-- lemma card_filter_mem_of_mem_edgeSet [Fintype α] (e : Sym2 α) (he : e ∈ G.edgeSet) : +-- Finset.card {v | v ∈ e} = 2 := by +-- rw [← SimpleGraph.card_toFinset_of_mem_edgeSet _ he] +-- congr; ext; simp end SimpleGraph @@ -109,14 +99,14 @@ namespace SimpleGraph variable {α : Type*} [Fintype α] {G : SimpleGraph α} [DecidableRel G.Adj] [DecidableEq α] -lemma card_toFinset_of_mem_edgeFinset (e : Sym2 α) (he : e ∈ G.edgeFinset) : - (e : Finset α).card = 2 := - Sym2.card_toFinset_of_not_isDiag (not_isDiag_of_mem_edgeSet _ (mem_edgeFinset.mp he)) +-- lemma card_toFinset_of_mem_edgeFinset (e : Sym2 α) (he : e ∈ G.edgeFinset) : +-- (e : Finset α).card = 2 := +-- Sym2.card_toFinset_of_not_isDiag (not_isDiag_of_mem_edgeSet _ (mem_edgeFinset.mp he)) -lemma card_filter_mem_of_mem_edgeFinset (e : Sym2 α) (he : e ∈ G.edgeFinset) : - Finset.card {v | v ∈ e} = 2 := by - rw [← SimpleGraph.card_toFinset_of_mem_edgeFinset _ he] - congr; ext; simp +-- lemma card_filter_mem_of_mem_edgeFinset (e : Sym2 α) (he : e ∈ G.edgeFinset) : +-- Finset.card {v | v ∈ e} = 2 := by +-- rw [← SimpleGraph.card_toFinset_of_mem_edgeFinset _ he] +-- congr; ext; simp end SimpleGraph diff --git a/FormalBook/Widgets/Windmill.lean b/FormalBook/Widgets/Windmill.lean index a80304d..41acb00 100644 --- a/FormalBook/Widgets/Windmill.lean +++ b/FormalBook/Widgets/Windmill.lean @@ -1,5 +1,4 @@ -import Lean.Util.Paths import LeanSearchClient.Syntax import ProofWidgets.Component.Basic diff --git a/lake-manifest.json b/lake-manifest.json index baad312..8d7afb6 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -1,62 +1,82 @@ {"version": "1.1.0", "packagesDir": ".lake/packages", "packages": - [{"url": "https://github.com/leanprover-community/batteries", + [{"url": "https://github.com/leanprover/doc-gen4", "type": "git", "subDir": null, - "scope": "leanprover-community", - "rev": "485efbc439ee0ebdeae8afb0acd24a5e82e2f771", - "name": "batteries", + "scope": "", + "rev": "3721ccdc8ce7c515cd60d385e5d5a463d6bf0383", + "name": "«doc-gen4»", "manifestFile": "lake-manifest.json", "inputRev": "main", - "inherited": true, - "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/quote4", + "inherited": false, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/PatrickMassot/checkdecls.git", "type": "git", "subDir": null, - "scope": "leanprover-community", - "rev": "303b23fbcea94ac4f96e590c1cad6618fd4f5f41", - "name": "Qq", + "scope": "", + "rev": "3d425859e73fcfbef85b9638c2a91708ef4a22d4", + "name": "checkdecls", "manifestFile": "lake-manifest.json", - "inputRev": "master", - "inherited": true, + "inputRev": null, + "inherited": false, "configFile": "lakefile.lean"}, - {"url": "https://github.com/leanprover-community/aesop", + {"url": "https://github.com/leanprover-community/mathlib4.git", "type": "git", "subDir": null, - "scope": "leanprover-community", - "rev": "de91b59101763419997026c35a41432ac8691f15", - "name": "aesop", + "scope": "", + "rev": "4aa8d324e47fd06e39e5a0985653f79979fd1308", + "name": "mathlib", "manifestFile": "lake-manifest.json", - "inputRev": "master", + "inputRev": null, + "inherited": false, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/mhuisi/lean4-cli", + "type": "git", + "subDir": null, + "scope": "", + "rev": "6667b921594697980586296511fab6a359e802d1", + "name": "Cli", + "manifestFile": "lake-manifest.json", + "inputRev": "main", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/ProofWidgets4", + {"url": "https://github.com/fgdorais/lean4-unicode-basic", "type": "git", "subDir": null, - "scope": "leanprover-community", - "rev": "1383e72b40dd62a566896a6e348ffe868801b172", - "name": "proofwidgets", + "scope": "", + "rev": "d3195374a885cf2b0bfa66063deb493686029f95", + "name": "UnicodeBasic", "manifestFile": "lake-manifest.json", - "inputRev": "v0.0.46", + "inputRev": "main", "inherited": true, "configFile": "lakefile.lean"}, - {"url": "https://github.com/leanprover/lean4-cli", + {"url": "https://github.com/dupuisf/BibtexQuery", "type": "git", "subDir": null, - "scope": "leanprover", - "rev": "726b3c9ad13acca724d4651f14afc4804a7b0e4d", - "name": "Cli", + "scope": "", + "rev": "1b05159ad44f220cec7489e65e6bc4b1e178b67f", + "name": "BibtexQuery", "manifestFile": "lake-manifest.json", - "inputRev": "main", + "inputRev": "dbfe2b7630c5f7c5c1cf71e7747ffc0a30337f69", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/import-graph", + {"url": "https://github.com/acmepjz/md4lean", + "type": "git", + "subDir": null, + "scope": "", + "rev": "feac4e0c356b0928657bf3b54fa83ae952f53257", + "name": "MD4Lean", + "manifestFile": "lake-manifest.json", + "inputRev": "main", + "inherited": true, + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover-community/plausible", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "119b022b3ea88ec810a677888528e50f8144a26e", - "name": "importGraph", + "rev": "240eddc1bb31420fbbc57fe5cc579435c2522493", + "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, @@ -65,81 +85,61 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "86d0d0584f5cd165353e2f8a30c455cd0e168ac2", + "rev": "99657ad92e23804e279f77ea6dbdeebaa1317b98", "name": "LeanSearchClient", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/plausible", + {"url": "https://github.com/leanprover-community/import-graph", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "42dc02bdbc5d0c2f395718462a76c3d87318f7fa", - "name": "plausible", + "rev": "dba7fbc707774d1ba830fd44d7f92a717e9bf57f", + "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover-community/mathlib4.git", - "type": "git", - "subDir": null, - "scope": "", - "rev": "0e836d6e1a3c5ed008688622e261e19fbef05e0e", - "name": "mathlib", - "manifestFile": "lake-manifest.json", - "inputRev": null, - "inherited": false, - "configFile": "lakefile.lean"}, - {"url": "https://github.com/PatrickMassot/checkdecls.git", - "type": "git", - "subDir": null, - "scope": "", - "rev": "11fa569b1b52f987dc5dcea97fd80eaff95c2fce", - "name": "checkdecls", - "manifestFile": "lake-manifest.json", - "inputRev": null, - "inherited": false, - "configFile": "lakefile.lean"}, - {"url": "https://github.com/acmepjz/md4lean", + {"url": "https://github.com/leanprover-community/ProofWidgets4", "type": "git", "subDir": null, - "scope": "", - "rev": "5e95f4776be5e048364f325c7e9d619bb56fb005", - "name": "MD4Lean", + "scope": "leanprover-community", + "rev": "6e47cc88cfbf1601ab364e9a4de5f33f13401ff8", + "name": "proofwidgets", "manifestFile": "lake-manifest.json", - "inputRev": "main", + "inputRev": "v0.0.71", "inherited": true, "configFile": "lakefile.lean"}, - {"url": "https://github.com/fgdorais/lean4-unicode-basic", + {"url": "https://github.com/leanprover-community/aesop", "type": "git", "subDir": null, - "scope": "", - "rev": "2905ab4ec3961d1fd68ddae0ab4083497e579014", - "name": "UnicodeBasic", + "scope": "leanprover-community", + "rev": "3b779e9d1c73837a3764d516d81f942de391b6f0", + "name": "aesop", "manifestFile": "lake-manifest.json", - "inputRev": "main", + "inputRev": "master", "inherited": true, - "configFile": "lakefile.lean"}, - {"url": "https://github.com/dupuisf/BibtexQuery", + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/quote4", "type": "git", "subDir": null, - "scope": "", - "rev": "bdc2fc30b1e834b294759a5d391d83020a90058e", - "name": "BibtexQuery", + "scope": "leanprover-community", + "rev": "f85ad59c9b60647ef736719c23edd4578f723806", + "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", "inherited": true, - "configFile": "lakefile.lean"}, - {"url": "https://github.com/leanprover/doc-gen4", + "configFile": "lakefile.toml"}, + {"url": "https://github.com/leanprover-community/batteries", "type": "git", "subDir": null, - "scope": "", - "rev": "7b6a56e8e4fcf54d3834b225b9814a7c9e4d4bda", - "name": "«doc-gen4»", + "scope": "leanprover-community", + "rev": "76408f09466811154e0e42329962de19f95d178b", + "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", - "inherited": false, - "configFile": "lakefile.lean"}], + "inherited": true, + "configFile": "lakefile.toml"}], "name": "FormalBook", "lakeDir": ".lake"} diff --git a/lean-toolchain b/lean-toolchain index 57a4710..d644667 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.14.0-rc2 +leanprover/lean4:v4.23.0-rc2