Theorem: Multiset.attach_ndinsert
File: Mathlib/Data/Multiset/FinsetOps.lean

tactic: intro t ht
state_before: α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
⊢ ∀ (t : Multiset α) (eq : ndinsert a s = t),
    attach t =
      ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: by_cases h : a ∈ s
state_before: α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
t : Multiset α
ht : ndinsert a s = t
⊢ attach t =
    ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: rw [ndinsert_of_mem h] at ht
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
t : Multiset α
ht : ndinsert a s = t
h : a ∈ s
⊢ attach t =
    ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: subst ht
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
t : Multiset α
ht✝ : ndinsert a s = t
ht : s = t
h : a ∈ s
⊢ attach t =
    ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: rw [eq, map_id, ndinsert_of_mem (mem_attach _ _)]
state_before: case pos
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
h : a ∈ s
ht : ndinsert a s = s
⊢ attach s =
    ndinsert { val := a, property := (_ : a ∈ s) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) (attach s))

tactic: rw [ndinsert_of_not_mem h] at ht
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
t : Multiset α
ht : ndinsert a s = t
h : ¬a ∈ s
⊢ attach t =
    ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: subst ht
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
t : Multiset α
ht✝ : ndinsert a s = t
ht : a ::ₘ s = t
h : ¬a ∈ s
⊢ attach t =
    ndinsert { val := a, property := (_ : a ∈ t) } (map (fun p => { val := ↑p, property := (_ : ↑p ∈ t) }) (attach s))

tactic: simp [attach_cons, h]
state_before: case neg
α : Type u_1
inst✝ : DecidableEq α
s✝ : Multiset α
a : α
s : Multiset α
eq : ∀ (h : ∀ (p : { x // x ∈ s }), ↑p ∈ s), (fun p => { val := ↑p, property := (_ : ↑p ∈ s) }) = id
h : ¬a ∈ s
ht : ndinsert a s = a ::ₘ s
⊢ attach (a ::ₘ s) =
    ndinsert { val := a, property := (_ : a ∈ a ::ₘ s) }
      (map (fun p => { val := ↑p, property := (_ : ↑p ∈ a ::ₘ s) }) (attach s))