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

Commit b4b05dd

Browse files
kim-emjohoelzl
authored andcommitted
feat(logic/basic): introduce pempty
1 parent afd1c06 commit b4b05dd

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

data/equiv/basic.lean

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ def equiv_empty (h : α → false) : α ≃ empty :=
159159
def false_equiv_empty : false ≃ empty :=
160160
equiv_empty _root_.id
161161

162+
def equiv_pempty (h : α → false) : α ≃ pempty :=
163+
⟨λ x, (h x).elim, λ e, e.rec _, λ x, (h x).elim, λ e, e.rec _⟩
164+
165+
def false_equiv_pempty : false ≃ pempty :=
166+
equiv_pempty _root_.id
167+
168+
def pempty_equiv_pempty : pempty.{v} ≃ pempty.{w} :=
169+
equiv_pempty (pempty.elim)
170+
162171
def empty_of_not_nonempty {α : Sort*} (h : ¬ nonempty α) : α ≃ empty :=
163172
⟨assume a, (h ⟨a⟩).elim, assume e, e.rec_on _, assume a, (h ⟨a⟩).elim, assume e, e.rec_on _⟩
164173

@@ -188,13 +197,13 @@ section
188197
@[simp] def empty_arrow_equiv_unit (α : Sort*) : (empty → α) ≃ punit.{u} :=
189198
⟨λ f, punit.star, λ u e, e.rec _, λ f, funext $ λ x, x.rec _, λ u, by cases u; refl⟩
190199

200+
@[simp] def pempty_arrow_equiv_unit (α : Sort*) : (pempty → α) ≃ punit.{u} :=
201+
⟨λ f, punit.star, λ u e, e.rec _, λ f, funext $ λ x, x.rec _, λ u, by cases u; refl⟩
202+
191203
@[simp] def false_arrow_equiv_unit (α : Sort*) : (false → α) ≃ punit.{u} :=
192204
calc (false → α) ≃ (empty → α) : arrow_congr false_equiv_empty (equiv.refl _)
193205
... ≃ punit : empty_arrow_equiv_unit _
194206

195-
def arrow_empty_unit {α : Sort*} : (empty → α) ≃ punit.{u} :=
196-
⟨λf, punit.star, λu e, e.rec_on _, assume f, funext $ assume e, e.rec_on _, assume u, punit_eq _ _⟩
197-
198207
end
199208

200209
@[congr] def prod_congr {α₁ β₁ α₂ β₂ : Sort*} : α₁ ≃ α₂ → β₁ ≃ β₂ → (α₁ × β₁) ≃ (α₂ × β₂)
@@ -233,6 +242,12 @@ equiv_empty (λ ⟨_, e⟩, e.rec _)
233242

234243
@[simp] def empty_prod (α : Sort*) : (empty × α) ≃ empty :=
235244
equiv_empty (λ ⟨e, _⟩, e.rec _)
245+
246+
@[simp] def prod_pempty (α : Sort*) : (α × pempty) ≃ pempty :=
247+
equiv_pempty (λ ⟨_, e⟩, e.rec _)
248+
249+
@[simp] def pempty_prod (α : Sort*) : (pempty × α) ≃ pempty :=
250+
equiv_pempty (λ ⟨e, _⟩, e.rec _)
236251
end
237252

238253
section
@@ -293,6 +308,15 @@ noncomputable def Prop_equiv_bool : Prop ≃ bool :=
293308
@[simp] def empty_sum (α : Sort*) : (empty ⊕ α) ≃ α :=
294309
(sum_comm _ _).trans $ sum_empty _
295310

311+
@[simp] def sum_pempty (α : Sort*) : (α ⊕ pempty) ≃ α :=
312+
⟨λ s, match s with inl a := a | inr e := pempty.rec _ e end,
313+
inl,
314+
λ s, by rcases s with _ | ⟨⟨⟩⟩; refl,
315+
λ a, rfl⟩
316+
317+
@[simp] def pempty_sum (α : Sort*) : (pempty ⊕ α) ≃ α :=
318+
(sum_comm _ _).trans $ sum_pempty _
319+
296320
@[simp] def option_equiv_sum_unit (α : Sort*) : option α ≃ (α ⊕ punit.{u+1}) :=
297321
⟨λ o, match o with none := inr punit.star | some a := inl a end,
298322
λ s, match s with inr _ := none | inl a := some a end,
@@ -450,6 +474,9 @@ protected def univ (α) : @univ α ≃ α :=
450474
protected def empty (α) : (∅ : set α) ≃ empty :=
451475
equiv_empty $ λ ⟨x, h⟩, not_mem_empty x h
452476

477+
protected def pempty (α) : (∅ : set α) ≃ pempty :=
478+
equiv_pempty $ λ ⟨x, h⟩, not_mem_empty x h
479+
453480
protected def union {α} {s t : set α} [decidable_pred s] (H : s ∩ t = ∅) :
454481
(s ∪ t : set α) ≃ (s ⊕ t) :=
455482
⟨λ ⟨x, h⟩, if hs : x ∈ s then sum.inl ⟨_, hs⟩ else sum.inr ⟨_, h.resolve_left hs⟩,

data/fintype.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ instance : fintype empty := ⟨∅, empty.rec _⟩
169169

170170
@[simp] theorem fintype.card_empty : fintype.card empty = 0 := rfl
171171

172+
instance : fintype pempty := ⟨∅, pempty.rec _⟩
173+
174+
@[simp] theorem fintype.univ_pempty : @univ pempty _ = ∅ := rfl
175+
176+
@[simp] theorem fintype.card_pempty : fintype.card pempty = 0 := rfl
177+
172178
instance : fintype unit := ⟨⟨()::0, by simp⟩, λ ⟨⟩, by simp⟩
173179

174180
@[simp] theorem fintype.univ_unit : @univ unit _ = {()} := rfl

logic/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ instance : decidable_eq empty := λa, a.elim
3737
@[simp] theorem coe_coe {α β γ} [has_coe α β] [has_coe_t β γ]
3838
(a : α) : (a : γ) = (a : β) := rfl
3939

40+
/-- `pempty` is the universe-polymorphic analogue of `empty`. -/
41+
@[derive decidable_eq]
42+
inductive {u} pempty : Sort u
43+
44+
def pempty.elim {C : Sort*} : pempty → C.
45+
46+
instance subsingleton_pempty : subsingleton pempty := ⟨λa, a.elim⟩
47+
4048
end miscellany
4149

4250
/-

set_theory/cardinal.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ local infixr ^ := @has_pow.pow cardinal cardinal cardinal.has_pow
146146
@[simp] theorem power_zero {a : cardinal} : a ^ 0 = 1 :=
147147
quotient.induction_on a $ assume α, quotient.sound ⟨
148148
equiv.trans (equiv.arrow_congr equiv.ulift (equiv.refl α)) $
149-
equiv.trans equiv.arrow_empty_unit $
149+
equiv.trans (equiv.empty_arrow_equiv_unit α) $
150150
equiv.ulift.symm⟩
151151

152152
@[simp] theorem power_one {a : cardinal} : a ^ 1 = a :=

tactic/auto_cases.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
-- Released under Apache 2.0 license as described in the file LICENSE.
33
-- Authors: Scott Morrison
44

5+
import logic.basic
56
import tactic.basic
67
import data.option
78

89
open tactic
910

10-
-- FIXME we need to be able to add more cases here...
11-
-- Alternatively, just put `pempty` into mathlib and I'll survive.
1211
meta def auto_cases_at (h : expr) : tactic string :=
1312
do t' ← infer_type h,
1413
t' ← whnf t',
1514
let use_cases := match t' with
15+
| `(empty) := tt
16+
| `(pempty) := tt
1617
| `(unit) := tt
1718
| `(punit) := tt
1819
| `(ulift _) := tt

0 commit comments

Comments
 (0)