l3lab/ntp-mathlib huggingface dataset:
theorem Nontrivial.sdiff_singleton_nonempty {c : α} {s : Finset α} (hS : s.Nontrivial) :
    (s \ {c}).Nonempty := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t u v : Finset α
a b c : α
s : Finset α
hS : Finset.Nontrivial s
⊢ Finset.Nonempty (s \ {c})

Next tactic:
rw [Finset.sdiff_nonempty, Finset.subset_singleton_iff]
theorem Nontrivial.sdiff_singleton_nonempty {c : α} {s : Finset α} (hS : s.Nontrivial) :
    (s \ {c}).Nonempty := by
  rw [Finset.sdiff_nonempty, Finset.subset_singleton_iff]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t u v : Finset α
a b c : α
s : Finset α
hS : Finset.Nontrivial s
⊢ ¬(s = ∅ ∨ s = {c})

Next tactic:
push_neg
theorem Nontrivial.sdiff_singleton_nonempty {c : α} {s : Finset α} (hS : s.Nontrivial) :
    (s \ {c}).Nonempty := by
  rw [Finset.sdiff_nonempty, Finset.subset_singleton_iff]
  push_neg
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t u v : Finset α
a b c : α
s : Finset α
hS : Finset.Nontrivial s
⊢ s ≠ ∅ ∧ s ≠ {c}

Next tactic:
exact ⟨by rintro rfl; exact Finset.not_nontrivial_empty hS, hS.ne_singleton⟩
theorem Nontrivial.sdiff_singleton_nonempty {c : α} {s : Finset α} (hS : s.Nontrivial) :
    (s \ {c}).Nonempty := by
  rw [Finset.sdiff_nonempty, Finset.subset_singleton_iff]
  push_neg
  exact ⟨by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t u v : Finset α
a b c : α
s : Finset α
hS : Finset.Nontrivial s
⊢ s ≠ ∅

Next tactic:
rintro rfl
theorem Nontrivial.sdiff_singleton_nonempty {c : α} {s : Finset α} (hS : s.Nontrivial) :
    (s \ {c}).Nonempty := by
  rw [Finset.sdiff_nonempty, Finset.subset_singleton_iff]
  push_neg
  exact ⟨by rintro rfl; 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t u v : Finset α
a b c : α
hS : Finset.Nontrivial ∅
⊢ False

Next tactic:
exact Finset.not_nontrivial_empty hS
theorem sdiff_union_erase_cancel (hts : t ⊆ s) (ha : a ∈ t) : s \ t ∪ t.erase a = s.erase a := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t u v : Finset α
a b : α
hts : t ⊆ s
ha : a ∈ t
⊢ s \ t ∪ erase t a = erase s a

Next tactic:
simp_rw [erase_eq, sdiff_union_sdiff_cancel hts (singleton_subset_iff.2 ha)]
theorem sdiff_insert (s t : Finset α) (x : α) : s \ insert x t = (s \ t).erase x := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t✝ u v : Finset α
a b : α
s t : Finset α
x : α
⊢ s \ insert x t = erase (s \ t) x

Next tactic:
simp_rw [← sdiff_singleton_eq_erase, insert_eq, sdiff_sdiff_left', sdiff_union_distrib,
    inter_comm]
theorem sdiff_insert_insert_of_mem_of_not_mem {s t : Finset α} {x : α} (hxs : x ∈ s) (hxt : x ∉ t) :
    insert x (s \ insert x t) = s \ t := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t✝ u v : Finset α
a b : α
s t : Finset α
x : α
hxs : x ∈ s
hxt : x ∉ t
⊢ insert x (s \ insert x t) = s \ t

Next tactic:
rw [sdiff_insert, insert_erase (mem_sdiff.mpr ⟨hxs, hxt⟩)]
theorem sdiff_erase (h : a ∈ s) : s \ t.erase a = insert a (s \ t) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t u v : Finset α
a b : α
h : a ∈ s
⊢ s \ erase t a = insert a (s \ t)

Next tactic:
rw [← sdiff_singleton_eq_erase, sdiff_sdiff_eq_sdiff_union (singleton_subset_iff.2 h), insert_eq,
    union_comm]
theorem sdiff_erase_self (ha : a ∈ s) : s \ s.erase a = {a} := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t u v : Finset α
a b : α
ha : a ∈ s
⊢ s \ erase s a = {a}

Next tactic:
rw [sdiff_erase ha, Finset.sdiff_self, insert_emptyc_eq]
theorem erase_eq_empty_iff (s : Finset α) (a : α) : s.erase a = ∅ ↔ s = ∅ ∨ s = {a} := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s✝ t u v : Finset α
a✝ b : α
s : Finset α
a : α
⊢ erase s a = ∅ ↔ s = ∅ ∨ s = {a}

Next tactic:
rw [← sdiff_singleton_eq_erase, sdiff_eq_empty_iff_subset, subset_singleton_iff]
theorem mem_symmDiff : a ∈ s ∆ t ↔ a ∈ s ∧ a ∉ t ∨ a ∈ t ∧ a ∉ s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
a b : α
⊢ a ∈ s ∆ t ↔ a ∈ s ∧ a ∉ t ∨ a ∈ t ∧ a ∉ s

Next tactic:
simp_rw [symmDiff, sup_eq_union, mem_union, mem_sdiff]
@[simp, norm_cast]
theorem coe_symmDiff : (↑(s ∆ t) : Set α) = (s : Set α) ∆ t :=
  Set.ext fun x => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
a b x : α
⊢ x ∈ ↑(s ∆ t) ↔ x ∈ ↑s ∆ ↑t

Next tactic:
simp [mem_symmDiff, Set.mem_symmDiff]
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Finset α} (hx : x ∈ s) :
    SizeOf.sizeOf x < SizeOf.sizeOf s := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : SizeOf α
x : α
s : Finset α
hx : x ∈ s
⊢ sizeOf x < sizeOf s

Next tactic:
cases s
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Finset α} (hx : x ∈ s) :
    SizeOf.sizeOf x < SizeOf.sizeOf s := by
  cases s
  

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : SizeOf α
x : α
val✝ : Multiset α
nodup✝ : Nodup val✝
hx : x ∈ { val := val✝, nodup := nodup✝ }
⊢ sizeOf x < sizeOf { val := val✝, nodup := nodup✝ }

Next tactic:
dsimp [SizeOf.sizeOf, SizeOf.sizeOf, Multiset.sizeOf]
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Finset α} (hx : x ∈ s) :
    SizeOf.sizeOf x < SizeOf.sizeOf s := by
  cases s
  dsimp [SizeOf.sizeOf, SizeOf.sizeOf, Multiset.sizeOf]
  

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : SizeOf α
x : α
val✝ : Multiset α
nodup✝ : Nodup val✝
hx : x ∈ { val := val✝, nodup := nodup✝ }
⊢ sizeOf x <
    1 + Quot.liftOn val✝ (fun m => List._sizeOf_1 m) (_ : ∀ (x x_1 : List α), List.Perm x x_1 → sizeOf x = sizeOf x_1)

Next tactic:
rw [add_comm]
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Finset α} (hx : x ∈ s) :
    SizeOf.sizeOf x < SizeOf.sizeOf s := by
  cases s
  dsimp [SizeOf.sizeOf, SizeOf.sizeOf, Multiset.sizeOf]
  rw [add_comm]
  

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : SizeOf α
x : α
val✝ : Multiset α
nodup✝ : Nodup val✝
hx : x ∈ { val := val✝, nodup := nodup✝ }
⊢ sizeOf x <
    Quot.liftOn val✝ (fun m => List._sizeOf_1 m) (_ : ∀ (x x_1 : List α), List.Perm x x_1 → sizeOf x = sizeOf x_1) + 1

Next tactic:
refine' lt_trans _ (Nat.lt_succ_self _)
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Finset α} (hx : x ∈ s) :
    SizeOf.sizeOf x < SizeOf.sizeOf s := by
  cases s
  dsimp [SizeOf.sizeOf, SizeOf.sizeOf, Multiset.sizeOf]
  rw [add_comm]
  refine' lt_trans _ (Nat.lt_succ_self _)
  

Proof state:
case mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : SizeOf α
x : α
val✝ : Multiset α
nodup✝ : Nodup val✝
hx : x ∈ { val := val✝, nodup := nodup✝ }
⊢ sizeOf x <
    Quot.liftOn val✝ (fun m => List._sizeOf_1 m) (_ : ∀ (x x_1 : List α), List.Perm x x_1 → sizeOf x = sizeOf x_1)

Next tactic:
exact Multiset.sizeOf_lt_sizeOf_of_mem hx
@[simp]
theorem attach_nonempty_iff {s : Finset α} : s.attach.Nonempty ↔ s.Nonempty := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
s : Finset α
⊢ Finset.Nonempty (attach s) ↔ Finset.Nonempty s

Next tactic:
simp [Finset.Nonempty]
@[simp]
theorem attach_eq_empty_iff {s : Finset α} : s.attach = ∅ ↔ s = ∅ := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
s : Finset α
⊢ attach s = ∅ ↔ s = ∅

Next tactic:
simp [eq_empty_iff_forall_not_mem]
theorem piecewise_insert_self [DecidableEq α] {j : α} [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g j = f j := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
⊢ piecewise (insert j s) f g j = f j

Next tactic:
simp [piecewise]
@[simp]
theorem piecewise_empty [∀ i : α, Decidable (i ∈ (∅ : Finset α))] : piecewise ∅ f g = g := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (i : α) → Decidable (i ∈ ∅)
⊢ piecewise ∅ f g = g

Next tactic:
ext i
@[simp]
theorem piecewise_empty [∀ i : α, Decidable (i ∈ (∅ : Finset α))] : piecewise ∅ f g = g := by
  ext i
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (i : α) → Decidable (i ∈ ∅)
i : α
⊢ piecewise ∅ f g i = g i

Next tactic:
simp [piecewise]
@[norm_cast move]
theorem piecewise_coe [∀ j, Decidable (j ∈ (s : Set α))] :
    (s : Set α).piecewise f g = s.piecewise f g := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : (j : α) → Decidable (j ∈ ↑s)
⊢ Set.piecewise (↑s) f g = piecewise s f g

Next tactic:
ext
@[norm_cast move]
theorem piecewise_coe [∀ j, Decidable (j ∈ (s : Set α))] :
    (s : Set α).piecewise f g = s.piecewise f g := by
  ext
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : (j : α) → Decidable (j ∈ ↑s)
x✝ : α
⊢ Set.piecewise (↑s) f g x✝ = piecewise s f g x✝

Next tactic:
congr
@[simp]
theorem piecewise_eq_of_mem {i : α} (hi : i ∈ s) : s.piecewise f g i = f i := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (j : α) → Decidable (j ∈ s)
i : α
hi : i ∈ s
⊢ piecewise s f g i = f i

Next tactic:
simp [piecewise, hi]
@[simp]
theorem piecewise_eq_of_not_mem {i : α} (hi : i ∉ s) : s.piecewise f g i = g i := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (j : α) → Decidable (j ∈ s)
i : α
hi : i ∉ s
⊢ piecewise s f g i = g i

Next tactic:
simp [piecewise, hi]
@[simp]
theorem piecewise_insert_of_ne [DecidableEq α] {i j : α} [∀ i, Decidable (i ∈ insert j s)]
    (h : i ≠ j) : (insert j s).piecewise f g i = s.piecewise f g i := by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
i j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
h : i ≠ j
⊢ piecewise (insert j s) f g i = piecewise s f g i

Next tactic:
simp [piecewise, h]
theorem piecewise_insert [DecidableEq α] (j : α) [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = update (s.piecewise f g) j (f j) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
⊢ piecewise (insert j s) f g = update (piecewise s f g) j (f j)

Next tactic:
classical simp only [← piecewise_coe, coe_insert, ← Set.piecewise_insert]
theorem piecewise_insert [DecidableEq α] (j : α) [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = update (s.piecewise f g) j (f j) := by
  classical 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
⊢ piecewise (insert j s) f g = update (piecewise s f g) j (f j)

Next tactic:
simp only [← piecewise_coe, coe_insert, ← Set.piecewise_insert]
theorem piecewise_insert [DecidableEq α] (j : α) [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = update (s.piecewise f g) j (f j) := by
  classical simp only [← piecewise_coe, coe_insert, ← Set.piecewise_insert]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
⊢ Set.piecewise (↑(insert j s)) f g = Set.piecewise (insert j ↑s) f g

Next tactic:
ext
theorem piecewise_insert [DecidableEq α] (j : α) [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = update (s.piecewise f g) j (f j) := by
  classical simp only [← piecewise_coe, coe_insert, ← Set.piecewise_insert]
  ext
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
x✝ : α
⊢ Set.piecewise (↑(insert j s)) f g x✝ = Set.piecewise (insert j ↑s) f g x✝

Next tactic:
congr
theorem piecewise_insert [DecidableEq α] (j : α) [∀ i, Decidable (i ∈ insert j s)] :
    (insert j s).piecewise f g = update (s.piecewise f g) j (f j) := by
  classical simp only [← piecewise_coe, coe_insert, ← Set.piecewise_insert]
  ext
  congr
  

Proof state:
case h.e_s
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝² : (j : α) → Decidable (j ∈ s)
inst✝¹ : DecidableEq α
j : α
inst✝ : (i : α) → Decidable (i ∈ insert j s)
x✝ : α
⊢ ↑(insert j s) = insert j ↑s

Next tactic:
simp
theorem piecewise_cases {i} (p : δ i → Prop) (hf : p (f i)) (hg : p (g i)) :
    p (s.piecewise f g i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (j : α) → Decidable (j ∈ s)
i : α
p : δ i → Prop
hf : p (f i)
hg : p (g i)
⊢ p (piecewise s f g i)

Next tactic:
by_cases hi : i ∈ s
theorem piecewise_cases {i} (p : δ i → Prop) (hf : p (f i)) (hg : p (g i)) :
    p (s.piecewise f g i) := by
  by_cases hi : i ∈ s <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (j : α) → Decidable (j ∈ s)
i : α
p : δ i → Prop
hf : p (f i)
hg : p (g i)
hi : i ∈ s
⊢ p (piecewise s f g i)

Next tactic:
simpa [hi]
theorem piecewise_cases {i} (p : δ i → Prop) (hf : p (f i)) (hg : p (g i)) :
    p (s.piecewise f g i) := by
  by_cases hi : i ∈ s <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝ : (j : α) → Decidable (j ∈ s)
i : α
p : δ i → Prop
hf : p (f i)
hg : p (g i)
hi : i ∉ s
⊢ p (piecewise s f g i)

Next tactic:
simpa [hi]
theorem piecewise_mem_set_pi {δ : α → Type*} {t : Set α} {t' : ∀ i, Set (δ i)} {f g}
    (hf : f ∈ Set.pi t t') (hg : g ∈ Set.pi t t') : s.piecewise f g ∈ Set.pi t t' := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ✝ : α → Sort u_4
s : Finset α
f✝ g✝ : (i : α) → δ✝ i
inst✝ : (j : α) → Decidable (j ∈ s)
δ : α → Type u_5
t : Set α
t' : (i : α) → Set (δ i)
f g : (i : α) → δ i
hf : f ∈ Set.pi t t'
hg : g ∈ Set.pi t t'
⊢ piecewise s f g ∈ Set.pi t t'

Next tactic:
classical
    rw [← piecewise_coe]
    exact Set.piecewise_mem_pi (↑s) hf hg
theorem piecewise_mem_set_pi {δ : α → Type*} {t : Set α} {t' : ∀ i, Set (δ i)} {f g}
    (hf : f ∈ Set.pi t t') (hg : g ∈ Set.pi t t') : s.piecewise f g ∈ Set.pi t t' := by
  classical
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ✝ : α → Sort u_4
s : Finset α
f✝ g✝ : (i : α) → δ✝ i
inst✝ : (j : α) → Decidable (j ∈ s)
δ : α → Type u_5
t : Set α
t' : (i : α) → Set (δ i)
f g : (i : α) → δ i
hf : f ∈ Set.pi t t'
hg : g ∈ Set.pi t t'
⊢ piecewise s f g ∈ Set.pi t t'

Next tactic:
rw [← piecewise_coe]
theorem piecewise_mem_set_pi {δ : α → Type*} {t : Set α} {t' : ∀ i, Set (δ i)} {f g}
    (hf : f ∈ Set.pi t t') (hg : g ∈ Set.pi t t') : s.piecewise f g ∈ Set.pi t t' := by
  classical
    rw [← piecewise_coe]
    

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ✝ : α → Sort u_4
s : Finset α
f✝ g✝ : (i : α) → δ✝ i
inst✝ : (j : α) → Decidable (j ∈ s)
δ : α → Type u_5
t : Set α
t' : (i : α) → Set (δ i)
f g : (i : α) → δ i
hf : f ∈ Set.pi t t'
hg : g ∈ Set.pi t t'
⊢ Set.piecewise (↑s) f g ∈ Set.pi t t'

Next tactic:
exact Set.piecewise_mem_pi (↑s) hf hg
theorem piecewise_singleton [DecidableEq α] (i : α) : piecewise {i} f g = update g i (f i) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
⊢ piecewise {i} f g = update g i (f i)

Next tactic:
rw [← insert_emptyc_eq, piecewise_insert, piecewise_empty]
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
v : δ i
⊢ update (piecewise s f g) i v = piecewise s (update f i v) (update g i v)

Next tactic:
ext j
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  

Proof state:
case h
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
v : δ i
j : α
⊢ update (piecewise s f g) i v j = piecewise s (update f i v) (update g i v) j

Next tactic:
rcases em (j = i) with (rfl | hj)
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> 

Proof state:
case h.inl
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
j : α
v : δ j
⊢ update (piecewise s f g) j v j = piecewise s (update f j v) (update g j v) j

Next tactic:
by_cases hs : j ∈ s
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> 

Proof state:
case h.inr
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
v : δ i
j : α
hj : ¬j = i
⊢ update (piecewise s f g) i v j = piecewise s (update f i v) (update g i v) j

Next tactic:
by_cases hs : j ∈ s
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> by_cases hs : j ∈ s <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
j : α
v : δ j
hs : j ∈ s
⊢ update (piecewise s f g) j v j = piecewise s (update f j v) (update g j v) j

Next tactic:
simp [*]
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> by_cases hs : j ∈ s <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
j : α
v : δ j
hs : j ∉ s
⊢ update (piecewise s f g) j v j = piecewise s (update f j v) (update g j v) j

Next tactic:
simp [*]
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> by_cases hs : j ∈ s <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
v : δ i
j : α
hj : ¬j = i
hs : j ∈ s
⊢ update (piecewise s f g) i v j = piecewise s (update f i v) (update g i v) j

Next tactic:
simp [*]
theorem update_piecewise [DecidableEq α] (i : α) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) (update g i v) := by
  ext j
  rcases em (j = i) with (rfl | hj) <;> by_cases hs : j ∈ s <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
v : δ i
j : α
hj : ¬j = i
hs : j ∉ s
⊢ update (piecewise s f g) i v j = piecewise s (update f i v) (update g i v) j

Next tactic:
simp [*]
theorem update_piecewise_of_mem [DecidableEq α] {i : α} (hi : i ∈ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) g := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∈ s
v : δ i
⊢ update (piecewise s f g) i v = piecewise s (update f i v) g

Next tactic:
rw [update_piecewise]
theorem update_piecewise_of_mem [DecidableEq α] {i : α} (hi : i ∈ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) g := by
  rw [update_piecewise]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∈ s
v : δ i
⊢ piecewise s (update f i v) (update g i v) = piecewise s (update f i v) g

Next tactic:
refine' s.piecewise_congr (fun _ _ => rfl) fun j hj => update_noteq _ _ _
theorem update_piecewise_of_mem [DecidableEq α] {i : α} (hi : i ∈ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise (update f i v) g := by
  rw [update_piecewise]
  refine' s.piecewise_congr (fun _ _ => rfl) fun j hj => update_noteq _ _ _
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∈ s
v : δ i
j : α
hj : j ∉ s
⊢ j ≠ i

Next tactic:
exact fun h => hj (h.symm ▸ hi)
theorem update_piecewise_of_not_mem [DecidableEq α] {i : α} (hi : i ∉ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise f (update g i v) := by
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∉ s
v : δ i
⊢ update (piecewise s f g) i v = piecewise s f (update g i v)

Next tactic:
rw [update_piecewise]
theorem update_piecewise_of_not_mem [DecidableEq α] {i : α} (hi : i ∉ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise f (update g i v) := by
  rw [update_piecewise]
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∉ s
v : δ i
⊢ piecewise s (update f i v) (update g i v) = piecewise s f (update g i v)

Next tactic:
refine' s.piecewise_congr (fun j hj => update_noteq _ _ _) fun _ _ => rfl
theorem update_piecewise_of_not_mem [DecidableEq α] {i : α} (hi : i ∉ s) (v : δ i) :
    update (s.piecewise f g) i v = s.piecewise f (update g i v) := by
  rw [update_piecewise]
  refine' s.piecewise_congr (fun j hj => update_noteq _ _ _) fun _ _ => rfl
  

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ : α → Sort u_4
s : Finset α
f g : (i : α) → δ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
inst✝ : DecidableEq α
i : α
hi : i ∉ s
v : δ i
j : α
hj : j ∈ s
⊢ j ≠ i

Next tactic:
exact fun h => hi (h ▸ hj)
theorem piecewise_le_piecewise' {δ : α → Type*} [∀ i, Preorder (δ i)] {f g f' g' : ∀ i, δ i}
    (Hf : ∀ x ∈ s, f x ≤ f' x) (Hg : ∀ x ∉ s, g x ≤ g' x) :
    s.piecewise f g ≤ s.piecewise f' g' := fun x => by 

Proof state:
α : Type u_1
β : Type u_2
γ : Type u_3
δ✝ : α → Sort u_4
s : Finset α
f✝ g✝ : (i : α) → δ✝ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
δ : α → Type u_5
inst✝ : (i : α) → Preorder (δ i)
f g f' g' : (i : α) → δ i
Hf : ∀ x ∈ s, f x ≤ f' x
Hg : ∀ x ∉ s, g x ≤ g' x
x : α
⊢ piecewise s f g x ≤ piecewise s f' g' x

Next tactic:
by_cases hx : x ∈ s
theorem piecewise_le_piecewise' {δ : α → Type*} [∀ i, Preorder (δ i)] {f g f' g' : ∀ i, δ i}
    (Hf : ∀ x ∈ s, f x ≤ f' x) (Hg : ∀ x ∉ s, g x ≤ g' x) :
    s.piecewise f g ≤ s.piecewise f' g' := fun x => by by_cases hx : x ∈ s <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
γ : Type u_3
δ✝ : α → Sort u_4
s : Finset α
f✝ g✝ : (i : α) → δ✝ i
inst✝¹ : (j : α) → Decidable (j ∈ s)
δ : α → Type u_5
inst✝ : (i : α) → Preorder (δ i)
f g f' g' : (i : α) → δ i
Hf : ∀ x ∈ s, f x ≤ f' x
Hg : ∀ x ∉ s, g x ≤ g' x
x : α
hx : x ∈ s
⊢ piecewise s f g x ≤ piecewise s f' g' x

Next tactic:
simp [hx, *]