Skip to content

Commit 9f8304e

Browse files
committed
Golfed proofs using grind
1 parent b0beb6b commit 9f8304e

1 file changed

Lines changed: 6 additions & 29 deletions

File tree

Mathlib/Data/Finset/Powerset.lean

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,16 @@ theorem powerset_eq_singleton_empty : s.powerset = {∅} ↔ s = ∅ := by
7575

7676
theorem image_injOn_powerset_of_injOn {β : Type*} [DecidableEq β] {f : α → β} (H : Set.InjOn f s) :
7777
Set.InjOn (fun (x : Finset α) => x.image f) s.powerset := by
78-
intro x hx y hy h
79-
rw [mem_coe, mem_powerset] at hx hy
80-
dsimp at h
81-
ext a
82-
by_cases a ∈ s
83-
case pos ha =>
84-
have {z : Finset α} (hz : z ⊆ s) : a ∈ z ↔ f a ∈ z.image f := by
85-
refine ⟨fun b => mem_image_of_mem f b, fun h => ?_⟩
86-
obtain ⟨b, hb₁, hb₂⟩ := mem_image.mp h
87-
suffices b = a by rwa [this] at hb₁
88-
exact (H.eq_iff (hz hb₁) ha).mp hb₂
89-
rw [this hx, this hy, h]
90-
case neg ha => tauto
78+
have {z a} (_ : z ⊆ s) (_ : a ∈ s) : a ∈ z ↔ f a ∈ z.image f := by grind [H.eq_iff]
79+
exact fun _ _ _ _ _ => by grind
9180

9281
theorem image_surjOn_powerset {β : Type*} [DecidableEq β] {f : α → β} :
93-
Set.SurjOn (fun (x : Finset α) => x.image f) s.powerset (s.image f).powerset := by
94-
intro t ht
95-
rw [mem_coe, mem_powerset] at ht
96-
simp_rw [Set.mem_image, mem_coe, mem_powerset]
97-
use { x ∈ s | f x ∈ t}
98-
grind
82+
Set.SurjOn (fun (x : Finset α) => x.image f) s.powerset (s.image f).powerset :=
83+
fun t ht => ⟨{ x ∈ s | f x ∈ t}, by grind⟩
9984

10085
theorem powerset_image {β : Type*} [DecidableEq β] {f : α → β} :
101-
(s.image f).powerset = s.powerset.image (fun x => x.image f) := by
102-
ext a
103-
rw [mem_powerset, mem_image]
104-
refine ⟨fun ha => ?_, fun ha => ?_⟩
105-
· use { x ∈ s | f x ∈ a }
106-
grind
107-
· obtain ⟨b, hb₁, hb₂⟩ := ha
108-
rw [mem_powerset] at hb₁
109-
rw [← hb₂]
110-
exact image_subset_image hb₁
86+
(s.image f).powerset = s.powerset.image (fun x => x.image f) :=
87+
ext fun a => ⟨fun _ => mem_image.mpr ⟨{ x ∈ s | f x ∈ a}, by grind⟩, by grind⟩
11188

11289
/-- **Number of Subsets of a Set** -/
11390
@[simp]

0 commit comments

Comments
 (0)