forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic.lean
More file actions
77 lines (59 loc) · 3.19 KB
/
Basic.lean
File metadata and controls
77 lines (59 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
module
public import Mathlib.Logic.Small.Defs
public import Mathlib.Logic.Equiv.Set
/-!
# Instances and theorems for `Small`.
In particular we prove `small_of_injective` and `small_of_surjective`.
-/
@[expose] public section
assert_not_exists Countable
universe u w v v'
-- TODO(timotree3): lower the priority on this instance?
-- This instance applies to every synthesis problem of the form `Small ↥s` for some set `s`,
-- but we have lots of instances of `Small` for specific set constructions.
instance small_subtype (α : Type v) [Small.{w} α] (P : α → Prop) : Small.{w} { x // P x } :=
small_map (equivShrink α).subtypeEquivOfSubtype'
theorem small_of_injective {α : Type v} {β : Type w} [Small.{u} β] {f : α → β}
(hf : Function.Injective f) : Small.{u} α :=
small_map (Equiv.ofInjective f hf)
theorem small_of_surjective {α : Type v} {β : Type w} [Small.{u} α] {f : α → β}
(hf : Function.Surjective f) : Small.{u} β :=
small_of_injective (Function.injective_surjInv hf)
instance (priority := 100) small_subsingleton (α : Type v) [Subsingleton α] : Small.{w} α := by
rcases isEmpty_or_nonempty α with ⟨⟩
· apply small_map (Equiv.equivPEmpty α)
· apply small_map Equiv.punitOfNonemptyOfSubsingleton
/-- This can be seen as a version of `small_of_surjective` in which the function `f` doesn't
actually land in `β` but in some larger type `γ` related to `β` via an injective function `g`.
-/
theorem small_of_injective_of_exists {α : Type v} {β : Type w} {γ : Type v'} [Small.{u} α]
(f : α → γ) {g : β → γ} (hg : Function.Injective g) (h : ∀ b : β, ∃ a : α, f a = g b) :
Small.{u} β := by
by_cases hβ : Nonempty β
· refine small_of_surjective (f := Function.invFun g ∘ f) (fun b => ?_)
obtain ⟨a, ha⟩ := h b
exact ⟨a, by rw [Function.comp_apply, ha, Function.leftInverse_invFun hg]⟩
· simp only [not_nonempty_iff] at hβ
infer_instance
/-!
We don't define `Countable.toSmall` in this file, to keep imports to `Logic` to a minimum.
-/
instance small_Pi {α} (β : α → Type*) [Small.{w} α] [∀ a, Small.{w} (β a)] :
Small.{w} (∀ a, β a) :=
⟨⟨∀ a' : Shrink α, Shrink (β ((equivShrink α).symm a')),
⟨Equiv.piCongr (equivShrink α) fun a => by simpa using equivShrink (β a)⟩⟩⟩
instance small_prod {α β} [Small.{w} α] [Small.{w} β] : Small.{w} (α × β) :=
⟨⟨Shrink α × Shrink β, ⟨Equiv.prodCongr (equivShrink α) (equivShrink β)⟩⟩⟩
instance small_sum {α β} [Small.{w} α] [Small.{w} β] : Small.{w} (α ⊕ β) :=
⟨⟨Shrink α ⊕ Shrink β, ⟨Equiv.sumCongr (equivShrink α) (equivShrink β)⟩⟩⟩
instance small_set {α} [Small.{w} α] : Small.{w} (Set α) :=
⟨⟨Set (Shrink α), ⟨Equiv.Set.congr (equivShrink α)⟩⟩⟩
instance small_quot {α : Type u} [Small.{v} α] (r : α → α → Prop) : Small.{v} (Quot r) :=
small_of_surjective Quot.mk_surjective
instance small_quotient {α : Type u} [Small.{v} α] (s : Setoid α) : Small.{v} (Quotient s) :=
small_of_surjective Quotient.mk_surjective