@@ -282,7 +282,7 @@ is_partial_inv_left (partial_inv_of_injective I)
282
282
283
283
end
284
284
285
- section inv_fun
285
+ section inv_fun_on
286
286
variables {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {a : α} {b : β}
287
287
include n
288
288
local attribute [instance, priority 10 ] classical.prop_decidable
@@ -307,15 +307,23 @@ h _ (inv_fun_on_mem this) _ ha (inv_fun_on_eq this)
307
307
theorem inv_fun_on_neg (h : ¬ ∃a∈s, f a = b) : inv_fun_on f s b = classical.choice n :=
308
308
by rw [bex_def] at h; rw [inv_fun_on, dif_neg h]
309
309
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
+
310
317
/-- The inverse of a function (which is a left inverse if `f` is injective
311
318
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 α
313
321
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]
316
324
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
319
327
320
328
theorem inv_fun_eq_of_injective_of_right_inverse {g : β → α}
321
329
(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 :=
326
334
assume b, inv_fun_eq $ hf b
327
335
328
336
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⟩
333
338
334
339
lemma inv_fun_surjective (hf : injective f) : surjective (inv_fun f) :=
335
340
(left_inverse_inv_fun hf).surjective
336
341
337
342
lemma inv_fun_comp (hf : injective f) : inv_fun f ∘ f = id := funext $ left_inverse_inv_fun hf
338
343
339
- end inv_fun
340
-
341
- section inv_fun
342
- variables {α : Type u} [nonempty α] {β : Sort v} {f : α → β}
343
-
344
344
lemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=
345
345
⟨inv_fun f, left_inverse_inv_fun hf⟩
346
346
0 commit comments