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

tactic: simp only [destruct, Seq.destruct, Option.map_eq_map, ofSeq, Computation.corec_eq, rmap,
  Seq.head]
state_before: α : Type u
β : Type v
γ : Type w
s : Seq α
⊢ Computation.destruct (destruct ↑s) = Sum.inl (Option.map (fun a => (a, ↑(Seq.tail s))) (Seq.head s))

tactic: rw [show Seq.get? (some <$> s) 0 = some <$> Seq.get? s 0 by apply Seq.map_get?]
state_before: α : Type u
β : Type v
γ : Type w
s : Seq α
⊢ (match
      match Option.map (fun a' => (a', Seq.tail (some <$> s))) (Seq.get? (some <$> s) 0) with
      | none => Sum.inl none
      | some (none, s') => Sum.inr s'
      | some (some a, s') => Sum.inl (some (a, s')) with
    | Sum.inl a => Sum.inl a
    | Sum.inr b =>
      Sum.inr
        (Computation.corec
          (fun s =>
            match Option.map (fun a' => (a', Seq.tail s)) (Seq.get? s 0) with
            | none => Sum.inl none
            | some (none, s') => Sum.inr s'
            | some (some a, s') => Sum.inl (some (a, s')))
          b)) =
    Sum.inl (Option.map (fun a => (a, some <$> Seq.tail s)) (Seq.get? s 0))

tactic: cases' Seq.get? s 0 with a
state_before: α : Type u
β : Type v
γ : Type w
s : Seq α
⊢ (match
      match Option.map (fun a' => (a', Seq.tail (some <$> s))) (some <$> Seq.get? s 0) with
      | none => Sum.inl none
      | some (none, s') => Sum.inr s'
      | some (some a, s') => Sum.inl (some (a, s')) with
    | Sum.inl a => Sum.inl a
    | Sum.inr b =>
      Sum.inr
        (Computation.corec
          (fun s =>
            match Option.map (fun a' => (a', Seq.tail s)) (Seq.get? s 0) with
            | none => Sum.inl none
            | some (none, s') => Sum.inr s'
            | some (some a, s') => Sum.inl (some (a, s')))
          b)) =
    Sum.inl (Option.map (fun a => (a, some <$> Seq.tail s)) (Seq.get? s 0))

tactic: simp [destruct]
state_before: case some
α : Type u
β : Type v
γ : Type w
s : Seq α
a : α
⊢ (match
      match Option.map (fun a' => (a', Seq.tail (Seq.map some s))) (Option.map some (some a)) with
      | none => Sum.inl none
      | some (none, s') => Sum.inr s'
      | some (some a, s') => Sum.inl (some (a, s')) with
    | Sum.inl a => Sum.inl a
    | Sum.inr b =>
      Sum.inr
        (Computation.corec
          (fun s =>
            match Option.map (fun a' => (a', Seq.tail s)) (Seq.get? s 0) with
            | none => Sum.inl none
            | some (none, s') => Sum.inr s'
            | some (some a, s') => Sum.inl (some (a, s')))
          b)) =
    Sum.inl (Option.map (fun a => (a, Seq.map some (Seq.tail s))) (some a))

tactic: apply Seq.map_get?
state_before: α : Type u
β : Type v
γ : Type w
s : Seq α
⊢ Seq.get? (some <$> s) 0 = some <$> Seq.get? s 0

tactic: rfl
state_before: case none
α : Type u
β : Type v
γ : Type w
s : Seq α
⊢ (match
      match Option.map (fun a' => (a', Seq.tail (some <$> s))) (some <$> none) with
      | none => Sum.inl none
      | some (none, s') => Sum.inr s'
      | some (some a, s') => Sum.inl (some (a, s')) with
    | Sum.inl a => Sum.inl a
    | Sum.inr b =>
      Sum.inr
        (Computation.corec
          (fun s =>
            match Option.map (fun a' => (a', Seq.tail s)) (Seq.get? s 0) with
            | none => Sum.inl none
            | some (none, s') => Sum.inr s'
            | some (some a, s') => Sum.inl (some (a, s')))
          b)) =
    Sum.inl (Option.map (fun a => (a, some <$> Seq.tail s)) none)