Theorem: Computation.terminates_parallel
File: Mathlib/Data/Seq/Parallel.lean

tactic: 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
state_before: α : Type u
β : Type v
S : WSeq (Computation α)
c : Computation α
h : c ∈ S
T : Terminates c
⊢ Terminates (parallel S)

tactic: intro n
state_before: α : Type u
β : Type v
S : WSeq (Computation α)
c : Computation α
h : c ∈ S
T : Terminates c
⊢ ∀ (n : ℕ) (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))

tactic: induction' n with n IH <;> intro l S c o T
state_before: α : Type u
β : Type v
S : WSeq (Computation α)
c : Computation α
h : c ∈ S
T : Terminates c
n : ℕ
⊢ ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))

tactic: cases' o with a a
state_before: case zero
α : 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 α
o : c ∈ l ∨ some (some c) = Seq.get? S Nat.zero
T : Terminates c
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
state_before: case zero.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)
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: exact terminates_parallel.aux a T
state_before: case zero.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 : c ∈ l
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: rw [← a]
state_before: α : 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
⊢ Option.map (fun a' => (a', Seq.tail S)) (Seq.get? S 0) = some (some c, ?m.64769)

tactic: simp
state_before: α : 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
⊢ Option.map (fun a' => (a', Seq.tail S)) (some (some c)) = some (some c, ?m.64769)

α : 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
⊢ Stream'.Seq (Option (Computation α))

tactic: rfl
state_before: α : 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
⊢ (some c, Seq.tail S) = (some c, ?m.64769)

α : 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
⊢ Stream'.Seq (Option (Computation α))

tactic: apply destruct_eq_pure
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ corec parallel.aux1 (l, S) = ?m.67113

tactic: rw [corec_eq, parallel.aux1]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ destruct (corec parallel.aux1 (l, S)) = 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: dsimp only []
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rw [h]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: simp only [rmap]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rfl
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rw [C]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: skip
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

tactic: infer_instance
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

tactic: apply destruct_eq_think
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ corec parallel.aux1 (l, S) = ?m.67144

tactic: simp [parallel.aux1]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

tactic: rw [h, H]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

tactic: rw [C]
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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))

tactic: refine @Computation.think_terminates _ _ ?_
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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'))))

tactic: apply terminates_parallel.aux _ T
state_before: 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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
      (match some (some c, Seq.tail S) with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: simp
state_before: α : 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)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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')))
⊢ c ∈ c :: l'

tactic: cases' o with a a
state_before: case succ
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
o : c ∈ l ∨ some (some c) = Seq.get? S (Nat.succ n)
T : Terminates c
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
state_before: case succ.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: exact terminates_parallel.aux a T
state_before: case succ.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : c ∈ l
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: apply destruct_eq_pure
state_before: case C
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ corec parallel.aux1 (l, S) = ?m.73525

tactic: rw [corec_eq, parallel.aux1]
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ destruct (corec parallel.aux1 (l, S)) = Sum.inl ?C.a

case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: dsimp only []
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rw [h]
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: simp only [rmap]
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rfl
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ α

tactic: rw [C]
state_before: case succ.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: skip
state_before: case succ.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

tactic: infer_instance
state_before: case succ.inr.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a✝ : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
C : corec parallel.aux1 (l, S) = pure a
⊢ Terminates (pure a)

tactic: apply destruct_eq_think
state_before: case C
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ corec parallel.aux1 (l, S) = ?m.73556

tactic: simp [parallel.aux1]
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

tactic: rw [h]
state_before: case C.a
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
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✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Computation α

tactic: rw [C]
state_before: case succ.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates (corec parallel.aux1 (l, S))

tactic: refine @Computation.think_terminates _ _ ?_
state_before: case succ.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates
    (think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S'))))

tactic: have TT : ∀ l', Terminates (corec parallel.aux1 (l', S.tail)) := by
  intro
  apply IH _ _ _ (Or.inr _) T
  rw [a]
  cases' S with f al
  rfl
state_before: case succ.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: induction' e : Seq.get? S 0 with o
state_before: case succ.inr.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: intro
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))

tactic: apply IH _ _ _ (Or.inr _) T
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
l'✝ : List (Computation α)
⊢ Terminates (corec parallel.aux1 (l'✝, Seq.tail S))

tactic: rw [a]
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
l'✝ : List (Computation α)
⊢ some (some c) = Seq.get? (Seq.tail S) n

tactic: cases' S with f al
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
l'✝ : List (Computation α)
⊢ Seq.get? S (Nat.succ n) = Seq.get? (Seq.tail S) n

tactic: rfl
state_before: case mk
α : Type u
β : Type v
S : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
c : Computation α
T : Terminates c
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
l'✝ : List (Computation α)
f : Stream' (Option (Option (Computation α)))
al : IsSeq f
a : some (some c) = Seq.get? { val := f, property := al } (Nat.succ n)
C :
  corec parallel.aux1 (l, { val := f, property := al }) =
    think
      (corec parallel.aux1
        (match Seq.destruct { val := f, property := al } with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Seq.get? { val := f, property := al } (Nat.succ n) = Seq.get? (Seq.tail { val := f, property := al }) n

tactic: have D : Seq.destruct S = none := by
  dsimp [Seq.destruct]
  rw [e]
  rfl
state_before: case succ.inr.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: rw [D]
state_before: case succ.inr.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
D : Seq.destruct S = none
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: simp [parallel.aux1]
state_before: case succ.inr.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
D : Seq.destruct S = none
⊢ Terminates
    (corec parallel.aux1
      (match none with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: have TT := TT l'
state_before: case succ.inr.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
D : Seq.destruct S = none
⊢ Terminates (corec parallel.aux1 (l', Seq.nil))

tactic: rwa [Seq.destruct_eq_nil D, Seq.tail_nil] at TT
state_before: case succ.inr.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT✝ : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
D : Seq.destruct S = none
TT : Terminates (corec parallel.aux1 (l', Seq.tail S))
⊢ Terminates (corec parallel.aux1 (l', Seq.nil))

tactic: dsimp [Seq.destruct]
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
⊢ Seq.destruct S = none

tactic: rw [e]
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
⊢ Option.map (fun a' => (a', Seq.tail S)) (Seq.get? S 0) = none

tactic: rfl
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
e : Seq.get? S 0 = none
⊢ Option.map (fun a' => (a', Seq.tail S)) none = none

tactic: have D : Seq.destruct S = some (o, S.tail) := by
  dsimp [Seq.destruct]
  rw [e]
  rfl
state_before: case succ.inr.inr.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: rw [D]
state_before: case succ.inr.inr.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
D : Seq.destruct S = some (o, Seq.tail S)
⊢ Terminates
    (corec parallel.aux1
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: cases' o with c <;> simp [parallel.aux1, TT]
state_before: case succ.inr.inr.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
D : Seq.destruct S = some (o, Seq.tail S)
⊢ Terminates
    (corec parallel.aux1
      (match some (o, Seq.tail S) with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))

tactic: dsimp [Seq.destruct]
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
⊢ Seq.destruct S = some (o, Seq.tail S)

tactic: rw [e]
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
⊢ Option.map (fun a' => (a', Seq.tail S)) (Seq.get? S 0) = some (o, Seq.tail S)

tactic: rfl
state_before: α : Type u
β : Type v
S✝ : WSeq (Computation α)
c✝ : Computation α
h✝¹ : c✝ ∈ S✝
T✝ : Terminates c✝
n : ℕ
IH :
  ∀ (l : List (Computation α)) (S : Stream'.Seq (Option (Computation α))) (c : Computation α),
    c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : Stream'.Seq (Option (Computation α))
c : Computation α
T : Terminates c
a : some (some c) = Seq.get? S (Nat.succ n)
x✝¹ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝¹
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
C :
  corec parallel.aux1 (l, S) =
    think
      (corec parallel.aux1
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
TT : ∀ (l' : List (Computation α)), Terminates (corec parallel.aux1 (l', Seq.tail S))
x✝ : Option (Option (Computation α))
e✝ : Seq.get? S 0 = x✝
o : Option (Computation α)
e : Seq.get? S 0 = some o
⊢ Option.map (fun a' => (a', Seq.tail S)) (some o) = some (o, Seq.tail S)