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

Commit 7545909

Browse files
committed
chore(logic/function): allow Sort* in function.inv_fun (#10526)
1 parent 3ac9ae7 commit 7545909

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/logic/function/basic.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ is_partial_inv_left (partial_inv_of_injective I)
282282

283283
end
284284

285-
section inv_fun
285+
section inv_fun_on
286286
variables {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {a : α} {b : β}
287287
include n
288288
local attribute [instance, priority 10] classical.prop_decidable
@@ -307,15 +307,23 @@ h _ (inv_fun_on_mem this) _ ha (inv_fun_on_eq this)
307307
theorem inv_fun_on_neg (h : ¬ ∃a∈s, f a = b) : inv_fun_on f s b = classical.choice n :=
308308
by rw [bex_def] at h; rw [inv_fun_on, dif_neg h]
309309

310+
end inv_fun_on
311+
312+
section inv_fun
313+
314+
variables {α β : Sort*} [nonempty α] {f : α → β} {a : α} {b : β}
315+
local attribute [instance, priority 10] classical.prop_decidable
316+
310317
/-- The inverse of a function (which is a left inverse if `f` is injective
311318
and a right inverse if `f` is surjective). -/
312-
noncomputable def inv_fun (f : α → β) : β → α := inv_fun_on f set.univ
319+
noncomputable def inv_fun (f : α → β) : β → α :=
320+
λ y, if h : ∃ x, f x = y then h.some else classical.arbitrary α
313321

314-
theorem inv_fun_eq (h : ∃a, f a = b) : f (inv_fun f b) = b :=
315-
inv_fun_on_eq $ let ⟨a, ha⟩ := h in ⟨a, trivial, ha⟩
322+
theorem inv_fun_eq (h : ∃ a, f a = b) : f (inv_fun f b) = b :=
323+
by simp only [inv_fun, dif_pos h, h.some_spec]
316324

317-
lemma inv_fun_neg (h : ¬ ∃ a, f a = b) : inv_fun f b = classical.choice n :=
318-
by refine inv_fun_on_neg (mt _ h); exact assume ⟨a, _, ha⟩, ⟨a, ha⟩
325+
lemma inv_fun_neg (h : ¬ ∃ a, f a = b) : inv_fun f b = classical.choice ‹_› :=
326+
dif_neg h
319327

320328
theorem inv_fun_eq_of_injective_of_right_inverse {g : β → α}
321329
(hf : injective f) (hg : right_inverse g f) : inv_fun f = g :=
@@ -326,21 +334,13 @@ lemma right_inverse_inv_fun (hf : surjective f) : right_inverse (inv_fun f) f :=
326334
assume b, inv_fun_eq $ hf b
327335

328336
lemma left_inverse_inv_fun (hf : injective f) : left_inverse (inv_fun f) f :=
329-
assume b,
330-
have f (inv_fun f (f b)) = f b,
331-
from inv_fun_eq ⟨b, rfl⟩,
332-
hf this
337+
λ b, hf $ inv_fun_eq ⟨b, rfl⟩
333338

334339
lemma inv_fun_surjective (hf : injective f) : surjective (inv_fun f) :=
335340
(left_inverse_inv_fun hf).surjective
336341

337342
lemma inv_fun_comp (hf : injective f) : inv_fun f ∘ f = id := funext $ left_inverse_inv_fun hf
338343

339-
end inv_fun
340-
341-
section inv_fun
342-
variables {α : Type u} [nonempty α] {β : Sort v} {f : α → β}
343-
344344
lemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=
345345
⟨inv_fun f, left_inverse_inv_fun hf⟩
346346

0 commit comments

Comments
 (0)