From 3f6e616a5e5adf5277014c1b0870e01b83f6dd39 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Thu, 12 Sep 2024 14:52:53 +1000 Subject: [PATCH 1/2] chore: restrict exists_prop' to Type --- src/Init/PropLemmas.lean | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Init/PropLemmas.lean b/src/Init/PropLemmas.lean index aa8946f6a4e5..99aed1fd8b69 100644 --- a/src/Init/PropLemmas.lean +++ b/src/Init/PropLemmas.lean @@ -352,10 +352,10 @@ theorem not_forall_of_exists_not {p : α → Prop} : (∃ x, ¬p x) → ¬∀ x, @[simp] theorem exists_or_eq_left' (y : α) (p : α → Prop) : ∃ x : α, y = x ∨ p x := ⟨y, .inl rfl⟩ @[simp] theorem exists_or_eq_right' (y : α) (p : α → Prop) : ∃ x : α, p x ∨ y = x := ⟨y, .inr rfl⟩ -@[simp] theorem exists_prop' {p : Prop} : (∃ _ : α, p) ↔ Nonempty α ∧ p := +@[simp] theorem exists_prop' {α : Type _} {p : Prop} : (∃ _ : α, p) ↔ Nonempty α ∧ p := ⟨fun ⟨a, h⟩ => ⟨⟨a⟩, h⟩, fun ⟨⟨a⟩, h⟩ => ⟨a, h⟩⟩ -theorem exists_prop : (∃ _h : a, b) ↔ a ∧ b := +@[simp] theorem exists_prop (p q : Prop): (∃ _h : p, q) ↔ p ∧ q := ⟨fun ⟨hp, hq⟩ => ⟨hp, hq⟩, fun ⟨hp, hq⟩ => ⟨hp, hq⟩⟩ @[simp] theorem exists_apply_eq_apply (f : α → β) (a' : α) : ∃ a, f a = f a' := ⟨a', rfl⟩ From 28df84e476310ddd272d3a38b465a92e40ba25f3 Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Thu, 12 Sep 2024 15:22:11 +1000 Subject: [PATCH 2/2] does this work? --- src/Init/PropLemmas.lean | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Init/PropLemmas.lean b/src/Init/PropLemmas.lean index 99aed1fd8b69..3c48771df5f2 100644 --- a/src/Init/PropLemmas.lean +++ b/src/Init/PropLemmas.lean @@ -226,7 +226,8 @@ theorem Exists.imp' {β} {q : β → Prop} (f : α → β) (hpq : ∀ a, p a → theorem exists_imp : ((∃ x, p x) → b) ↔ ∀ x, p x → b := forall_exists_index theorem exists₂_imp {P : (x : α) → p x → Prop} : (∃ x h, P x h) → b ↔ ∀ x h, P x h → b := by simp -@[simp] theorem exists_const (α) [i : Nonempty α] : (∃ _ : α, b) ↔ b := +-- We only apply this when `α : Type _`, as `exists_prop` covers the case `α : Prop`. +@[simp] theorem exists_const (α : Type _) [i : Nonempty α] : (∃ _ : α, b) ↔ b := ⟨fun ⟨_, h⟩ => h, i.elim Exists.intro⟩ @[congr] @@ -234,12 +235,6 @@ theorem exists_prop_congr {p p' : Prop} {q q' : p → Prop} (hq : ∀ h, q h ↔ Exists q ↔ ∃ h : p', q' (hp.2 h) := ⟨fun ⟨_, _⟩ ↦ ⟨hp.1 ‹_›, (hq _).1 ‹_›⟩, fun ⟨_, _⟩ ↦ ⟨_, (hq _).2 ‹_›⟩⟩ -theorem exists_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (Exists fun h' : p => q h') ↔ q h := - @exists_const (q h) p ⟨h⟩ - -@[simp] theorem exists_true_left {p : True → Prop} : Exists p ↔ p True.intro := - exists_prop_of_true _ - section forall_congr theorem forall_congr' (h : ∀ a, p a ↔ q a) : (∀ a, p a) ↔ ∀ a, q a := @@ -355,9 +350,15 @@ theorem not_forall_of_exists_not {p : α → Prop} : (∃ x, ¬p x) → ¬∀ x, @[simp] theorem exists_prop' {α : Type _} {p : Prop} : (∃ _ : α, p) ↔ Nonempty α ∧ p := ⟨fun ⟨a, h⟩ => ⟨⟨a⟩, h⟩, fun ⟨⟨a⟩, h⟩ => ⟨a, h⟩⟩ -@[simp] theorem exists_prop (p q : Prop): (∃ _h : p, q) ↔ p ∧ q := +@[simp] theorem exists_prop (p q : Prop) : (∃ _h : p, q) ↔ p ∧ q := ⟨fun ⟨hp, hq⟩ => ⟨hp, hq⟩, fun ⟨hp, hq⟩ => ⟨hp, hq⟩⟩ +theorem exists_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (Exists fun h' : p => q h') ↔ q h := + ⟨fun ⟨_, hq⟩ => hq, fun hq => ⟨h, hq⟩⟩ + +@[simp] theorem exists_true_left {p : True → Prop} : Exists p ↔ p True.intro := + exists_prop_of_true _ + @[simp] theorem exists_apply_eq_apply (f : α → β) (a' : α) : ∃ a, f a = f a' := ⟨a', rfl⟩ theorem forall_prop_of_true {p : Prop} {q : p → Prop} (h : p) : (∀ h' : p, q h') ↔ q h :=