l3lab/ntp-mathlib huggingface dataset:
/-- Given a box `I₀` in `ℝⁿ⁺¹`, `f x : Box (Fin n) → G` is a family of functions indexed by a real
`x` and for `x ∈ [I₀.lower i, I₀.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`I₀`, then `fun J ↦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `I₀`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (I₀ : Box (Fin (n + 1))) (i : Fin (n + 1))
    (f : ℝ → Box (Fin n) → G) (fb : Icc (I₀.lower i) (I₀.upper i) → Fin n →ᵇᵃ[I₀.face i] G)
    (hf : ∀ (x) (hx : x ∈ Icc (I₀.lower i) (I₀.upper i)) (J), f x J = fb ⟨x, hx⟩ J) :
    Fin (n + 1) →ᵇᵃ[I₀] G :=
  ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
    I₀
    (by
      intro J hJ j x
      rw [WithTop.coe_le_coe] at hJ
      refine' i.succAboveCases (fun hx => _) (fun j hx => _) j
      · simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_same, ← WithBot.some_eq_coe,
          Option.elim', Box.face, (· ∘ ·), update_noteq (Fin.succAbove_ne _ _)]
        abel
      · have : (J.face i : WithTop (Box (Fin n))) ≤ I₀.face i :=
          WithTop.coe_le_coe.2 (face_mono hJ i)
        

Proof state:
case refine'_2
ι : Type u_1
M : Type u_2
n : ℕ
N : Type u_3
inst✝² : AddCommMonoid M
inst✝¹ : AddCommMonoid N
I₀✝ : WithTop (Box ι)
I J✝ : Box ι
i✝ : ι
G : Type u
inst✝ : AddCommGroup G
I₀ : Box (Fin (n + 1))
i : Fin (n + 1)
f : ℝ → Box (Fin n) → G
fb : ↑(Set.Icc (lower I₀ i) (upper I₀ i)) → Fin n →ᵇᵃ[↑(face I₀ i)] G
hf :
  ∀ (x : ℝ) (hx : x ∈ Set.Icc (lower I₀ i) (upper I₀ i)) (J : Box (Fin n)), f x J = (fb { val := x, property := hx }) J
J : Box (Fin (n + 1))
hJ : J ≤ I₀
j✝ : Fin (n + 1)
x : ℝ
j : Fin n
hx : x ∈ Set.Ioo (lower J (Fin.succAbove i j)) (upper J (Fin.succAbove i j))
this : ↑(face J i) ≤ ↑(face I₀ i)
⊢ Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) (splitLower J (Fin.succAbove i j) x) +
      Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i))
        (splitUpper J (Fin.succAbove i j) x) =
    (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) J

Next tactic:
rw [le_iff_Icc, @Box.Icc_eq_pi _ I₀] at hJ
/-- Given a box `I₀` in `ℝⁿ⁺¹`, `f x : Box (Fin n) → G` is a family of functions indexed by a real
`x` and for `x ∈ [I₀.lower i, I₀.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`I₀`, then `fun J ↦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `I₀`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (I₀ : Box (Fin (n + 1))) (i : Fin (n + 1))
    (f : ℝ → Box (Fin n) → G) (fb : Icc (I₀.lower i) (I₀.upper i) → Fin n →ᵇᵃ[I₀.face i] G)
    (hf : ∀ (x) (hx : x ∈ Icc (I₀.lower i) (I₀.upper i)) (J), f x J = fb ⟨x, hx⟩ J) :
    Fin (n + 1) →ᵇᵃ[I₀] G :=
  ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
    I₀
    (by
      intro J hJ j x
      rw [WithTop.coe_le_coe] at hJ
      refine' i.succAboveCases (fun hx => _) (fun j hx => _) j
      · simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_same, ← WithBot.some_eq_coe,
          Option.elim', Box.face, (· ∘ ·), update_noteq (Fin.succAbove_ne _ _)]
        abel
      · have : (J.face i : WithTop (Box (Fin n))) ≤ I₀.face i :=
          WithTop.coe_le_coe.2 (face_mono hJ i)
        rw [le_iff_Icc, @Box.Icc_eq_pi _ I₀] at hJ
        

Proof state:
case refine'_2
ι : Type u_1
M : Type u_2
n : ℕ
N : Type u_3
inst✝² : AddCommMonoid M
inst✝¹ : AddCommMonoid N
I₀✝ : WithTop (Box ι)
I J✝ : Box ι
i✝ : ι
G : Type u
inst✝ : AddCommGroup G
I₀ : Box (Fin (n + 1))
i : Fin (n + 1)
f : ℝ → Box (Fin n) → G
fb : ↑(Set.Icc (lower I₀ i) (upper I₀ i)) → Fin n →ᵇᵃ[↑(face I₀ i)] G
hf :
  ∀ (x : ℝ) (hx : x ∈ Set.Icc (lower I₀ i) (upper I₀ i)) (J : Box (Fin n)), f x J = (fb { val := x, property := hx }) J
J : Box (Fin (n + 1))
hJ : Box.Icc J ⊆ Set.pi Set.univ fun i => Set.Icc (lower I₀ i) (upper I₀ i)
j✝ : Fin (n + 1)
x : ℝ
j : Fin n
hx : x ∈ Set.Ioo (lower J (Fin.succAbove i j)) (upper J (Fin.succAbove i j))
this : ↑(face J i) ≤ ↑(face I₀ i)
⊢ Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) (splitLower J (Fin.succAbove i j) x) +
      Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i))
        (splitUpper J (Fin.succAbove i j) x) =
    (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) J

Next tactic:
simp only
/-- Given a box `I₀` in `ℝⁿ⁺¹`, `f x : Box (Fin n) → G` is a family of functions indexed by a real
`x` and for `x ∈ [I₀.lower i, I₀.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`I₀`, then `fun J ↦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `I₀`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (I₀ : Box (Fin (n + 1))) (i : Fin (n + 1))
    (f : ℝ → Box (Fin n) → G) (fb : Icc (I₀.lower i) (I₀.upper i) → Fin n →ᵇᵃ[I₀.face i] G)
    (hf : ∀ (x) (hx : x ∈ Icc (I₀.lower i) (I₀.upper i)) (J), f x J = fb ⟨x, hx⟩ J) :
    Fin (n + 1) →ᵇᵃ[I₀] G :=
  ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
    I₀
    (by
      intro J hJ j x
      rw [WithTop.coe_le_coe] at hJ
      refine' i.succAboveCases (fun hx => _) (fun j hx => _) j
      · simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_same, ← WithBot.some_eq_coe,
          Option.elim', Box.face, (· ∘ ·), update_noteq (Fin.succAbove_ne _ _)]
        abel
      · have : (J.face i : WithTop (Box (Fin n))) ≤ I₀.face i :=
          WithTop.coe_le_coe.2 (face_mono hJ i)
        rw [le_iff_Icc, @Box.Icc_eq_pi _ I₀] at hJ
        simp only
        

Proof state:
case refine'_2
ι : Type u_1
M : Type u_2
n : ℕ
N : Type u_3
inst✝² : AddCommMonoid M
inst✝¹ : AddCommMonoid N
I₀✝ : WithTop (Box ι)
I J✝ : Box ι
i✝ : ι
G : Type u
inst✝ : AddCommGroup G
I₀ : Box (Fin (n + 1))
i : Fin (n + 1)
f : ℝ → Box (Fin n) → G
fb : ↑(Set.Icc (lower I₀ i) (upper I₀ i)) → Fin n →ᵇᵃ[↑(face I₀ i)] G
hf :
  ∀ (x : ℝ) (hx : x ∈ Set.Icc (lower I₀ i) (upper I₀ i)) (J : Box (Fin n)), f x J = (fb { val := x, property := hx }) J
J : Box (Fin (n + 1))
hJ : Box.Icc J ⊆ Set.pi Set.univ fun i => Set.Icc (lower I₀ i) (upper I₀ i)
j✝ : Fin (n + 1)
x : ℝ
j : Fin n
hx : x ∈ Set.Ioo (lower J (Fin.succAbove i j)) (upper J (Fin.succAbove i j))
this : ↑(face J i) ≤ ↑(face I₀ i)
⊢ Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) (splitLower J (Fin.succAbove i j) x) +
      Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i))
        (splitUpper J (Fin.succAbove i j) x) =
    f (upper J i) (face J i) - f (lower J i) (face J i)

Next tactic:
rw [hf _ (hJ J.upper_mem_Icc _ trivial), hf _ (hJ J.lower_mem_Icc _ trivial),
          ← (fb _).map_split_add this j x, ← (fb _).map_split_add this j x]
/-- Given a box `I₀` in `ℝⁿ⁺¹`, `f x : Box (Fin n) → G` is a family of functions indexed by a real
`x` and for `x ∈ [I₀.lower i, I₀.upper i]`, `f x` is box-additive on subboxes of the `i`-th face of
`I₀`, then `fun J ↦ f (J.upper i) (J.face i) - f (J.lower i) (J.face i)` is box-additive on subboxes
of `I₀`. -/
@[simps!]
def upperSubLower.{u} {G : Type u} [AddCommGroup G] (I₀ : Box (Fin (n + 1))) (i : Fin (n + 1))
    (f : ℝ → Box (Fin n) → G) (fb : Icc (I₀.lower i) (I₀.upper i) → Fin n →ᵇᵃ[I₀.face i] G)
    (hf : ∀ (x) (hx : x ∈ Icc (I₀.lower i) (I₀.upper i)) (J), f x J = fb ⟨x, hx⟩ J) :
    Fin (n + 1) →ᵇᵃ[I₀] G :=
  ofMapSplitAdd (fun J : Box (Fin (n + 1)) => f (J.upper i) (J.face i) - f (J.lower i) (J.face i))
    I₀
    (by
      intro J hJ j x
      rw [WithTop.coe_le_coe] at hJ
      refine' i.succAboveCases (fun hx => _) (fun j hx => _) j
      · simp only [Box.splitLower_def hx, Box.splitUpper_def hx, update_same, ← WithBot.some_eq_coe,
          Option.elim', Box.face, (· ∘ ·), update_noteq (Fin.succAbove_ne _ _)]
        abel
      · have : (J.face i : WithTop (Box (Fin n))) ≤ I₀.face i :=
          WithTop.coe_le_coe.2 (face_mono hJ i)
        rw [le_iff_Icc, @Box.Icc_eq_pi _ I₀] at hJ
        simp only
        rw [hf _ (hJ J.upper_mem_Icc _ trivial), hf _ (hJ J.lower_mem_Icc _ trivial),
          ← (fb _).map_split_add this j x, ← (fb _).map_split_add this j x]
        

Proof state:
case refine'_2
ι : Type u_1
M : Type u_2
n : ℕ
N : Type u_3
inst✝² : AddCommMonoid M
inst✝¹ : AddCommMonoid N
I₀✝ : WithTop (Box ι)
I J✝ : Box ι
i✝ : ι
G : Type u
inst✝ : AddCommGroup G
I₀ : Box (Fin (n + 1))
i : Fin (n + 1)
f : ℝ → Box (Fin n) → G
fb : ↑(Set.Icc (lower I₀ i) (upper I₀ i)) → Fin n →ᵇᵃ[↑(face I₀ i)] G
hf :
  ∀ (x : ℝ) (hx : x ∈ Set.Icc (lower I₀ i) (upper I₀ i)) (J : Box (Fin n)), f x J = (fb { val := x, property := hx }) J
J : Box (Fin (n + 1))
hJ : Box.Icc J ⊆ Set.pi Set.univ fun i => Set.Icc (lower I₀ i) (upper I₀ i)
j✝ : Fin (n + 1)
x : ℝ
j : Fin n
hx : x ∈ Set.Ioo (lower J (Fin.succAbove i j)) (upper J (Fin.succAbove i j))
this : ↑(face J i) ≤ ↑(face I₀ i)
⊢ Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i)) (splitLower J (Fin.succAbove i j) x) +
      Option.elim' 0 (fun J => f (upper J i) (face J i) - f (lower J i) (face J i))
        (splitUpper J (Fin.succAbove i j) x) =
    Option.elim' 0
          (⇑(fb { val := upper J i, property := (_ : upper J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitLower (face J i) j x) +
        Option.elim' 0
          (⇑(fb { val := upper J i, property := (_ : upper J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitUpper (face J i) j x) -
      (Option.elim' 0
          (⇑(fb { val := lower J i, property := (_ : lower J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitLower (face J i) j x) +
        Option.elim' 0
          (⇑(fb { val := lower J i, property := (_ : lower J i ∈ (fun i => Set.Icc (lower I₀ i) (upper I₀ i)) i) }))
          (splitUpper (face J i) j x))

Next tactic:
have hx' : x ∈ Ioo ((J.face i).lower j) ((J.face i).upper j) := hx
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
ha : ∀ (s : Finset ι), Finset.Nonempty s → s ≠ univ → card s < card (Finset.biUnion s t)
s' : Finset ↑{x' | x' ≠ x}
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
haveI := Classical.decEq ι
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
ha : ∀ (s : Finset ι), Finset.Nonempty s → s ≠ univ → card s < card (Finset.biUnion s t)
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
specialize ha (s'.image fun z => z.1)
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha :
  Finset.Nonempty (image (fun z => ↑z) s') →
    image (fun z => ↑z) s' ≠ univ → card (image (fun z => ↑z) s') < card (Finset.biUnion (image (fun z => ↑z) s') t)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
by_cases he : s'.Nonempty
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · 

Proof state:
case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)

Next tactic:
convert ha he fun h => by simpa [← h] using mem_univ x using 2
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by 

Proof state:
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
h : image (fun z => ↑z) s' = univ
⊢ False

Next tactic:
simpa [← h] using mem_univ x
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      

Proof state:
case h.e'_4.h.e'_2
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ (Finset.biUnion s' fun x_1 => t ↑x_1) = Finset.biUnion (image (fun z => ↑z) s') t

Next tactic:
ext x
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      

Proof state:
case h.e'_4.h.e'_2.a
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x✝ : ι
a : α
s' : Finset ↑{x' | x' ≠ x✝}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
x : α
⊢ (x ∈ Finset.biUnion s' fun x => t ↑x) ↔ x ∈ Finset.biUnion (image (fun z => ↑z) s') t

Next tactic:
simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
    

Proof state:
case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

Next tactic:
rw [← erase_biUnion]
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
    rw [← erase_biUnion]
    

Proof state:
case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

Next tactic:
by_cases hb : a ∈ s'.biUnion fun x => t x
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
    rw [← erase_biUnion]
    by_cases hb : a ∈ s'.biUnion fun x => t x
    · 

Proof state:
case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

Next tactic:
rw [card_erase_of_mem hb]
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
    rw [← erase_biUnion]
    by_cases hb : a ∈ s'.biUnion fun x => t x
    · rw [card_erase_of_mem hb]
      

Proof state:
case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (Finset.biUnion s' fun x_1 => t ↑x_1) - 1

Next tactic:
exact Nat.le_sub_one_of_lt ha'
theorem hall_cond_of_erase {x : ι} (a : α)
    (ha : ∀ s : Finset ι, s.Nonempty → s ≠ univ → s.card < (s.biUnion t).card)
    (s' : Finset { x' : ι | x' ≠ x }) : s'.card ≤ (s'.biUnion fun x' => (t x').erase a).card := by
  haveI := Classical.decEq ι
  specialize ha (s'.image fun z => z.1)
  rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
  by_cases he : s'.Nonempty
  · have ha' : s'.card < (s'.biUnion fun x => t x).card := by
      convert ha he fun h => by simpa [← h] using mem_univ x using 2
      ext x
      simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
        exists_eq_right, Subtype.coe_mk]
    rw [← erase_biUnion]
    by_cases hb : a ∈ s'.biUnion fun x => t x
    · rw [card_erase_of_mem hb]
      exact Nat.le_sub_one_of_lt ha'
    · 

Proof state:
case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : a ∉ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

Next tactic:
rw [erase_eq_of_not_mem hb]