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

Commit cdb69d5

Browse files
committed
fix(data/set/function): do not use reducible (#12377)
Reducible should only be used if the definition if it occurs as an explicit argument in a type class and must reduce during type class search, or if it is a type that should inherit instances. Propositions should only be reducible if they are trivial variants (`<` and `>` for example). These reducible attributes here will cause issues in Lean 4. In Lean 4, the simplifier unfold reducible definitions in simp lemmas. This means that tagging an `inj_on`-theorem with `@[simp]` creates the simp lemma `?a = ?b` (i.e. match anything).
1 parent 363b7cd commit cdb69d5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/data/set/function.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ end order
205205
/-! ### maps to -/
206206

207207
/-- `maps_to f a b` means that the image of `a` is contained in `b`. -/
208-
@[reducible] def maps_to (f : α → β) (s : set α) (t : set β) : Prop := ∀ ⦃x⦄, x ∈ s → f x ∈ t
208+
def maps_to (f : α → β) (s : set α) (t : set β) : Prop := ∀ ⦃x⦄, x ∈ s → f x ∈ t
209209

210210
/-- Given a map `f` sending `s : set α` into `t : set β`, restrict domain of `f` to `s`
211211
and the codomain to `t`. Same as `subtype.map`. -/
@@ -325,7 +325,7 @@ theorem maps_to.mem_iff (h : maps_to f s t) (hc : maps_to f sᶜ tᶜ) {x} : f x
325325
/-! ### Injectivity on a set -/
326326

327327
/-- `f` is injective on `a` if the restriction of `f` to `a` is injective. -/
328-
@[reducible] def inj_on (f : α → β) (s : set α) : Prop :=
328+
def inj_on (f : α → β) (s : set α) : Prop :=
329329
∀ ⦃x₁ : α⦄, x₁ ∈ s → ∀ ⦃x₂ : α⦄, x₂ ∈ s → f x₁ = f x₂ → x₁ = x₂
330330

331331
theorem subsingleton.inj_on (hs : s.subsingleton) (f : α → β) : inj_on f s :=
@@ -414,7 +414,7 @@ lemma inj_on.cancel_left (hg : t.inj_on g) (hf₁ : s.maps_to f₁ t) (hf₂ : s
414414
/-! ### Surjectivity on a set -/
415415

416416
/-- `f` is surjective from `a` to `b` if `b` is contained in the image of `a`. -/
417-
@[reducible] def surj_on (f : α → β) (s : set α) (t : set β) : Prop := t ⊆ f '' s
417+
def surj_on (f : α → β) (s : set α) (t : set β) : Prop := t ⊆ f '' s
418418

419419
theorem surj_on.subset_range (h : surj_on f s t) : t ⊆ range f :=
420420
subset.trans h $ image_subset_range f s
@@ -508,7 +508,7 @@ lemma eq_on_comp_right_iff : s.eq_on (g₁ ∘ f) (g₂ ∘ f) ↔ (f '' s).eq_o
508508
/-! ### Bijectivity -/
509509

510510
/-- `f` is bijective from `s` to `t` if `f` is injective on `s` and `f '' s = t`. -/
511-
@[reducible] def bij_on (f : α → β) (s : set α) (t : set β) : Prop :=
511+
def bij_on (f : α → β) (s : set α) (t : set β) : Prop :=
512512
maps_to f s t ∧ inj_on f s ∧ surj_on f s t
513513

514514
lemma bij_on.maps_to (h : bij_on f s t) : maps_to f s t := h.left
@@ -572,7 +572,7 @@ lemma bij_on.compl (hst : bij_on f s t) (hf : bijective f) : bij_on f sᶜ tᶜ
572572
/-! ### left inverse -/
573573

574574
/-- `g` is a left inverse to `f` on `a` means that `g (f x) = x` for all `x ∈ a`. -/
575-
@[reducible] def left_inv_on (f' : β → α) (f : α → β) (s : set α) : Prop :=
575+
def left_inv_on (f' : β → α) (f : α → β) (s : set α) : Prop :=
576576
∀ ⦃x⦄, x ∈ s → f' (f x) = x
577577

578578
lemma left_inv_on.eq_on (h : left_inv_on f' f s) : eq_on (f' ∘ f) id s := h
@@ -688,7 +688,7 @@ theorem surj_on.left_inv_on_of_right_inv_on (hf : surj_on f s t) (hf' : right_in
688688
/-! ### Two-side inverses -/
689689

690690
/-- `g` is an inverse to `f` viewed as a map from `a` to `b` -/
691-
@[reducible] def inv_on (g : β → α) (f : α → β) (s : set α) (t : set β) : Prop :=
691+
def inv_on (g : β → α) (f : α → β) (s : set α) (t : set β) : Prop :=
692692
left_inv_on g f s ∧ right_inv_on g f t
693693

694694
lemma inv_on.symm (h : inv_on f' f s t) : inv_on f f' t s := ⟨h.right, h.left⟩

src/logic/function/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ end involutive
677677
/-- The property of a binary function `f : α → β → γ` being injective.
678678
Mathematically this should be thought of as the corresponding function `α × β → γ` being injective.
679679
-/
680-
@[reducible] def injective2 {α β γ} (f : α → β → γ) : Prop :=
680+
def injective2 {α β γ} (f : α → β → γ) : Prop :=
681681
∀ ⦃a₁ a₂ b₁ b₂⦄, f a₁ b₁ = f a₂ b₂ → a₁ = a₂ ∧ b₁ = b₂
682682

683683
namespace injective2

0 commit comments

Comments
 (0)