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

Commit db1c500

Browse files
urkudmergify[bot]
andauthored
refactor(data/set/function): use dot notation (#1934)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 0372fb0 commit db1c500

File tree

11 files changed

+321
-266
lines changed

11 files changed

+321
-266
lines changed

src/data/equiv/local_equiv.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected def symm : local_equiv β α :=
120120

121121
/-- A local equiv induces a bijection between its source and target -/
122122
lemma bij_on_source : bij_on e.to_fun e.source e.target :=
123-
bij_on_of_inv_on e.map_source e.map_target ⟨e.left_inv, e.right_inv⟩
123+
inv_on.bij_on ⟨e.left_inv, e.right_inv⟩ e.map_source e.map_target
124124

125125
lemma image_eq_target_inter_inv_preimage {s : set α} (h : s ⊆ e.source) :
126126
e.to_fun '' s = e.target ∩ e.inv_fun ⁻¹' s :=
@@ -156,13 +156,13 @@ lemma target_inter_inv_preimage_preimage (s : set β) :
156156
e.symm.source_inter_preimage_inv_preimage _
157157

158158
lemma image_source_eq_target : e.to_fun '' e.source = e.target :=
159-
image_eq_of_bij_on e.bij_on_source
159+
e.bij_on_source.image_eq
160160

161161
lemma source_subset_preimage_target : e.source ⊆ e.to_fun ⁻¹' e.target :=
162162
λx hx, e.map_source hx
163163

164164
lemma inv_image_target_eq_source : e.inv_fun '' e.target = e.source :=
165-
image_eq_of_bij_on e.symm.bij_on_source
165+
e.symm.bij_on_source.image_eq
166166

167167
lemma target_subset_preimage_source : e.target ⊆ e.inv_fun ⁻¹' e.source :=
168168
λx hx, e.map_target hx
@@ -367,9 +367,9 @@ lemma eq_on_source_refl : e ≈ e := setoid.refl _
367367
lemma eq_on_source_symm {e e' : local_equiv α β} (h : e ≈ e') : e.symm ≈ e'.symm :=
368368
begin
369369
have T : e.target = e'.target,
370-
{ have : set.bij_on e'.to_fun e.source e.target := bij_on_of_eq_on h.2 e.bij_on_source,
371-
have A : e'.to_fun '' e.source = e.target := image_eq_of_bij_on this,
372-
rw [h.1, image_eq_of_bij_on e'.bij_on_source] at A,
370+
{ have : set.bij_on e'.to_fun e.source e.target := e.bij_on_source.congr h.2,
371+
have A : e'.to_fun '' e.source = e.target := this.image_eq,
372+
rw [h.1, e'.bij_on_source.image_eq] at A,
373373
exact A.symm },
374374
refine ⟨T, λx hx, _⟩,
375375
have xt : x ∈ e.target := hx,
@@ -378,7 +378,7 @@ begin
378378
have A : e.to_fun (e.inv_fun x) = x := e.right_inv hx,
379379
have B : e.to_fun (e'.inv_fun x) = x,
380380
by { rw h.2, exact e'.right_inv xt, exact e's },
381-
apply inj_on_of_bij_on e.bij_on_source (e.map_target hx) e's,
381+
apply e.bij_on_source.inj_on (e.map_target hx) e's,
382382
rw [A, B]
383383
end
384384

@@ -407,7 +407,7 @@ begin
407407
split,
408408
{ have : e.target = e'.target := (eq_on_source_symm he).1,
409409
rw [trans_source'', trans_source'', ← this, ← hf.1],
410-
exact image_eq_image_of_eq_on (λx hx, (eq_on_source_symm he).2 x hx.1) },
410+
exact eq_on.image_eq (λx hx, (eq_on_source_symm he).2 x hx.1) },
411411
{ assume x hx,
412412
rw trans_source at hx,
413413
simp [(he.2 x hx.1).symm, hf.2 _ hx.2] }

src/data/finsupp.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ end
793793

794794
lemma sum_comap_domain {α₁ α₂ β γ : Type*} [has_zero β] [add_comm_monoid γ]
795795
(f : α₁ → α₂) (l : α₂ →₀ β) (g : α₂ → β → γ) (hf : set.bij_on f (f ⁻¹' l.support.to_set) l.support.to_set):
796-
(comap_domain f l (set.inj_on_of_bij_on hf)).sum (g ∘ f) = l.sum g :=
796+
(comap_domain f l hf.inj_on).sum (g ∘ f) = l.sum g :=
797797
begin
798798
unfold sum,
799799
haveI := classical.dec_eq α₂,
@@ -802,7 +802,7 @@ end
802802

803803
lemma eq_zero_of_comap_domain_eq_zero {α₁ α₂ γ : Type*} [add_comm_monoid γ]
804804
(f : α₁ → α₂) (l : α₂ →₀ γ) (hf : set.bij_on f (f ⁻¹' l.support.to_set) l.support.to_set) :
805-
comap_domain f l (set.inj_on_of_bij_on hf) = 0 → l = 0 :=
805+
comap_domain f l hf.inj_on = 0 → l = 0 :=
806806
begin
807807
rw [← support_eq_empty, ← support_eq_empty, comap_domain],
808808
simp only [finset.ext, finset.not_mem_empty, iff_false, mem_preimage],
@@ -814,7 +814,7 @@ end
814814
lemma map_domain_comap_domain {α₁ α₂ γ : Type*} [add_comm_monoid γ]
815815
(f : α₁ → α₂) (l : α₂ →₀ γ)
816816
(hf : function.injective f) (hl : ↑l.support ⊆ set.range f):
817-
map_domain f (comap_domain f l (set.inj_on_of_injective _ hf)) = l :=
817+
map_domain f (comap_domain f l (hf.inj_on _)) = l :=
818818
begin
819819
ext a,
820820
haveI := classical.dec (a ∈ set.range f),

src/data/set/basic.lean

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,6 @@ section image
885885

886886
infix ` '' `:80 := image
887887

888-
/-- Two functions `f₁ f₂ : α → β` are equal on `s`
889-
if `f₁ x = f₂ x` for all `x ∈ a`. -/
890-
@[reducible] def eq_on (f1 f2 : α → β) (a : set α) : Prop :=
891-
∀ x ∈ a, f1 x = f2 x
892-
893888
-- TODO(Jeremy): use bounded exists in image
894889

895890
theorem mem_image_iff_bex {f : α → β} {s : set α} {y : β} :
@@ -937,10 +932,6 @@ by safe [ext_iff, iff_def]
937932
lemma image_congr' {f g : α → β} {s : set α} (h : ∀ (x : α), f x = g x) : f '' s = g '' s :=
938933
image_congr (λx _, h x)
939934

940-
theorem image_eq_image_of_eq_on {f₁ f₂ : α → β} {s : set α} (heq : eq_on f₁ f₂ s) :
941-
f₁ '' s = f₂ '' s :=
942-
image_congr heq
943-
944935
theorem image_comp (f : β → γ) (g : α → β) (a : set α) : (f ∘ g) '' a = f '' (g '' a) :=
945936
subset.antisymm
946937
(ball_image_of_ball $ assume a ha, mem_image_of_mem _ $ mem_image_of_mem _ ha)

src/data/set/countable.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ by rw ← image_univ; exact countable_image _ (countable_encodable _)
109109
lemma countable_of_injective_of_countable_image {s : set α} {f : α → β}
110110
(hf : inj_on f s) (hs : countable (f '' s)) : countable s :=
111111
let ⟨g, hg⟩ := countable_iff_exists_inj_on.1 hs in
112-
countable_iff_exists_inj_on.2 ⟨g ∘ f, inj_on_comp (maps_to_image _ _) hg hf
112+
countable_iff_exists_inj_on.2 ⟨g ∘ f, hg.comp hf (maps_to_image _ _)⟩
113113

114114
lemma countable_Union {t : α → set β} [encodable α] (ht : ∀a, countable (t a)) :
115115
countable (⋃a, t a) :=

src/data/set/finite.lean

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ by simp [set.ext_iff]
507507

508508
lemma image_preimage [decidable_eq β] (f : α → β) (s : finset β)
509509
(hf : set.bij_on f (f ⁻¹' s.to_set) s.to_set) :
510-
image f (preimage s (set.inj_on_of_bij_on hf)) = s :=
510+
image f (preimage s hf.inj_on) = s :=
511511
finset.coe_inj.1 $
512512
suffices f '' (f ⁻¹' ↑s) = ↑s, by simpa,
513513
(set.subset.antisymm (image_preimage_subset _ _) hf.2.2)
@@ -517,33 +517,27 @@ end preimage
517517
@[to_additive]
518518
lemma prod_preimage [comm_monoid β] (f : α → γ) (s : finset γ)
519519
(hf : set.bij_on f (f ⁻¹' ↑s) ↑s) (g : γ → β) :
520-
(preimage s (set.inj_on_of_bij_on hf)).prod (g ∘ f) = s.prod g :=
520+
(preimage s hf.inj_on).prod (g ∘ f) = s.prod g :=
521521
by classical;
522522
calc
523-
(preimage s (set.inj_on_of_bij_on hf)).prod (g ∘ f)
524-
= (image f (preimage s (set.inj_on_of_bij_on hf))).prod g :
523+
(preimage s hf.inj_on).prod (g ∘ f)
524+
= (image f (preimage s hf.inj_on)).prod g :
525525
begin
526526
rw prod_image,
527527
intros x hx y hy hxy,
528-
apply set.inj_on_of_bij_on hf,
528+
apply hf.inj_on,
529529
repeat { try { rw mem_preimage at hx hy,
530530
rw [set.mem_preimage, mem_coe] },
531531
assumption },
532532
end
533-
... = s.prod g : by rw image_preimage
533+
... = s.prod g : by rw [image_preimage]
534534

535535
end finset
536536

537537
lemma fintype.exists_max [fintype α] [nonempty α]
538-
{β : Type*} [decidable_linear_order β] (f : α → β) :
538+
{β : Type*} [linear_order β] (f : α → β) :
539539
∃ x₀ : α, ∀ x, f x ≤ f x₀ :=
540540
begin
541-
obtain ⟨y, hy⟩ : ∃ y, y ∈ (set.range f).to_finset,
542-
{ haveI := classical.inhabited_of_nonempty ‹nonempty α›,
543-
exact ⟨f (default α), set.mem_to_finset.mpr $ set.mem_range_self _⟩ },
544-
rcases finset.max_of_mem hy with ⟨y₀, h⟩,
545-
rcases set.mem_to_finset.1 (finset.mem_of_max h) with ⟨x₀, rfl⟩,
546-
use x₀,
547-
intro x,
548-
apply finset.le_max_of_mem (set.mem_to_finset.mpr $ set.mem_range_self x) h
541+
rcases set.finite_univ.exists_maximal_wrt f _ univ_nonempty with ⟨x, _, hx⟩,
542+
exact ⟨x, λ y, (le_total (f x) (f y)).elim (λ h, ge_of_eq $ hx _ trivial h) id⟩
549543
end

0 commit comments

Comments
 (0)