Skip to content

Commit 0f086d1

Browse files
committed
chore(Data/Nat/Periodic): golf (#30970)
1 parent 112dbac commit 0f086d1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Mathlib/Data/Nat/Periodic.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ namespace Nat
1919

2020
open Function
2121

22-
theorem periodic_gcd (a : ℕ) : Periodic (gcd a) a := by
23-
simp only [forall_const, gcd_add_self_right, Periodic]
22+
theorem periodic_gcd (a : ℕ) : Periodic (gcd a) a :=
23+
a.gcd_add_self_right
2424

25-
theorem periodic_coprime (a : ℕ) : Periodic (Coprime a) a := by
26-
simp only [coprime_add_self_right, forall_const, Periodic]
25+
theorem periodic_coprime (a : ℕ) : Periodic (Coprime a) a :=
26+
fun _ ↦ eq_iff_iff.mpr coprime_add_self_right
2727

28-
theorem periodic_mod (a : ℕ) : Periodic (fun n => n % a) a := by
29-
simp only [forall_const, add_mod_right, Periodic]
28+
theorem periodic_mod (a : ℕ) : Periodic (fun n => n % a) a :=
29+
(add_mod_right · a)
3030

3131
theorem _root_.Function.Periodic.map_mod_nat {α : Type*} {f : ℕ → α} {a : ℕ} (hf : Periodic f a) :
3232
∀ n, f (n % a) = f n := fun n => by
33-
conv_rhs => rw [← Nat.mod_add_div n a, mul_comm, ← Nat.nsmul_eq_mul, hf.nsmul]
33+
conv_rhs => rw [← n.mod_add_div a, mul_comm, ← Nat.nsmul_eq_mul, hf.nsmul]
3434

3535
section Multiset
3636

@@ -44,7 +44,7 @@ theorem filter_multiset_Ico_card_eq_of_periodic (n a : ℕ) (p : ℕ → Prop) [
4444
multiset_Ico_map_mod n, ← map_count_True_eq_filter_card, ← map_count_True_eq_filter_card,
4545
map_map]
4646
congr; funext n
47-
exact (Function.Periodic.map_mod_nat pp n).symm
47+
exact (pp.map_mod_nat n).symm
4848

4949
end Multiset
5050

@@ -56,7 +56,7 @@ open Finset
5656
equal to the number naturals below `a` for which `p a` is true. -/
5757
theorem filter_Ico_card_eq_of_periodic (n a : ℕ) (p : ℕ → Prop) [DecidablePred p]
5858
(pp : Periodic p a) : ((Ico n (n + a)).filter p).card = a.count p :=
59-
filter_multiset_Ico_card_eq_of_periodic n a p pp
59+
n.filter_multiset_Ico_card_eq_of_periodic a p pp
6060

6161
end Finset
6262

0 commit comments

Comments
 (0)