l3lab/ntp-mathlib huggingface dataset:
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ rmap (corec parallel.aux1)
      (match (l, S) with
      | (l, S) =>
        rmap
          (fun l' =>
            match Seq.destruct S with
            | none => (l', Seq.nil)
            | some (none, S') => (l', S')
            | some (some c, S') => (c :: l', S'))
          (parallel.aux2 l)) =
    Sum.inl ?C.a
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

Next tactic:
dsimp only []
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ rmap (corec parallel.aux1)
      (rmap
        (fun l' =>
          match Seq.destruct S with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        (parallel.aux2 l)) =
    Sum.inl ?C.a
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

Next tactic:
rw [h]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ rmap (corec parallel.aux1)
      (rmap
        (fun l' =>
          match Seq.destruct S with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        (Sum.inl a)) =
    Sum.inl ?C.a
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

Next tactic:
simp only [rmap]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ Sum.inl a = Sum.inl ?C.a
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

Next tactic:
rfl
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · 

Proof state:
case zero.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (corec parallel.aux1 (l, S))

Next tactic:
rw [C]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      

Proof state:
case zero.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

Next tactic:
skip
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      

Proof state:
case zero.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

Next tactic:
infer_instance
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      infer_instance
    · 

Proof state:
case C
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ corec parallel.aux1 (l, S) = ?m.40060

Next tactic:
apply destruct_eq_think
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      infer_instance
    · apply destruct_eq_think
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ destruct (corec parallel.aux1 (l, S)) = Sum.inr ?C.s'
case C.s'
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

Next tactic:
simp only [corec_eq, rmap, parallel.aux1._eq_1]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      infer_instance
    · apply destruct_eq_think
      simp only [corec_eq, rmap, parallel.aux1._eq_1]
      

Proof state:
case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ (match
      match parallel.aux2 l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b =>
        Sum.inr
          (match Seq.destruct S with
          | none => (b, Seq.nil)
          | some (none, S') => (b, S')
          | some (some c, S') => (c :: b, S')) with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (corec parallel.aux1 b)) =
    Sum.inr ?C.s'
case C.s'
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

Next tactic:
rw [h, H]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      infer_instance
    · apply destruct_eq_think
      simp only [corec_eq, rmap, parallel.aux1._eq_1]
      rw [h, H]
    · 

Proof state:
case zero.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match some (some c, Seq.tail S) with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates (corec parallel.aux1 (l, S))

Next tactic:
rw [C]
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
    Terminates (parallel S) := by
  suffices
    ∀ (n) (l : List (Computation α)) (S c),
      c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
    from
    let ⟨n, h⟩ := h
    this n [] S c (Or.inr h) T
  intro n; induction' n with n IH <;> intro l S c o T
  · cases' o with a a
    · exact terminates_parallel.aux a T
    have H : Seq.destruct S = some (some c, _) := by
      dsimp [Seq.destruct, (· <$> ·)]
      rw [← a]
      simp
      rfl
    induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
    · -- Porting note: To adjust RHS of `C`, these lines are changed.
      apply destruct_eq_pure
      rw [corec_eq, parallel.aux1]
      dsimp only []
      rw [h]
      simp only [rmap]
      rfl
    · rw [C]
      skip
      infer_instance
    · apply destruct_eq_think
      simp only [corec_eq, rmap, parallel.aux1._eq_1]
      rw [h, H]
    · rw [C]
      

Proof state:
case zero.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝ : c✝ ∈ S✝
T✝ : Terminates c✝
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S Nat.zero
H : Seq.destruct S = some (some c, Seq.tail S)
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match some (some c, Seq.tail S) with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates
    (think
      (corec parallel.aux1
        (match some (some c, Seq.tail S) with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S'))))

Next tactic:
refine @Computation.think_terminates _ _ ?_