Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 17a9f8f

Browse files
committed
chore(*): golf (#17558)
Golfing part of #17553
1 parent 7cca171 commit 17a9f8f

File tree

4 files changed

+15
-49
lines changed

4 files changed

+15
-49
lines changed

src/data/finsupp/fin.lean

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,20 @@ variables {n : ℕ} (i : fin n) {M : Type*} [has_zero M] (y : M)
2727

2828
/-- `tail` for maps `fin (n + 1) →₀ M`. See `fin.tail` for more details. -/
2929
def tail (s : fin (n + 1) →₀ M) : fin n →₀ M :=
30-
finsupp.equiv_fun_on_fintype.inv_fun (fin.tail s.to_fun)
30+
finsupp.equiv_fun_on_fintype.symm (fin.tail s)
3131

3232
/-- `cons` for maps `fin n →₀ M`. See `fin.cons` for more details. -/
3333
def cons (y : M) (s : fin n →₀ M) : fin (n + 1) →₀ M :=
34-
finsupp.equiv_fun_on_fintype.inv_fun (fin.cons y s.to_fun)
34+
finsupp.equiv_fun_on_fintype.symm (fin.cons y s : fin (n + 1) → M)
3535

36-
lemma tail_apply : tail t i = t i.succ :=
37-
begin
38-
simp only [tail, equiv_fun_on_fintype_symm_apply_to_fun, equiv.inv_fun_as_coe],
39-
refl,
40-
end
36+
lemma tail_apply : tail t i = t i.succ := rfl
4137

42-
@[simp] lemma cons_zero : cons y s 0 = y :=
43-
by simp [cons, finsupp.equiv_fun_on_fintype]
38+
@[simp] lemma cons_zero : cons y s 0 = y := rfl
4439

45-
@[simp] lemma cons_succ : cons y s i.succ = s i :=
46-
begin
47-
simp only [finsupp.cons, fin.cons, finsupp.equiv_fun_on_fintype, fin.cases_succ, finsupp.coe_mk],
48-
refl,
49-
end
40+
@[simp] lemma cons_succ : cons y s i.succ = s i := fin.cons_succ _ _ _
5041

5142
@[simp] lemma tail_cons : tail (cons y s) = s :=
52-
begin
53-
simp only [finsupp.cons, fin.cons, finsupp.tail, fin.tail],
54-
ext,
55-
simp only [equiv_fun_on_fintype_symm_apply_to_fun, equiv.inv_fun_as_coe,
56-
finsupp.coe_mk, fin.cases_succ, equiv_fun_on_fintype],
57-
refl,
58-
end
43+
ext $ λ k, by simp only [tail_apply, cons_succ]
5944

6045
@[simp] lemma cons_tail : cons (t 0) (tail t) = t :=
6146
begin

src/linear_algebra/basic.lean

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,11 @@ variables (R M) [add_comm_monoid M] [semiring R] [module R M]
9999

100100
@[simp] lemma linear_equiv_fun_on_fintype_single [decidable_eq α] (x : α) (m : M) :
101101
(linear_equiv_fun_on_fintype R M α) (single x m) = pi.single x m :=
102-
begin
103-
ext a,
104-
change (equiv_fun_on_fintype (single x m)) a = _,
105-
convert _root_.congr_fun (equiv_fun_on_fintype_single x m) a,
106-
end
102+
equiv_fun_on_fintype_single x m
107103

108104
@[simp] lemma linear_equiv_fun_on_fintype_symm_single [decidable_eq α]
109105
(x : α) (m : M) : (linear_equiv_fun_on_fintype R M α).symm (pi.single x m) = single x m :=
110-
begin
111-
ext a,
112-
change (equiv_fun_on_fintype.symm (pi.single x m)) a = _,
113-
convert congr_fun (equiv_fun_on_fintype_symm_single x m) a,
114-
end
106+
equiv_fun_on_fintype_symm_single x m
115107

116108
@[simp] lemma linear_equiv_fun_on_fintype_symm_coe (f : α →₀ M) :
117109
(linear_equiv_fun_on_fintype R M α).symm f = f :=

src/order/well_founded_set.lean

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,22 +689,18 @@ partially well ordered, and also to consider the case of `set.partially_well_ord
689689
lemma pi.is_pwo {α : ι → Type*} [Π i, linear_order (α i)] [∀ i, is_well_order (α i) (<)] [finite ι]
690690
(s : set (Π i, α i)) : s.is_pwo :=
691691
begin
692-
classical,
693692
casesI nonempty_fintype ι,
694-
refine is_pwo.mono _ (subset_univ _),
695-
rw is_pwo_iff_exists_monotone_subseq,
696-
simp only [mem_univ, forall_const, function.comp_app],
697693
suffices : ∀ s : finset ι, ∀ (f : ℕ → Π s, α s), ∃ g : ℕ ↪o ℕ,
698694
∀ ⦃a b : ℕ⦄, a ≤ b → ∀ (x : ι) (hs : x ∈ s), (f ∘ g) a x ≤ (f ∘ g) b x,
699-
{ simpa only [forall_true_left, finset.mem_univ] using this finset.univ },
700-
apply' finset.induction,
695+
{ refine is_pwo_iff_exists_monotone_subseq.2 (λ f hf, _),
696+
simpa only [finset.mem_univ, true_implies_iff] using this finset.univ f },
697+
refine finset.cons_induction _ _,
701698
{ intros f, existsi rel_embedding.refl (≤),
702699
simp only [is_empty.forall_iff, implies_true_iff, forall_const, finset.not_mem_empty], },
703700
{ intros x s hx ih f,
704701
obtain ⟨g, hg⟩ := (is_well_founded.wf.is_wf univ).is_pwo.exists_monotone_subseq (λ n, f n x)
705702
mem_univ,
706703
obtain ⟨g', hg'⟩ := ih (f ∘ g),
707-
refine ⟨g'.trans g, λ a b hab, _⟩,
708-
simp only [finset.mem_insert, rel_embedding.coe_trans, function.comp_app, forall_eq_or_imp],
704+
refine ⟨g'.trans g, λ a b hab, (finset.forall_mem_cons _ _).2 _⟩,
709705
exact ⟨hg (order_hom_class.mono g' hab), hg' hab⟩ }
710706
end

src/set_theory/cardinal/basic.lean

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -893,21 +893,14 @@ lemma mk_finsupp_of_fintype (α β : Type u) [fintype α] [has_zero β] :
893893
by simp
894894

895895
theorem card_le_of_finset {α} (s : finset α) : (s.card : cardinal) ≤ #α :=
896-
begin
897-
rw (_ : (s.card : cardinal) = #s),
898-
{ exact ⟨function.embedding.subtype _⟩ },
899-
rw [cardinal.mk_fintype, fintype.card_coe]
900-
end
896+
@mk_coe_finset _ s ▸ mk_set_le _
901897

902898
@[norm_cast] theorem nat_cast_pow {m n : ℕ} : (↑(pow m n) : cardinal) = m ^ n :=
903899
by simp only [cardinal.pow_cast_right, coe_pow]
904900

905901
@[simp, norm_cast] theorem nat_cast_le {m n : ℕ} : (m : cardinal) ≤ n ↔ m ≤ n :=
906-
begin
907-
rw [←lift_mk_fin, ←lift_mk_fin, lift_le],
908-
exact ⟨λ ⟨⟨f, hf⟩⟩, by simpa only [fintype.card_fin] using fintype.card_le_of_injective f hf,
909-
λ h, ⟨(fin.cast_le h).to_embedding⟩⟩
910-
end
902+
by rw [← lift_mk_fin, ← lift_mk_fin, lift_le, le_def, function.embedding.nonempty_iff_card_le,
903+
fintype.card_fin, fintype.card_fin]
911904

912905
@[simp, norm_cast] theorem nat_cast_lt {m n : ℕ} : (m : cardinal) < n ↔ m < n :=
913906
by simp [lt_iff_le_not_le, ←not_le]

0 commit comments

Comments
 (0)