Theorem: Stream'.WSeq.destruct_some_of_destruct_tail_some
File: Mathlib/Data/Seq/WSeq.lean

tactic: unfold tail Functor.map at h
state_before: α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ s.tail.destruct
⊢ ∃ a', some a' ∈ s.destruct
state_after: α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ (flatten (Applicative.toFunctor.1 (fun o => Option.recOn o nil Prod.snd) s.destruct)).destruct
⊢ ∃ a', some a' ∈ s.destruct

tactic: simp only [destruct_flatten] at h
state_before: α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ (flatten (Applicative.toFunctor.1 (fun o => Option.recOn o nil Prod.snd) s.destruct)).destruct
⊢ ∃ a', some a' ∈ s.destruct
state_after: α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct >>= destruct
⊢ ∃ a', some a' ∈ s.destruct

tactic: rcases exists_of_mem_bind h with ⟨t, tm, td⟩
state_before: α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct >>= destruct
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct >>= destruct
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
⊢ ∃ a', some a' ∈ s.destruct

tactic: clear h
state_before: case intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
h : some a ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct >>= destruct
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
⊢ ∃ a', some a' ∈ s.destruct

tactic: rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩
state_before: case intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
t' : Option (α × WSeq α)
ht' : t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd t' = t
⊢ ∃ a', some a' ∈ s.destruct

tactic: clear tm
state_before: case intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
tm : t ∈ Applicative.toFunctor.1 (fun o => Option.rec nil Prod.snd o) s.destruct
td : some a ∈ t.destruct
t' : Option (α × WSeq α)
ht' : t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd t' = t
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
td : some a ∈ t.destruct
t' : Option (α × WSeq α)
ht' : t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd t' = t
⊢ ∃ a', some a' ∈ s.destruct

tactic: cases' t' with t' <;> rw [← ht2] at td <;> simp only [destruct_nil] at td
state_before: case intro.intro.intro.intro
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
td : some a ∈ t.destruct
t' : Option (α × WSeq α)
ht' : t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd t' = t
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro.intro.intro.none
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
ht' : none ∈ s.destruct
ht2 : Option.rec nil Prod.snd none = t
td : some a ∈ Computation.pure none
⊢ ∃ a', some a' ∈ s.destruct

case intro.intro.intro.intro.some
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
t' : α × WSeq α
td : some a ∈ t'.2.destruct
ht' : some t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd (some t') = t
⊢ ∃ a', some a' ∈ s.destruct

tactic: have := mem_unique td (ret_mem _)
state_before: case intro.intro.intro.intro.none
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
ht' : none ∈ s.destruct
ht2 : Option.rec nil Prod.snd none = t
td : some a ∈ Computation.pure none
⊢ ∃ a', some a' ∈ s.destruct
state_after: case intro.intro.intro.intro.none
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
ht' : none ∈ s.destruct
ht2 : Option.rec nil Prod.snd none = t
td : some a ∈ Computation.pure none
this : some a = none
⊢ ∃ a', some a' ∈ s.destruct

tactic: contradiction
state_before: case intro.intro.intro.intro.none
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
ht' : none ∈ s.destruct
ht2 : Option.rec nil Prod.snd none = t
td : some a ∈ Computation.pure none
this : some a = none
⊢ ∃ a', some a' ∈ s.destruct
state_after: no goals

tactic: exact ⟨_, ht'⟩
state_before: case intro.intro.intro.intro.some
α : Type u
β : Type v
γ : Type w
s : WSeq α
a : α × WSeq α
t : WSeq α
t' : α × WSeq α
td : some a ∈ t'.2.destruct
ht' : some t' ∈ s.destruct
ht2 : Option.rec nil Prod.snd (some t') = t
⊢ ∃ a', some a' ∈ s.destruct
state_after: no goals