Skip to content

Commit 8b47904

Browse files
committed
chore: golf using grind. add grind annotations. (#32738)
1 parent 3e342c9 commit 8b47904

File tree

6 files changed

+11
-36
lines changed

6 files changed

+11
-36
lines changed

Mathlib/Data/Finsupp/Basic.lean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,10 +1110,7 @@ theorem extendDomain_eq_embDomain_subtype (f : Subtype P →₀ M) :
11101110

11111111
theorem support_extendDomain_subset (f : Subtype P →₀ M) :
11121112
↑(f.extendDomain).support ⊆ {x | P x} := by
1113-
intro x
1114-
rw [extendDomain_support, mem_coe, mem_map, Embedding.coe_subtype]
1115-
rintro ⟨x, -, rfl⟩
1116-
exact x.prop
1113+
grind
11171114

11181115
@[simp]
11191116
theorem subtypeDomain_extendDomain (f : Subtype P →₀ M) :

Mathlib/Data/Nat/PrimeFin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def primeFactors (n : ℕ) : Finset ℕ := n.primeFactorsList.toFinset
3636

3737
@[simp] lemma toFinset_factors (n : ℕ) : n.primeFactorsList.toFinset = n.primeFactors := rfl
3838

39-
@[simp] lemma mem_primeFactors : p ∈ n.primeFactors ↔ p.Prime ∧ p ∣ n ∧ n ≠ 0 := by
39+
@[simp, grind =] lemma mem_primeFactors : p ∈ n.primeFactors ↔ p.Prime ∧ p ∣ n ∧ n ≠ 0 := by
4040
simp_rw [← toFinset_factors, List.mem_toFinset, mem_primeFactorsList']
4141

4242
lemma mem_primeFactors_of_ne_zero (hn : n ≠ 0) : p ∈ n.primeFactors ↔ p.Prime ∧ p ∣ n := by

Mathlib/Data/Seq/Basic.lean

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ theorem take_succ_cons {n : ℕ} {x : α} {s : Seq α} :
157157
(cons x s).take (n + 1) = x :: s.take n := by
158158
rfl
159159

160-
@[simp]
160+
@[simp, grind =]
161161
theorem getElem?_take : ∀ (n k : ℕ) (s : Seq α),
162162
(s.take k)[n]? = if n < k then s.get? n else none
163163
| n, 0, s => by simp [take]
@@ -488,7 +488,7 @@ end Join
488488

489489
section Drop
490490

491-
@[simp]
491+
@[simp, grind =]
492492
theorem drop_get? {n m : ℕ} {s : Seq α} : (s.drop n).get? m = s.get? (n + m) := by
493493
induction n generalizing m with
494494
| zero => simp [drop]
@@ -541,18 +541,8 @@ theorem drop_length' {n : ℕ} {s : Seq α} :
541541

542542
theorem take_drop {s : Seq α} {n m : ℕ} :
543543
(s.take n).drop m = (s.drop m).take (n - m) := by
544-
induction m generalizing n s with
545-
| zero => simp [drop]
546-
| succ k ih =>
547-
cases s
548-
· simp
549-
cases n with
550-
| zero => simp
551-
| succ l =>
552-
simp only [take, destruct_cons, List.drop_succ_cons, Nat.reduceSubDiff]
553-
rw [ih]
554-
congr 1
555-
rw [drop_succ_cons]
544+
ext
545+
grind
556546

557547
end Drop
558548

Mathlib/LinearAlgebra/Lagrange.lean

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,17 +452,7 @@ theorem interpolate_eq_add_interpolate_erase (hvs : Set.InjOn v s) (hi : i ∈ s
452452
open scoped Classical in
453453
theorem interpolate_poly_eq_self
454454
(hvs : Set.InjOn v s) {P : Polynomial F} (hP : P.degree < s.card) :
455-
interpolate s v (fun i => P.eval (v i)) = P := by
456-
classical
457-
let t : Finset F := s.image v
458-
have ht : t.card = s.card := Finset.card_image_iff.mpr hvs
459-
apply eq_of_degrees_lt_of_eval_finset_eq t
460-
· rw [ht]
461-
apply degree_interpolate_lt _ hvs
462-
· rwa [ht]
463-
· intro x hx
464-
obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hx
465-
rw [eval_interpolate_at_node _ hvs hi]
455+
interpolate s v (fun i => P.eval (v i)) = P := (eq_interpolate hvs hP).symm
466456

467457
theorem leadingCoeff_eq_sum
468458
(hvs : Set.InjOn v s) {P : Polynomial F} (hP : s.card = P.degree + 1) :

Mathlib/NumberTheory/Divisors.lean

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ theorem cons_self_properDivisors (h : n ≠ 0) :
106106
cons n (properDivisors n) self_notMem_properDivisors = divisors n := by
107107
rw [cons_eq_insert, insert_self_properDivisors h]
108108

109-
@[simp]
109+
@[simp, grind =]
110110
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 := by
111111
rcases eq_or_ne m 0 with (rfl | hm); · simp [divisors]
112112
simp only [hm, Ne, not_false_iff, and_true, ← filter_dvd_eq_divisors hm, mem_filter,
@@ -554,10 +554,8 @@ theorem prod_divisorsAntidiagonal' {M : Type*} [CommMonoid M] (f : ℕ → ℕ
554554
/-- The factors of `n` are the prime divisors -/
555555
theorem primeFactors_eq_to_filter_divisors_prime (n : ℕ) :
556556
n.primeFactors = {p ∈ divisors n | p.Prime} := by
557-
rcases n.eq_zero_or_pos with (rfl | hn)
558-
· simp
559-
· ext q
560-
simpa [hn, hn.ne', mem_primeFactorsList] using and_comm
557+
ext
558+
grind
561559

562560
lemma primeFactors_filter_dvd_of_dvd {m n : ℕ} (hn : n ≠ 0) (hmn : m ∣ n) :
563561
{p ∈ n.primeFactors | p ∣ m} = m.primeFactors := by

Mathlib/NumberTheory/SumTwoSquares.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ theorem Nat.eq_sq_add_sq_iff {n : ℕ} :
225225
-- now `0 < n`
226226
refine eq_sq_add_sq_iff_eq_sq_mul.trans ⟨fun ⟨a, b, h₁, h₂⟩ q hq h ↦ ?_, fun H ↦ ?_⟩
227227
· have : Fact q.Prime := ⟨prime_of_mem_primeFactors hq⟩
228-
have : q ∣ b → q ∈ b.primeFactors := by grind [mem_primeFactors]
228+
have : q ∣ b → q ∈ b.primeFactors := by grind
229229
grind (splits := 10) [padicValNat.mul, padicValNat.pow,
230230
padicValNat.eq_zero_of_not_dvd, mod_four_ne_three_of_mem_primeFactors_of_isSquare_neg_one]
231231
· obtain ⟨b, a, hb₀, ha₀, hab, hb⟩ := sq_mul_squarefree_of_pos hn₀

0 commit comments

Comments
 (0)