Theorem: Computation.corec_eq
File: Mathlib/Data/Seq/Computation.lean

Proof steps:
state_before: α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
⊢ (corec f b).destruct = rmap (corec f) (f b)
state_after: α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
⊢ (match Stream'.corec' (Corec.f f) (Sum.inr b) 0 with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match f b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
tactic: dsimp [corec, destruct]
state_before: α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
⊢ (match Stream'.corec' (Corec.f f) (Sum.inr b) 0 with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match f b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
state_after: α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
⊢ (match Sum.rec some (fun x => none) (f b) with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match f b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
tactic: rw [show Stream'.corec' (Corec.f f) (Sum.inr b) 0 =
    Sum.rec Option.some (fun _ ↦ none) (f b) by
    dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.get, Stream'.iterate]
    match (f b) with
    | Sum.inl x => rfl
    | Sum.inr x => rfl
    ]
state_before: α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
⊢ (match Sum.rec some (fun x => none) (f b) with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match f b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
state_after: case inl
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b : β
a : α
h : f b = Sum.inl a
⊢ (match Sum.rec some (fun x => none) (Sum.inl a) with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match Sum.inl a with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩

case inr
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ (match Sum.rec some (fun x => none) (Sum.inr b') with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match Sum.inr b' with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
tactic: induction' h : f b with a b'
state_before: case inr
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ (match Sum.rec some (fun x => none) (Sum.inr b') with
    | none => Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩)
    | some a => Sum.inl a) =
    match Sum.inr b' with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩
state_after: case inr
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩) = Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
tactic: dsimp [Corec.f, destruct]
state_before: case inr
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Sum.inr (tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩) = Sum.inr ⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
state_after: case inr.h
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩ = ⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
tactic: apply congr_arg
state_before: case inr.h
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩ = ⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
state_after: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ ↑(tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩) = ↑⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
tactic: apply Subtype.eq
state_before: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ ↑(tail ⟨Stream'.corec' (Corec.f f) (Sum.inr b), ⋯⟩) = ↑⟨Stream'.corec' (Corec.f f) (Sum.inr b'), ⋯⟩
state_after: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ (Stream'.corec' (Corec.f f) (Sum.inr b)).tail = Stream'.corec' (Corec.f f) (Sum.inr b')
tactic: dsimp [corec, tail]
state_before: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ (Stream'.corec' (Corec.f f) (Sum.inr b)).tail = Stream'.corec' (Corec.f f) (Sum.inr b')
state_after: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Stream'.corec' (Corec.f f) (Corec.f f (Sum.inr b)).2 = Stream'.corec' (Corec.f f) (Sum.inr b')
tactic: rw [Stream'.corec'_eq, Stream'.tail_cons]
state_before: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Stream'.corec' (Corec.f f) (Corec.f f (Sum.inr b)).2 = Stream'.corec' (Corec.f f) (Sum.inr b')
state_after: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Stream'.corec' (Corec.f f) (f b) = Stream'.corec' (Corec.f f) (Sum.inr b')
tactic: dsimp [Corec.f]
state_before: case inr.h.a
α : Type u
β : Type v
γ : Type w
f : β → α ⊕ β
b b' : β
h : f b = Sum.inr b'
⊢ Stream'.corec' (Corec.f f) (f b) = Stream'.corec' (Corec.f f) (Sum.inr b')
state_after: no goals
tactic: rw [h]