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

Proof steps:
state_before: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (cons a s).toList.destruct = Sum.inr (List.cons a <$> s.toList)
state_after: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (Computation.corec
        (fun x =>
          match x with
          | (l, s) =>
            match Seq.destruct s with
            | none => Sum.inl l.reverse
            | some (none, s') => Sum.inr (l, s')
            | some (some a, s') => Sum.inr (a :: l, s'))
        ([], cons a s)).destruct =
    Sum.inr
      (List.cons a <$>
        Computation.corec
          (fun x =>
            match x with
            | (l, s) =>
              match Seq.destruct s with
              | none => Sum.inl l.reverse
              | some (none, s') => Sum.inr (l, s')
              | some (some a, s') => Sum.inr (a :: l, s'))
          ([], s))
tactic: unfold toList
state_before: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (Computation.corec
        (fun x =>
          match x with
          | (l, s) =>
            match Seq.destruct s with
            | none => Sum.inl l.reverse
            | some (none, s') => Sum.inr (l, s')
            | some (some a, s') => Sum.inr (a :: l, s'))
        ([], cons a s)).destruct =
    Sum.inr
      (List.cons a <$>
        Computation.corec
          (fun x =>
            match x with
            | (l, s) =>
              match Seq.destruct s with
              | none => Sum.inl l.reverse
              | some (none, s') => Sum.inr (l, s')
              | some (some a, s') => Sum.inr (a :: l, s'))
          ([], s))
state_after: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ Computation.corec
      (fun x =>
        match Seq.destruct x.2 with
        | none => Sum.inl x.1.reverse
        | some (none, s') => Sum.inr (x.1, s')
        | some (some a, s') => Sum.inr (a :: x.1, s'))
      ([a], s) =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
tactic: simp only [toList'_cons, Computation.destruct_think, Sum.inr.injEq]
state_before: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ Computation.corec
      (fun x =>
        match Seq.destruct x.2 with
        | none => Sum.inl x.1.reverse
        | some (none, s') => Sum.inr (x.1, s')
        | some (some a, s') => Sum.inr (a :: x.1, s'))
      ([a], s) =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
state_after: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (fun x => [a].reverse ++ x) <$> s.toList =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
tactic: rw [toList'_map]
state_before: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (fun x => [a].reverse ++ x) <$> s.toList =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
state_after: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (fun x => a :: x) <$> s.toList =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
tactic: simp only [List.reverse_cons, List.reverse_nil, List.nil_append, List.singleton_append]
state_before: α : Type u
β : Type v
γ : Type w
a : α
s : WSeq α
⊢ (fun x => a :: x) <$> s.toList =
    List.cons a <$>
      Computation.corec
        (fun x =>
          match Seq.destruct x.2 with
          | none => Sum.inl x.1.reverse
          | some (none, s') => Sum.inr (x.1, s')
          | some (some a, s') => Sum.inr (a :: x.1, s'))
        ([], s)
state_after: no goals
tactic: rfl