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

Commit d2d8742

Browse files
committed
chore(logic/equiv/basic): Generalize Type to Sort (#18543)
This backports a change that was already made in mathlib4. Indeed, mathport complains that the change was made, see the comments in https://github.com/leanprover-community/mathlib3port/blob/e3a205b1f51e409563e9e4294f41dd4df61f578a/Mathbin/Logic/Equiv/Basic.lean#L1729-L1735 By backporting this, we can deal with the fallout up-front rather than during porting.
1 parent 62e8311 commit d2d8742

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

src/combinatorics/configuration.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ begin
437437
convert (fintype.card_subtype_compl _).trans (congr_arg _ (fintype.card_subtype_eq p)) },
438438
have h2 : ∀ l : {l : L // p ∈ l}, fintype.card {q // q ∈ l.1 ∧ q ≠ p} = order P L,
439439
{ intro l,
440-
rw [←fintype.card_congr (equiv.subtype_subtype_equiv_subtype_inter _ _),
440+
rw [←fintype.card_congr (equiv.subtype_subtype_equiv_subtype_inter (∈ l.val) (≠ p)),
441441
fintype.card_subtype_compl (λ (x : subtype (∈ l.val)), x.val = p), ←nat.card_eq_fintype_card],
442442
refine tsub_eq_of_eq_add ((point_count_eq P l.1).trans _),
443443
rw ← fintype.card_subtype_eq (⟨p, l.2⟩ : {q : P // q ∈ l.1}),

src/data/list/defs.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,23 +246,23 @@ mall id
246246
end
247247

248248
/-- Auxiliary definition for `foldl_with_index`. -/
249-
def foldl_with_index_aux (f : ℕ → α → β → α) : ℕ → α → list β → α
249+
def foldl_with_index_aux {α : Sort*} {β : Type*} (f : ℕ → α → β → α) : ℕ → α → list β → α
250250
| _ a [] := a
251251
| i a (b :: l) := foldl_with_index_aux (i + 1) (f i a b) l
252252

253253
/-- Fold a list from left to right as with `foldl`, but the combining function
254254
also receives each element's index. -/
255-
def foldl_with_index (f : ℕ → α → β → α) (a : α) (l : list β) : α :=
255+
def foldl_with_index {α : Sort*} {β : Type*} (f : ℕ → α → β → α) (a : α) (l : list β) : α :=
256256
foldl_with_index_aux f 0 a l
257257

258258
/-- Auxiliary definition for `foldr_with_index`. -/
259-
def foldr_with_index_aux (f : ℕ → α → β → β) : ℕ → β → list α → β
259+
def foldr_with_index_aux {α : Type*} {β : Sort*} (f : ℕ → α → β → β) : ℕ → β → list α → β
260260
| _ b [] := b
261261
| i b (a :: l) := f i a (foldr_with_index_aux (i + 1) b l)
262262

263263
/-- Fold a list from right to left as with `foldr`, but the combining function
264264
also receives each element's index. -/
265-
def foldr_with_index (f : ℕ → α → β → β) (b : β) (l : list α) : β :=
265+
def foldr_with_index {α : Type*} {β : Sort*} (f : ℕ → α → β → β) (b : β) (l : list α) : β :=
266266
foldr_with_index_aux f 0 b l
267267

268268
/-- `find_indexes p l` is the list of indexes of elements of `l` that satisfy `p`. -/

src/logic/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ attribute [symm] ne.symm
177177

178178
lemma ne_comm {α} {a b : α} : a ≠ b ↔ b ≠ a := ⟨ne.symm, ne.symm⟩
179179

180-
@[simp] lemma eq_iff_eq_cancel_left {b c : α} :
180+
@[simp] lemma eq_iff_eq_cancel_left {α : Sort*} {b c : α} :
181181
(∀ {a}, a = b ↔ a = c) ↔ (b = c) :=
182182
⟨λ h, by rw [← h], λ h a, by rw h⟩
183183

184-
@[simp] lemma eq_iff_eq_cancel_right {a b : α} :
184+
@[simp] lemma eq_iff_eq_cancel_right {α : Sort*} {a b : α} :
185185
(∀ {c}, a = c ↔ b = c) ↔ (a = b) :=
186186
⟨λ h, by rw h, λ h a, by rw h⟩
187187

src/logic/equiv/basic.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,20 +811,20 @@ def subtype_equiv_of_subtype' {p : α → Prop} (e : α ≃ β) :
811811
e.symm.subtype_equiv_of_subtype.symm
812812

813813
/-- If two predicates are equal, then the corresponding subtypes are equivalent. -/
814-
def subtype_equiv_prop {α : Type*} {p q : α → Prop} (h : p = q) : subtype p ≃ subtype q :=
814+
def subtype_equiv_prop {α : Sort*} {p q : α → Prop} (h : p = q) : subtype p ≃ subtype q :=
815815
subtype_equiv (equiv.refl α) (assume a, h ▸ iff.rfl)
816816

817817
/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This
818818
version allows the “inner” predicate to depend on `h : p a`. -/
819819
@[simps]
820-
def subtype_subtype_equiv_subtype_exists {α : Type u} (p : α → Prop) (q : subtype p → Prop) :
820+
def subtype_subtype_equiv_subtype_exists {α : Sort u} (p : α → Prop) (q : subtype p → Prop) :
821821
subtype q ≃ {a : α // ∃h:p a, q ⟨a, h⟩ } :=
822822
⟨λ a, ⟨a, a.1.2, by { rcases a with ⟨⟨a, hap⟩, haq⟩, exact haq }⟩,
823823
λ a, ⟨⟨a, a.2.fst⟩, a.2.snd⟩,
824824
assume ⟨⟨a, ha⟩, h⟩, rfl, assume ⟨a, h₁, h₂⟩, rfl⟩
825825

826826
/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/
827-
@[simps] def subtype_subtype_equiv_subtype_inter {α : Type u} (p q : α → Prop) :
827+
@[simps] def subtype_subtype_equiv_subtype_inter {α : Sort u} (p q : α → Prop) :
828828
{x : subtype p // q x.1} ≃ subtype (λ x, p x ∧ q x) :=
829829
(subtype_subtype_equiv_subtype_exists p _).trans $
830830
subtype_equiv_right $ λ x, exists_prop
@@ -1249,7 +1249,7 @@ end function.involutive
12491249
lemma plift.eq_up_iff_down_eq {x : plift α} {y : α} : x = plift.up y ↔ x.down = y :=
12501250
equiv.plift.eq_symm_apply
12511251

1252-
lemma function.injective.map_swap {α β : Type*} [decidable_eq α] [decidable_eq β]
1252+
lemma function.injective.map_swap {α β : Sort*} [decidable_eq α] [decidable_eq β]
12531253
{f : α → β} (hf : function.injective f) (x y z : α) :
12541254
f (equiv.swap x y z) = equiv.swap (f x) (f y) (f z) :=
12551255
begin

src/logic/nonempty.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ lemma classical.nonempty_pi {ι} {α : ι → Sort*} : nonempty (Π i, α i) ↔
121121
lemma subsingleton_of_not_nonempty {α : Sort*} (h : ¬ nonempty α) : subsingleton α :=
122122
⟨λ x, false.elim $ not_nonempty_iff_imp_false.mp h x⟩
123123

124-
lemma function.surjective.nonempty [h : nonempty β] {f : α → β} (hf : function.surjective f) :
124+
lemma function.surjective.nonempty {α β : Sort*} [h : nonempty β] {f : α → β}
125+
(hf : function.surjective f) :
125126
nonempty α :=
126127
let ⟨y⟩ := h, ⟨x, hx⟩ := hf y in ⟨x⟩

0 commit comments

Comments
 (0)