l3lab/ntp-mathlib huggingface dataset:
theorem sum_card_parts : ∑ i in P.parts, i.card = s.card := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s t u : Finset α
P : Finpartition s
a : α
⊢ ∑ i in P.parts, card i = card s

Next tactic:
convert congr_arg Finset.card P.biUnion_parts
theorem sum_card_parts : ∑ i in P.parts, i.card = s.card := by
  convert congr_arg Finset.card P.biUnion_parts
  

Proof state:
case h.e'_2
α : Type u_1
inst✝ : DecidableEq α
s t u : Finset α
P : Finpartition s
a : α
⊢ ∑ i in P.parts, card i = card (Finset.biUnion P.parts id)

Next tactic:
rw [card_biUnion P.supIndep.pairwiseDisjoint]
theorem sum_card_parts : ∑ i in P.parts, i.card = s.card := by
  convert congr_arg Finset.card P.biUnion_parts
  rw [card_biUnion P.supIndep.pairwiseDisjoint]
  

Proof state:
case h.e'_2
α : Type u_1
inst✝ : DecidableEq α
s t u : Finset α
P : Finpartition s
a : α
⊢ ∑ i in P.parts, card i = ∑ u in P.parts, card (id u)

Next tactic:
rfl
/-- `⊥` is the partition in singletons, aka discrete partition. -/
instance (s : Finset α) : Bot (Finpartition s) :=
  ⟨{  parts := s.map ⟨singleton, singleton_injective⟩
      supIndep :=
        Set.PairwiseDisjoint.supIndep
          (by
            

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
⊢ Set.PairwiseDisjoint (↑(map { toFun := singleton, inj' := (_ : Injective singleton) } s)) id

Next tactic:
rw [Finset.coe_map]
/-- `⊥` is the partition in singletons, aka discrete partition. -/
instance (s : Finset α) : Bot (Finpartition s) :=
  ⟨{  parts := s.map ⟨singleton, singleton_injective⟩
      supIndep :=
        Set.PairwiseDisjoint.supIndep
          (by
            rw [Finset.coe_map]
            

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
⊢ Set.PairwiseDisjoint (⇑{ toFun := singleton, inj' := (_ : Injective singleton) } '' ↑s) id

Next tactic:
exact Finset.pairwiseDisjoint_range_singleton.subset (Set.image_subset_range _ _)
/-- `⊥` is the partition in singletons, aka discrete partition. -/
instance (s : Finset α) : Bot (Finpartition s) :=
  ⟨{  parts := s.map ⟨singleton, singleton_injective⟩
      supIndep :=
        Set.PairwiseDisjoint.supIndep
          (by
            rw [Finset.coe_map]
            exact Finset.pairwiseDisjoint_range_singleton.subset (Set.image_subset_range _ _))
      supParts := by 

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
⊢ sup (map { toFun := singleton, inj' := (_ : Injective singleton) } s) id = s

Next tactic:
rw [sup_map, comp.left_id, Embedding.coeFn_mk, Finset.sup_singleton']
/-- `⊥` is the partition in singletons, aka discrete partition. -/
instance (s : Finset α) : Bot (Finpartition s) :=
  ⟨{  parts := s.map ⟨singleton, singleton_injective⟩
      supIndep :=
        Set.PairwiseDisjoint.supIndep
          (by
            rw [Finset.coe_map]
            exact Finset.pairwiseDisjoint_range_singleton.subset (Set.image_subset_range _ _))
      supParts := by rw [sup_map, comp.left_id, Embedding.coeFn_mk, Finset.sup_singleton']
      not_bot_mem := by 

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
⊢ ⊥ ∉ map { toFun := singleton, inj' := (_ : Injective singleton) } s

Next tactic:
simp
instance (s : Finset α) : OrderBot (Finpartition s) :=
  { (inferInstance : Bot (Finpartition s)) with
    bot_le := fun P t ht ↦ by
      

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t✝ u : Finset α
P✝ : Finpartition s✝
a : α
s : Finset α
src✝ : Bot (Finpartition s) := inferInstance
P : Finpartition s
t : Finset α
ht : t ∈ ⊥.parts
⊢ ∃ c ∈ P.parts, t ≤ c

Next tactic:
rw [mem_bot_iff] at ht
instance (s : Finset α) : OrderBot (Finpartition s) :=
  { (inferInstance : Bot (Finpartition s)) with
    bot_le := fun P t ht ↦ by
      rw [mem_bot_iff] at ht
      

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t✝ u : Finset α
P✝ : Finpartition s✝
a : α
s : Finset α
src✝ : Bot (Finpartition s) := inferInstance
P : Finpartition s
t : Finset α
ht : ∃ a ∈ s, {a} = t
⊢ ∃ c ∈ P.parts, t ≤ c

Next tactic:
obtain ⟨a, ha, rfl⟩ := ht
instance (s : Finset α) : OrderBot (Finpartition s) :=
  { (inferInstance : Bot (Finpartition s)) with
    bot_le := fun P t ht ↦ by
      rw [mem_bot_iff] at ht
      obtain ⟨a, ha, rfl⟩ := ht
      

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P✝ : Finpartition s✝
a✝ : α
s : Finset α
src✝ : Bot (Finpartition s) := inferInstance
P : Finpartition s
a : α
ha : a ∈ s
⊢ ∃ c ∈ P.parts, {a} ≤ c

Next tactic:
obtain ⟨t, ht, hat⟩ := P.exists_mem ha
instance (s : Finset α) : OrderBot (Finpartition s) :=
  { (inferInstance : Bot (Finpartition s)) with
    bot_le := fun P t ht ↦ by
      rw [mem_bot_iff] at ht
      obtain ⟨a, ha, rfl⟩ := ht
      obtain ⟨t, ht, hat⟩ := P.exists_mem ha
      

Proof state:
case intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t✝ u : Finset α
P✝ : Finpartition s✝
a✝ : α
s : Finset α
src✝ : Bot (Finpartition s) := inferInstance
P : Finpartition s
a : α
ha : a ∈ s
t : Finset α
ht : t ∈ P.parts
hat : a ∈ t
⊢ ∃ c ∈ P.parts, {a} ≤ c

Next tactic:
exact ⟨t, ht, singleton_subset_iff.2 hat⟩
theorem card_parts_le_card (P : Finpartition s) : P.parts.card ≤ s.card := by
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s t u : Finset α
P✝ : Finpartition s
a : α
P : Finpartition s
⊢ card P.parts ≤ card s

Next tactic:
rw [← card_bot s]
theorem card_parts_le_card (P : Finpartition s) : P.parts.card ≤ s.card := by
  rw [← card_bot s]
  

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s t u : Finset α
P✝ : Finpartition s
a : α
P : Finpartition s
⊢ card P.parts ≤ card ⊥.parts

Next tactic:
exact card_mono bot_le
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
x : Finset α
hx : x ∈ ↑(image (fun Q => filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s) (powerset F))
y : Finset α
hy : y ∈ ↑(image (fun Q => filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s) (powerset F))
h : x ≠ y
z : α
hz1 : z ∈ id x
hz2 : z ∈ id y
⊢ x = y

Next tactic:
rw [mem_coe, mem_image] at hx hy
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
x : Finset α
hx : ∃ a ∈ powerset F, filter (fun i => ∀ t ∈ F, t ∈ a ↔ i ∈ t) s = x
y : Finset α
hy : ∃ a ∈ powerset F, filter (fun i => ∀ t ∈ F, t ∈ a ↔ i ∈ t) s = y
h : x ≠ y
z : α
hz1 : z ∈ id x
hz2 : z ∈ id y
⊢ x = y

Next tactic:
obtain ⟨Q, hQ, rfl⟩ := hx
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            

Proof state:
case intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
y : Finset α
hy : ∃ a ∈ powerset F, filter (fun i => ∀ t ∈ F, t ∈ a ↔ i ∈ t) s = y
z : α
hz2 : z ∈ id y
Q : Finset (Finset α)
hQ : Q ∈ powerset F
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ y
hz1 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
⊢ filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s = y

Next tactic:
obtain ⟨R, hR, rfl⟩ := hy
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            

Proof state:
case intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ∈ powerset F
hz1 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
R : Finset (Finset α)
hR : R ∈ powerset F
hz2 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s)
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
⊢ filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s = filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s

Next tactic:
suffices h' : Q = R
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · 

Proof state:
case intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ∈ powerset F
hz1 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
R : Finset (Finset α)
hR : R ∈ powerset F
hz2 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s)
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
h' : Q = R
⊢ filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s = filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s

Next tactic:
subst h'
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              

Proof state:
case intro.intro.intro.intro
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ∈ powerset F
hz1 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
hR : Q ∈ powerset F
hz2 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s
⊢ filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s = filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s

Next tactic:
exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            

Proof state:
case h'
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ∈ powerset F
hz1 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s)
R : Finset (Finset α)
hR : R ∈ powerset F
hz2 : z ∈ id (filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s)
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
⊢ Q = R

Next tactic:
rw [id, mem_filter] at hz1 hz2
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            

Proof state:
case h'
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ∈ powerset F
hz1 : z ∈ s ∧ ∀ t ∈ F, t ∈ Q ↔ z ∈ t
R : Finset (Finset α)
hR : R ∈ powerset F
hz2 : z ∈ s ∧ ∀ t ∈ F, t ∈ R ↔ z ∈ t
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
⊢ Q = R

Next tactic:
rw [mem_powerset] at hQ hR
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            

Proof state:
case h'
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ⊆ F
hz1 : z ∈ s ∧ ∀ t ∈ F, t ∈ Q ↔ z ∈ t
R : Finset (Finset α)
hR : R ⊆ F
hz2 : z ∈ s ∧ ∀ t ∈ F, t ∈ R ↔ z ∈ t
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
⊢ Q = R

Next tactic:
ext i
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            

Proof state:
case h'.a
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ⊆ F
hz1 : z ∈ s ∧ ∀ t ∈ F, t ∈ Q ↔ z ∈ t
R : Finset (Finset α)
hR : R ⊆ F
hz2 : z ∈ s ∧ ∀ t ∈ F, t ∈ R ↔ z ∈ t
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
i : Finset α
⊢ i ∈ Q ↔ i ∈ R

Next tactic:
refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
            · 

Proof state:
case h'.a.refine'_1
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ⊆ F
hz1 : z ∈ s ∧ ∀ t ∈ F, t ∈ Q ↔ z ∈ t
R : Finset (Finset α)
hR : R ⊆ F
hz2 : z ∈ s ∧ ∀ t ∈ F, t ∈ R ↔ z ∈ t
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
i : Finset α
hi : i ∈ Q
⊢ i ∈ R

Next tactic:
rwa [hz2.2 _ (hQ hi), ← hz1.2 _ (hQ hi)]
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
            · rwa [hz2.2 _ (hQ hi), ← hz1.2 _ (hQ hi)]
            · 

Proof state:
case h'.a.refine'_2
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
z : α
Q : Finset (Finset α)
hQ : Q ⊆ F
hz1 : z ∈ s ∧ ∀ t ∈ F, t ∈ Q ↔ z ∈ t
R : Finset (Finset α)
hR : R ⊆ F
hz2 : z ∈ s ∧ ∀ t ∈ F, t ∈ R ↔ z ∈ t
h : filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s ≠ filter (fun i => ∀ t ∈ F, t ∈ R ↔ i ∈ t) s
i : Finset α
hi : i ∈ R
⊢ i ∈ Q

Next tactic:
rwa [hz1.2 _ (hR hi), ← hz2.2 _ (hR hi)]
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
            · rwa [hz2.2 _ (hQ hi), ← hz1.2 _ (hQ hi)]
            · rwa [hz1.2 _ (hR hi), ← hz2.2 _ (hR hi)]))
    (by
      

Proof state:
α : Type u_1
inst✝ : DecidableEq α
s✝ t u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
⊢ sup (image (fun Q => filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s) (powerset F)) id = s

Next tactic:
refine' (Finset.sup_le fun t ht ↦ _).antisymm fun a ha ↦ _
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
            · rwa [hz2.2 _ (hQ hi), ← hz1.2 _ (hQ hi)]
            · rwa [hz1.2 _ (hR hi), ← hz2.2 _ (hR hi)]))
    (by
      refine' (Finset.sup_le fun t ht ↦ _).antisymm fun a ha ↦ _
      · 

Proof state:
case refine'_1
α : Type u_1
inst✝ : DecidableEq α
s✝ t✝ u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
t : Finset α
ht : t ∈ image (fun Q => filter (fun i => ∀ t ∈ F, t ∈ Q ↔ i ∈ t) s) (powerset F)
⊢ id t ≤ s

Next tactic:
rw [mem_image] at ht
/-- Cuts `s` along the finsets in `F`: Two elements of `s` will be in the same part if they are
in the same finsets of `F`. -/
def atomise (s : Finset α) (F : Finset (Finset α)) : Finpartition s :=
  ofErase (F.powerset.image fun Q ↦ s.filter fun i ↦ ∀ t ∈ F, t ∈ Q ↔ i ∈ t)
    (Set.PairwiseDisjoint.supIndep fun x hx y hy h ↦
      disjoint_left.mpr fun z hz1 hz2 ↦
        h (by
            rw [mem_coe, mem_image] at hx hy
            obtain ⟨Q, hQ, rfl⟩ := hx
            obtain ⟨R, hR, rfl⟩ := hy
            suffices h' : Q = R
            · subst h'
              exact of_eq_true (eq_self (
                filter (fun i ↦ ∀ (t : Finset α), t ∈ F → (t ∈ Q ↔ i ∈ t)) s))
            rw [id, mem_filter] at hz1 hz2
            rw [mem_powerset] at hQ hR
            ext i
            refine' ⟨fun hi ↦ _, fun hi ↦ _⟩
            · rwa [hz2.2 _ (hQ hi), ← hz1.2 _ (hQ hi)]
            · rwa [hz1.2 _ (hR hi), ← hz2.2 _ (hR hi)]))
    (by
      refine' (Finset.sup_le fun t ht ↦ _).antisymm fun a ha ↦ _
      · rw [mem_image] at ht
        

Proof state:
case refine'_1
α : Type u_1
inst✝ : DecidableEq α
s✝ t✝ u : Finset α
P : Finpartition s✝
a : α
s : Finset α
F : Finset (Finset α)
t : Finset α
ht : ∃ a ∈ powerset F, filter (fun i => ∀ t ∈ F, t ∈ a ↔ i ∈ t) s = t
⊢ id t ≤ s

Next tactic:
obtain ⟨A, _, rfl⟩ := ht