Skip to content

Commit 4b0d022

Browse files
committed
feat(Data/Set/Basic,Data/Finset/Empty): forall_mem_const for nonempty s (leanprover-community#40745)
Add variants of the `forall_const` `@simp` lemma that localize to a `Nonempty` `Set` or `Finset`. Here we use the instance form of `Nonempty` (in contrast to the existing `Finset.Nonempty.forall_const`) in order to make `simp` work painlessly. Co-authored-by: Terence Tao <tao@math.ucla.edu>
1 parent c108fbd commit 4b0d022

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Mathlib/Data/Finset/Empty.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ theorem Nonempty.forall_const {s : Finset α} (h : s.Nonempty) {p : Prop} : (∀
7474
let ⟨x, hx⟩ := h
7575
fun h => h x hx, fun h _ _ => h⟩
7676

77+
@[simp]
78+
theorem forall_mem_const {s : Finset α} [Nonempty s] {p : Prop} : (∀ x ∈ s, p) ↔ p :=
79+
(nonempty_coe_sort.mp ‹_›).forall_const
80+
7781
theorem Nonempty.to_subtype {s : Finset α} : s.Nonempty → Nonempty s :=
7882
nonempty_coe_sort.2
7983

Mathlib/Data/Set/Basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,14 @@ theorem subset_eq_empty {s t : Set α} (h : t ⊆ s) (e : s = ∅) : t = ∅ :=
505505
theorem forall_mem_empty {p : α → Prop} : (∀ x ∈ (∅ : Set α), p x) ↔ True :=
506506
iff_true_intro fun _ => False.elim
507507

508+
theorem Nonempty.forall_const (h : s.Nonempty) {p : Prop} : (∀ x ∈ s, p) ↔ p :=
509+
let ⟨x, hx⟩ := h
510+
fun h ↦ h x hx, fun h _ _ ↦ h⟩
511+
512+
@[simp]
513+
theorem forall_mem_const {p : Prop} [Nonempty s] : (∀ x ∈ s, p) ↔ p :=
514+
(nonempty_coe_sort.mp ‹_›).forall_const
515+
508516
instance (α : Type u) : IsEmpty.{u + 1} (↥(∅ : Set α)) :=
509517
fun x => x.2
510518

0 commit comments

Comments
 (0)