l3lab/ntp-mathlib huggingface dataset:
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card 𝒜 ≤ card (shatterer 𝒜)

Next tactic:
have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · 

Proof state:
case hℬ
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))

Next tactic:
refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    

Proof state:
case hℬ
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ ↑(shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜)) ⊆ {s | a ∉ s}

Next tactic:
simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    

Proof state:
case hℬ
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ ∀ (x : Finset α), Shatters (memberSubfamily a 𝒜) x → Shatters (nonMemberSubfamily a 𝒜) x → a ∉ x

Next tactic:
exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card 𝒜 ≤ card (shatterer 𝒜)

Next tactic:
rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card (memberSubfamily a 𝒜) + card (nonMemberSubfamily a 𝒜) ≤ card (shatterer 𝒜)

Next tactic:
refine (add_le_add ih₁ ih₀).trans ?_
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card (shatterer (memberSubfamily a 𝒜)) + card (shatterer (nonMemberSubfamily a 𝒜)) ≤ card (shatterer 𝒜)

Next tactic:
rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card (shatterer (memberSubfamily a 𝒜) ∪ shatterer (nonMemberSubfamily a 𝒜) ∪ ℬ) ≤ card (shatterer 𝒜)
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ Disjoint (shatterer (memberSubfamily a 𝒜) ∪ shatterer (nonMemberSubfamily a 𝒜)) ℬ

Next tactic:
swap
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · 

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ Disjoint (shatterer (memberSubfamily a 𝒜) ∪ shatterer (nonMemberSubfamily a 𝒜)) ℬ

Next tactic:
simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ ∀ ⦃a_1 : Finset α⦄,
    Shatters (memberSubfamily a 𝒜) a_1 ∨ Shatters (nonMemberSubfamily a 𝒜) a_1 →
      ∀ x ∈ shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜), ¬insert a x = a_1

Next tactic:
rintro _ (hs | hs) s - rfl
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    rintro _ (hs | hs) s - rfl
    · 

Proof state:
case refine_3.inl
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s✝ t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
s : Finset α
hs : Shatters (memberSubfamily a 𝒜) (insert a s)
⊢ False

Next tactic:
exact aux (fun t ht ↦ (mem_memberSubfamily.1 ht).2) hs <| mem_insert_self _ _
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    rintro _ (hs | hs) s - rfl
    · exact aux (fun t ht ↦ (mem_memberSubfamily.1 ht).2) hs <| mem_insert_self _ _
    · 

Proof state:
case refine_3.inr
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s✝ t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
s : Finset α
hs : Shatters (nonMemberSubfamily a 𝒜) (insert a s)
⊢ False

Next tactic:
exact aux (fun t ht ↦ (mem_nonMemberSubfamily.1 ht).2) hs <| mem_insert_self _ _
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    rintro _ (hs | hs) s - rfl
    · exact aux (fun t ht ↦ (mem_memberSubfamily.1 ht).2) hs <| mem_insert_self _ _
    · exact aux (fun t ht ↦ (mem_nonMemberSubfamily.1 ht).2) hs <| mem_insert_self _ _
  

Proof state:
case refine_3
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ card (shatterer (memberSubfamily a 𝒜) ∪ shatterer (nonMemberSubfamily a 𝒜) ∪ ℬ) ≤ card (shatterer 𝒜)

Next tactic:
refine card_mono <| union_subset (union_subset ?_ <| shatterer_mono <| filter_subset _ _) ?_
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    rintro _ (hs | hs) s - rfl
    · exact aux (fun t ht ↦ (mem_memberSubfamily.1 ht).2) hs <| mem_insert_self _ _
    · exact aux (fun t ht ↦ (mem_nonMemberSubfamily.1 ht).2) hs <| mem_insert_self _ _
  refine card_mono <| union_subset (union_subset ?_ <| shatterer_mono <| filter_subset _ _) ?_
  · 

Proof state:
case refine_3.refine_1
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ shatterer (memberSubfamily a 𝒜) ⊆ shatterer 𝒜

Next tactic:
simp only [subset_iff, mem_shatterer]
/-- Pajor's variant of the **Sauer-Shelah lemma**. -/
lemma card_le_card_shatterer (𝒜 : Finset (Finset α)) : 𝒜.card ≤ 𝒜.shatterer.card := by
  refine memberFamily_induction_on 𝒜 ?_ ?_ ?_
  · simp
  · rfl
  intros a 𝒜 ih₀ ih₁
  set ℬ : Finset (Finset α) :=
    ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).image (insert a)
  have hℬ :
    ℬ.card = ((memberSubfamily a 𝒜).shatterer ∩ (nonMemberSubfamily a 𝒜).shatterer).card
  · refine card_image_of_injOn <| insert_erase_invOn.2.injOn.mono ?_
    simp only [coe_inter, Set.subset_def, Set.mem_inter_iff, mem_coe, Set.mem_setOf_eq, and_imp,
      mem_shatterer]
    exact fun s _ ↦ aux (fun t ht ↦ (mem_filter.1 ht).2)
  rw [← card_memberSubfamily_add_card_nonMemberSubfamily a]
  refine (add_le_add ih₁ ih₀).trans ?_
  rw [← card_union_add_card_inter, ← hℬ, ← card_disjoint_union]
  swap
  · simp only [disjoint_left, mem_union, mem_shatterer, mem_image, not_exists, not_and]
    rintro _ (hs | hs) s - rfl
    · exact aux (fun t ht ↦ (mem_memberSubfamily.1 ht).2) hs <| mem_insert_self _ _
    · exact aux (fun t ht ↦ (mem_nonMemberSubfamily.1 ht).2) hs <| mem_insert_self _ _
  refine card_mono <| union_subset (union_subset ?_ <| shatterer_mono <| filter_subset _ _) ?_
  · simp only [subset_iff, mem_shatterer]
    

Proof state:
case refine_3.refine_1
α : Type u_1
inst✝ : DecidableEq α
𝒜✝¹ ℬ✝ : Finset (Finset α)
s t : Finset α
a✝ : α
n : ℕ
𝒜✝ : Finset (Finset α)
a : α
𝒜 : Finset (Finset α)
ih₀ : card (nonMemberSubfamily a 𝒜) ≤ card (shatterer (nonMemberSubfamily a 𝒜))
ih₁ : card (memberSubfamily a 𝒜) ≤ card (shatterer (memberSubfamily a 𝒜))
ℬ : Finset (Finset α) := image (insert a) (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
hℬ : card ℬ = card (shatterer (memberSubfamily a 𝒜) ∩ shatterer (nonMemberSubfamily a 𝒜))
⊢ ∀ ⦃x : Finset α⦄, Shatters (memberSubfamily a 𝒜) x → Shatters 𝒜 x

Next tactic:
rintro s hs t ht