[GOAL]
α : Type u
β : Type v
⊢ ∀ {l : List (Computation α)} {S : WSeq (Computation α)} {c : Computation α},
    c ∈ l → Terminates c → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have lem1 : ∀ l S, (∃ a : α, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S)) :=
  by
  intro l S e
  cases' e with a e
  have : corec parallel.aux1 (l, S) = return a :=
    by
    apply destruct_eq_pure
    simp [parallel.aux1]
    rw [e]
  rw [this]
    -- Porting note: This line is required.
  exact ret_terminates a
[GOAL]
α : Type u
β : Type v
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro l S e
[GOAL]
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
e : ∃ a, parallel.aux2 l = Sum.inl a
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
cases' e with a e
[GOAL]
case intro
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have : corec parallel.aux1 (l, S) = return a := by
  apply destruct_eq_pure
  simp [parallel.aux1]
  rw [e]
[GOAL]
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
⊢ corec parallel.aux1 (l, S) = Pure.pure a
[PROOFSTEP]
apply destruct_eq_pure
[GOAL]
case a
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
⊢ destruct (corec parallel.aux1 (l, S)) = Sum.inl a
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
case a
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
⊢ (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
          (fun x =>
            match parallel.aux2 x.fst with
            | Sum.inl a => Sum.inl a
            | Sum.inr b =>
              Sum.inr
                (match Seq.destruct x.snd with
                | none => (b, Seq.nil)
                | some (none, S') => (b, S')
                | some (some c, S') => (c :: b, S')))
          b)) =
    Sum.inl a
[PROOFSTEP]
rw [e]
[GOAL]
case intro
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
this : corec parallel.aux1 (l, S) = Pure.pure a
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
rw [this]
  -- Porting note: This line is required.
[GOAL]
case intro
α : Type u
β : Type v
l : List (Computation α)
S : WSeq (Computation α)
a : α
e : parallel.aux2 l = Sum.inl a
this : corec parallel.aux1 (l, S) = Pure.pure a
⊢ Terminates (Pure.pure a)
[PROOFSTEP]
exact ret_terminates a
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
⊢ ∀ {l : List (Computation α)} {S : WSeq (Computation α)} {c : Computation α},
    c ∈ l → Terminates c → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro l S c m T
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
c : Computation α
m : c ∈ l
T : Terminates c
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
revert l S
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
⊢ ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, c ∈ l → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
apply @terminatesRecOn _ _ c T _ _
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
⊢ ∀ (a : α) {l : List (Computation α)} {S : WSeq (Computation α)}, pure a ∈ l → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro a l S m
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
a : α
l : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
apply lem1
[GOAL]
case a
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
a : α
l : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l
⊢ ∃ a, parallel.aux2 l = Sum.inl a
[PROOFSTEP]
induction' l with c l IH
[GOAL]
case a.nil
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
a : α
l : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l
m : pure a ∈ []
⊢ ∃ a, parallel.aux2 [] = Sum.inl a
[PROOFSTEP]
simp at m
[GOAL]
case a.cons
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ c :: l
⊢ ∃ a, parallel.aux2 (c :: l) = Sum.inl a
[PROOFSTEP]
simp at m
[GOAL]
case a.cons
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a = c ∨ pure a ∈ l
⊢ ∃ a, parallel.aux2 (c :: l) = Sum.inl a
[PROOFSTEP]
cases' m with e m
[GOAL]
case a.cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
e : pure a = c
⊢ ∃ a, parallel.aux2 (c :: l) = Sum.inl a
[PROOFSTEP]
rw [← e]
[GOAL]
case a.cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
e : pure a = c
⊢ ∃ a_1, parallel.aux2 (pure a :: l) = Sum.inl a_1
[PROOFSTEP]
simp [parallel.aux2]
[GOAL]
case a.cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
e : pure a = c
⊢ ∃ a_1,
    (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => Sum.inl a) =
      Sum.inl a_1
[PROOFSTEP]
cases'
  List.foldr
    (fun c o =>
      match o with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (Sum.inr List.nil) l with
  a' ls
[GOAL]
case a.cons.inl.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
e : pure a = c
a' : α
⊢ ∃ a_1,
    (match Sum.inl a' with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => Sum.inl a) =
      Sum.inl a_1
case a.cons.inl.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
e : pure a = c
ls : List (Computation α)
⊢ ∃ a_1,
    (match Sum.inr ls with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => Sum.inl a) =
      Sum.inl a_1
[PROOFSTEP]
exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
[GOAL]
case a.cons.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ l
⊢ ∃ a, parallel.aux2 (c :: l) = Sum.inl a
[PROOFSTEP]
cases' IH m with a' e
[GOAL]
case a.cons.inr.intro
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ l
a' : α
e : parallel.aux2 l = Sum.inl a'
⊢ ∃ a, parallel.aux2 (c :: l) = Sum.inl a
[PROOFSTEP]
simp [parallel.aux2]
[GOAL]
case a.cons.inr.intro
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ l
a' : α
e : parallel.aux2 l = Sum.inl a'
⊢ ∃ a,
    (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct c with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inl a
[PROOFSTEP]
simp [parallel.aux2] at e
[GOAL]
case a.cons.inr.intro
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ l
a' : α
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) l =
    Sum.inl a'
⊢ ∃ a,
    (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct c with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inl a
[PROOFSTEP]
rw [e]
[GOAL]
case a.cons.inr.intro
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
a : α
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : pure a ∈ l✝
c : Computation α
l : List (Computation α)
IH : pure a ∈ l → ∃ a, parallel.aux2 l = Sum.inl a
m : pure a ∈ l
a' : α
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) l =
    Sum.inl a'
⊢ ∃ a,
    (match Sum.inl a' with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct c with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inl a
[PROOFSTEP]
exact ⟨a', rfl⟩
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
⊢ ∀ (s : Computation α),
    (∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))) →
      ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, think s ∈ l → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro s IH l S m
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have H1 : ∀ l', parallel.aux2 l = Sum.inr l' → s ∈ l' :=
  by
  induction' l with c l IH' <;> intro l' e' <;> simp at m
  cases' m with e m <;> simp [parallel.aux2] at e'
  · rw [← e] at e'
    revert e'
    cases'
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
          a' ls <;>
        intro e' <;>
      [injection e'; injection e' with e']
    rw [← e']
    simp
  · induction' e :
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
          (Sum.inr List.nil) l with
        a' ls <;> erw [e] at e'
    · contradiction
    have := IH' m _ e
    simp [parallel.aux2] at e'
    revert e'
    cases destruct c <;> intro e' <;> [injection e'; injection e' with h']
    rw [← h']
    simp [this]
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
⊢ ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
[PROOFSTEP]
induction' l with c l IH'
[GOAL]
case nil
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l
m : think s ∈ []
⊢ ∀ (l' : List (Computation α)), parallel.aux2 [] = Sum.inr l' → s ∈ l'
[PROOFSTEP]
intro l' e'
[GOAL]
case cons
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
m : think s ∈ c :: l
⊢ ∀ (l' : List (Computation α)), parallel.aux2 (c :: l) = Sum.inr l' → s ∈ l'
[PROOFSTEP]
intro l' e'
[GOAL]
case nil
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l
m : think s ∈ []
l' : List (Computation α)
e' : parallel.aux2 [] = Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
simp at m
[GOAL]
case cons
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
m : think s ∈ c :: l
l' : List (Computation α)
e' : parallel.aux2 (c :: l) = Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
simp at m
[GOAL]
case cons
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' : parallel.aux2 (c :: l) = Sum.inr l'
m : think s = c ∨ think s ∈ l
⊢ s ∈ l'
[PROOFSTEP]
cases' m with e m
[GOAL]
case cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' : parallel.aux2 (c :: l) = Sum.inr l'
e : think s = c
⊢ s ∈ l'
[PROOFSTEP]
simp [parallel.aux2] at e'
[GOAL]
case cons.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' : parallel.aux2 (c :: l) = Sum.inr l'
m : think s ∈ l
⊢ s ∈ l'
[PROOFSTEP]
simp [parallel.aux2] at e'
[GOAL]
case cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' :
  (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e : think s = c
⊢ s ∈ l'
[PROOFSTEP]
rw [← e] at e'
[GOAL]
case cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' :
  (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct (think s) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e : think s = c
⊢ s ∈ l'
[PROOFSTEP]
revert e'
[GOAL]
case cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
⊢ (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct (think s) with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
cases'
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
        (Sum.inr []) l with
      a' ls <;>
    intro e' <;>
  [injection e'; injection e' with e']
[GOAL]
case cons.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
⊢ (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct (think s) with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
cases'
  List.foldr
    (fun c o =>
      match o with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (Sum.inr []) l with
  a' ls
[GOAL]
case cons.inl.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
a' : α
⊢ (match Sum.inl a' with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct (think s) with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
intro e'
[GOAL]
case cons.inl.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
ls : List (Computation α)
⊢ (match Sum.inr ls with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls =>
        match destruct (think s) with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
intro e'
[GOAL]
case cons.inl.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
a' : α
e' :
  (match Sum.inl a' with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct (think s) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
injection e'
[GOAL]
case cons.inl.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
ls : List (Computation α)
e' :
  (match Sum.inr ls with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct (think s) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
injection e' with e'
[GOAL]
case cons.inl.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
ls : List (Computation α)
e' : tail (think s) :: ls = l'
⊢ s ∈ l'
[PROOFSTEP]
rw [← e']
[GOAL]
case cons.inl.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e : think s = c
ls : List (Computation α)
e' : tail (think s) :: ls = l'
⊢ s ∈ tail (think s) :: ls
[PROOFSTEP]
simp
[GOAL]
case cons.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' :
  (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
m : think s ∈ l
⊢ s ∈ l'
[PROOFSTEP]
induction' e :
  List.foldr
    (fun c o =>
      match o with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (Sum.inr List.nil) l with
  a' ls
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' :
  (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
a' : α
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inl a'
⊢ s ∈ l'
[PROOFSTEP]
erw [e] at e'
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
e' :
  (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
⊢ s ∈ l'
[PROOFSTEP]
erw [e] at e'
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
a' : α
e' :
  (match Sum.inl a' with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inl a'
⊢ s ∈ l'
[PROOFSTEP]
contradiction
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e' :
  (match Sum.inr ls with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
⊢ s ∈ l'
[PROOFSTEP]
have := IH' m _ e
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e' :
  (match Sum.inr ls with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
⊢ s ∈ l'
[PROOFSTEP]
simp [parallel.aux2] at e'
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e' :
  (match destruct c with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
⊢ s ∈ l'
[PROOFSTEP]
revert e'
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
⊢ (match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
cases destruct c <;> intro e' <;> [injection e'; injection e' with h']
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
⊢ (match destruct c with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
cases destruct c
[GOAL]
case cons.inr.inr.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : α
⊢ (match Sum.inl val✝ with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
intro e'
[GOAL]
case cons.inr.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : Computation α
⊢ (match Sum.inr val✝ with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
      Sum.inr l' →
    s ∈ l'
[PROOFSTEP]
intro e'
[GOAL]
case cons.inr.inr.inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : α
e' :
  (match Sum.inl val✝ with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
injection e'
[GOAL]
case cons.inr.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : Computation α
e' :
  (match Sum.inr val✝ with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: ls)) =
    Sum.inr l'
⊢ s ∈ l'
[PROOFSTEP]
injection e' with h'
[GOAL]
case cons.inr.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : Computation α
h' : val✝ :: ls = l'
⊢ s ∈ l'
[PROOFSTEP]
rw [← h']
[GOAL]
case cons.inr.inr.inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l✝ : List (Computation α)
S : WSeq (Computation α)
m✝ : think s ∈ l✝
c : Computation α
l : List (Computation α)
IH' : think s ∈ l → ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
l' : List (Computation α)
m : think s ∈ l
x✝ : α ⊕ List (Computation α)
e✝ :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    x✝
ls : List (Computation α)
e :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l =
    Sum.inr ls
this : s ∈ ls
val✝ : Computation α
h' : val✝ :: ls = l'
⊢ s ∈ val✝ :: ls
[PROOFSTEP]
simp [this]
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
induction' h : parallel.aux2 l with a l'
[GOAL]
case inl
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
a : α
h : parallel.aux2 l = Sum.inl a
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
exact lem1 _ _ ⟨a, h⟩
[GOAL]
case inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have H2 : corec parallel.aux1 (l, S) = think _ :=
  by
  apply destruct_eq_think
  simp [parallel.aux1]
  rw [h]
[GOAL]
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
⊢ corec parallel.aux1 (l, S) = think ?m.50541
[PROOFSTEP]
apply destruct_eq_think
[GOAL]
case a
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
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 ?m.50541
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
case a
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
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
          (fun x =>
            match parallel.aux2 x.fst with
            | Sum.inl a => Sum.inl a
            | Sum.inr b =>
              Sum.inr
                (match Seq.destruct x.snd with
                | none => (b, Seq.nil)
                | some (none, S') => (b, S')
                | some (some c, S') => (c :: b, S')))
          b)) =
    Sum.inr ?m.50541
[PROOFSTEP]
rw [h]
[GOAL]
case inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (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))
[PROOFSTEP]
rw [H2]
[GOAL]
case inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates
    (think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S'))))
[PROOFSTEP]
refine @Computation.think_terminates _ _ ?_
[GOAL]
case inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
have := H1 _ h
[GOAL]
case inr
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (match Seq.destruct S with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
rcases Seq.destruct S with (_ | ⟨_ | c, S'⟩)
[GOAL]
case inr.none
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (match none with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
case inr.some.mk.none
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (match some (none, S') with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
case inr.some.mk.some
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
c : Computation α
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (match some (some c, S') with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
case inr.none
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (l', Seq.nil))
[PROOFSTEP]
apply IH
[GOAL]
case inr.some.mk.none
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (l', S'))
[PROOFSTEP]
apply IH
[GOAL]
case inr.some.mk.some
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
c : Computation α
⊢ Terminates
    (corec
      (fun x =>
        match parallel.aux2 x.fst with
        | Sum.inl a => Sum.inl a
        | Sum.inr b =>
          Sum.inr
            (match Seq.destruct x.snd with
            | none => (b, Seq.nil)
            | some (none, S') => (b, S')
            | some (some c, S') => (c :: b, S')))
      (c :: l', S'))
[PROOFSTEP]
apply IH
[GOAL]
case inr.none.m
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
⊢ s ∈ l'
[PROOFSTEP]
simp [this]
[GOAL]
case inr.some.mk.none.m
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c : Computation α
T : Terminates c
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
⊢ s ∈ l'
[PROOFSTEP]
simp [this]
[GOAL]
case inr.some.mk.some.m
α : Type u
β : Type v
lem1 :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    (∃ a, parallel.aux2 l = Sum.inl a) → Terminates (corec parallel.aux1 (l, S))
c✝ : Computation α
T : Terminates c✝
s : Computation α
IH : ∀ {l : List (Computation α)} {S : WSeq (Computation α)}, s ∈ l → Terminates (corec parallel.aux1 (l, S))
l : List (Computation α)
S : WSeq (Computation α)
m : think s ∈ l
H1 : ∀ (l' : List (Computation α)), parallel.aux2 l = Sum.inr l' → s ∈ l'
x✝ : α ⊕ List (Computation α)
h✝ : parallel.aux2 l = x✝
l' : List (Computation α)
h : parallel.aux2 l = Sum.inr l'
H2 :
  corec parallel.aux1 (l, S) =
    think
      (corec
        (fun x =>
          match parallel.aux2 x.fst with
          | Sum.inl a => Sum.inl a
          | Sum.inr b =>
            Sum.inr
              (match Seq.destruct x.snd with
              | none => (b, Seq.nil)
              | some (none, S') => (b, S')
              | some (some c, S') => (c :: b, S')))
        (match Seq.destruct S with
        | none => (l', Seq.nil)
        | some (none, S') => (l', S')
        | some (some c, S') => (c :: l', S')))
this : s ∈ l'
S' : Stream'.Seq (Option (Computation α))
c : Computation α
⊢ s ∈ c :: l'
[PROOFSTEP]
simp [this]
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
c : Computation α
h : c ∈ S
T : Terminates c
⊢ Terminates (parallel S)
[PROOFSTEP]
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
[GOAL]
α : 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))
[PROOFSTEP]
intro n
[GOAL]
α : 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))
[PROOFSTEP]
induction' n with n IH
[GOAL]
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 α),
    c ∈ l ∨ some (some c) = Seq.get? S Nat.zero → Terminates c → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro l S c o T
[GOAL]
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 α),
    c ∈ l ∨ some (some c) = Seq.get? S (Nat.succ n) → Terminates c → Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
intro l S c o T
[GOAL]
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))
[PROOFSTEP]
cases' o with a a
[GOAL]
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))
[PROOFSTEP]
exact terminates_parallel.aux a T
[GOAL]
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
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have H : Seq.destruct S = some (some c, _) :=
  by
  dsimp [Seq.destruct, (· <$> ·)]
  rw [← a]
  simp
  rfl
[GOAL]
α : 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
⊢ Seq.destruct S = some (some c, ?m.63808)
[PROOFSTEP]
dsimp [Seq.destruct, (· <$> ·)]
[GOAL]
α : 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.63808)
[PROOFSTEP]
rw [← a]
[GOAL]
α : 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.63808)
α : 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 α))
[PROOFSTEP]
simp
[GOAL]
α : 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.63808)
α : 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 α))
[PROOFSTEP]
rfl
[GOAL]
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))
[PROOFSTEP]
induction' h : parallel.aux2 l with a l'
[GOAL]
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
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have C : corec parallel.aux1 (l, S) = _
[GOAL]
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'
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have C : corec parallel.aux1 (l, S) = _
[GOAL]
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.66152
[PROOFSTEP]
apply destruct_eq_pure
[GOAL]
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
⊢ α
[PROOFSTEP]
rw [corec_eq, parallel.aux1]
[GOAL]
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
⊢ α
[PROOFSTEP]
dsimp only []
[GOAL]
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
⊢ α
[PROOFSTEP]
rw [h]
[GOAL]
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
⊢ α
[PROOFSTEP]
simp only [rmap]
[GOAL]
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
⊢ α
[PROOFSTEP]
rfl
[GOAL]
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))
[PROOFSTEP]
rw [C]
[GOAL]
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)
[PROOFSTEP]
skip
[GOAL]
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)
[PROOFSTEP]
infer_instance
[GOAL]
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.66183
[PROOFSTEP]
apply destruct_eq_think
[GOAL]
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 α
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
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 α
[PROOFSTEP]
rw [h, H]
[GOAL]
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))
[PROOFSTEP]
rw [C]
[GOAL]
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'))))
[PROOFSTEP]
refine @Computation.think_terminates _ _ ?_
[GOAL]
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')))
[PROOFSTEP]
apply terminates_parallel.aux _ T
[GOAL]
α : 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'
[PROOFSTEP]
simp
[GOAL]
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))
[PROOFSTEP]
cases' o with a a
[GOAL]
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))
[PROOFSTEP]
exact terminates_parallel.aux a T
[GOAL]
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))
[PROOFSTEP]
induction' h : parallel.aux2 l with a l'
[GOAL]
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
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have C : corec parallel.aux1 (l, S) = _
[GOAL]
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'
⊢ Terminates (corec parallel.aux1 (l, S))
[PROOFSTEP]
have C : corec parallel.aux1 (l, S) = _
[GOAL]
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.72564
[PROOFSTEP]
apply destruct_eq_pure
[GOAL]
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
⊢ α
[PROOFSTEP]
rw [corec_eq, parallel.aux1]
[GOAL]
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
⊢ α
[PROOFSTEP]
dsimp only []
[GOAL]
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
⊢ α
[PROOFSTEP]
rw [h]
[GOAL]
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
⊢ α
[PROOFSTEP]
simp only [rmap]
[GOAL]
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
⊢ α
[PROOFSTEP]
rfl
[GOAL]
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))
[PROOFSTEP]
rw [C]
[GOAL]
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)
[PROOFSTEP]
skip
[GOAL]
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)
[PROOFSTEP]
infer_instance
[GOAL]
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.72595
[PROOFSTEP]
apply destruct_eq_think
[GOAL]
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 α
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
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 α
[PROOFSTEP]
rw [h]
[GOAL]
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))
[PROOFSTEP]
rw [C]
[GOAL]
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'))))
[PROOFSTEP]
refine @Computation.think_terminates _ _ ?_
[GOAL]
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')))
[PROOFSTEP]
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
[GOAL]
α : 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))
[PROOFSTEP]
intro
[GOAL]
α : 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))
[PROOFSTEP]
apply IH _ _ _ (Or.inr _) T
[GOAL]
α : 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
[PROOFSTEP]
rw [a]
[GOAL]
α : 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
[PROOFSTEP]
cases' S with f al
[GOAL]
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
[PROOFSTEP]
rfl
[GOAL]
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')))
[PROOFSTEP]
induction' e : Seq.get? S 0 with o
[GOAL]
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')))
[PROOFSTEP]
have D : Seq.destruct S = none := by
  dsimp [Seq.destruct]
  rw [e]
  rfl
[GOAL]
α : 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
[PROOFSTEP]
dsimp [Seq.destruct]
[GOAL]
α : 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
[PROOFSTEP]
rw [e]
[GOAL]
α : 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
[PROOFSTEP]
rfl
[GOAL]
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')))
[PROOFSTEP]
rw [D]
[GOAL]
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')))
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
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))
[PROOFSTEP]
have TT := TT l'
[GOAL]
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))
[PROOFSTEP]
rwa [Seq.destruct_eq_nil D, Seq.tail_nil] at TT
[GOAL]
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')))
[PROOFSTEP]
have D : Seq.destruct S = some (o, S.tail) := by
  dsimp [Seq.destruct]
  rw [e]
  rfl
[GOAL]
α : 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)
[PROOFSTEP]
dsimp [Seq.destruct]
[GOAL]
α : 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)
[PROOFSTEP]
rw [e]
[GOAL]
α : 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)
[PROOFSTEP]
rfl
[GOAL]
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')))
[PROOFSTEP]
rw [D]
[GOAL]
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')))
[PROOFSTEP]
cases' o with c
[GOAL]
case succ.inr.inr.some.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 = some none
D : Seq.destruct S = some (none, Seq.tail S)
⊢ Terminates
    (corec parallel.aux1
      (match some (none, Seq.tail S) with
      | none => (l', Seq.nil)
      | some (none, S') => (l', S')
      | some (some c, S') => (c :: l', S')))
[PROOFSTEP]
simp [parallel.aux1, TT]
[GOAL]
case succ.inr.inr.some.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✝
c : Computation α
e : Seq.get? S 0 = some (some c)
D : Seq.destruct S = some (some c, Seq.tail 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')))
[PROOFSTEP]
simp [parallel.aux1, TT]
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
⊢ ∃ c, c ∈ S ∧ a ∈ c
[PROOFSTEP]
suffices ∀ C, a ∈ C → ∀ (l : List (Computation α)) (S), corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
  from
  let ⟨c, h1, h2⟩ := this _ h [] S rfl
  ⟨c, h1.resolve_left <| List.not_mem_nil _, h2⟩
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
⊢ ∀ (C : Computation α),
    a ∈ C →
      ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
        corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
let F : List (Computation α) → Sum α (List (Computation α)) → Prop :=
  by
  intro l a
  cases' a with a l'
  exact ∃ c ∈ l, a ∈ c
  exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
⊢ List (Computation α) → α ⊕ List (Computation α) → Prop
[PROOFSTEP]
intro l a
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
l : List (Computation α)
a : α ⊕ List (Computation α)
⊢ Prop
[PROOFSTEP]
cases' a with a l'
[GOAL]
case inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
l : List (Computation α)
a : α
⊢ Prop
case inr α : Type u β : Type v S : WSeq (Computation α) a : α h : a ∈ parallel S l l' : List (Computation α) ⊢ Prop
[PROOFSTEP]
exact ∃ c ∈ l, a ∈ c
[GOAL]
case inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
l l' : List (Computation α)
⊢ Prop
[PROOFSTEP]
exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
⊢ ∀ (C : Computation α),
    a ∈ C →
      ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
        corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
have lem1 : ∀ l : List (Computation α), F l (parallel.aux2 l) :=
  by
  intro l
  induction' l with c l IH <;> simp only [parallel.aux2, List.foldr]
  · intro a h
    rcases h with ⟨c, hn, _⟩
    exact False.elim <| List.not_mem_nil _ hn
  · simp only [parallel.aux2] at IH
    revert IH
    cases'
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr List.nil) l with
          a ls <;>
        intro IH <;>
      simp only [parallel.aux2]
    · rcases IH with ⟨c', cl, ac⟩
      refine' ⟨c', List.Mem.tail _ cl, ac⟩
    · induction' h : destruct c with a c' <;> simp only [rmap]
      · refine' ⟨c, List.mem_cons_self _ _, _⟩
        rw [destruct_eq_pure h]
        apply ret_mem
      · intro a' h
        rcases h with ⟨d, dm, ad⟩
        simp at dm
        cases' dm with e dl
        · rw [e] at ad
          refine' ⟨c, List.mem_cons_self _ _, _⟩
          rw [destruct_eq_think h]
          exact think_mem ad
        · cases' IH a' ⟨d, dl, ad⟩ with d dm
          cases' dm with dm ad
          exact ⟨d, List.Mem.tail _ dm, ad⟩
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
⊢ ∀ (l : List (Computation α)), F l (parallel.aux2 l)
[PROOFSTEP]
intro l
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
l : List (Computation α)
⊢ F l (parallel.aux2 l)
[PROOFSTEP]
induction' l with c l IH
[GOAL]
case nil
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
⊢ F [] (parallel.aux2 [])
[PROOFSTEP]
simp only [parallel.aux2, List.foldr]
[GOAL]
case cons
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
IH : F l (parallel.aux2 l)
⊢ F (c :: l) (parallel.aux2 (c :: l))
[PROOFSTEP]
simp only [parallel.aux2, List.foldr]
[GOAL]
case nil
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
⊢ ∀ (a' : α), (∃ c, c ∈ [] ∧ a' ∈ c) → ∃ c, c ∈ [] ∧ a' ∈ c
[PROOFSTEP]
intro a h
[GOAL]
case nil
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h✝ : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
a : α
h : ∃ c, c ∈ [] ∧ a ∈ c
⊢ ∃ c, c ∈ [] ∧ a ∈ c
[PROOFSTEP]
rcases h with ⟨c, hn, _⟩
[GOAL]
case nil.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
a : α
c : Computation α
hn : c ∈ []
right✝ : a ∈ c
⊢ ∃ c, c ∈ [] ∧ a ∈ c
[PROOFSTEP]
exact False.elim <| List.not_mem_nil _ hn
[GOAL]
case cons
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
IH : F l (parallel.aux2 l)
⊢ Sum.rec (motive := fun t =>
    (match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        t →
      Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (_ :
      (match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
simp only [parallel.aux2] at IH
[GOAL]
case cons
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
IH :
  Sum.rec (motive := fun t =>
    List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
          (Sum.inr []) l =
        t →
      Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            List.foldr
              (fun c o =>
                match o with
                | Sum.inl a => Sum.inl a
                | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
              (Sum.inr []) l) ▸
        ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h =>
      (_ :
          Sum.inr val =
            List.foldr
              (fun c o =>
                match o with
                | Sum.inl a => Sum.inl a
                | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
              (Sum.inr []) l) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (Sum.inr []) l)
    (_ :
      List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
          (Sum.inr []) l =
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
          (Sum.inr []) l)
⊢ Sum.rec (motive := fun t =>
    (match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        t →
      Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
        (Sum.inr []) l with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (_ :
      (match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
revert IH
[GOAL]
case cons
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
⊢ Sum.rec (motive := fun t =>
      List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l =
          t →
        Prop)
      (fun val h =>
        (_ :
            Sum.inl val =
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l) ▸
          ∃ c, c ∈ l ∧ val ∈ c)
      (fun val h =>
        (_ :
            Sum.inr val =
              List.foldr
                (fun c o =>
                  match o with
                  | Sum.inl a => Sum.inl a
                  | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                (Sum.inr []) l) ▸
          ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
      (List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
        (Sum.inr []) l)
      (_ :
        List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l =
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr []) l) →
    Sum.rec (motive := fun t =>
      (match
            List.foldr
              (fun c o =>
                match o with
                | Sum.inl a => Sum.inl a
                | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
              (Sum.inr []) l with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          t →
        Prop)
      (fun val h =>
        (_ :
            Sum.inl val =
              match
                List.foldr
                  (fun c o =>
                    match o with
                    | Sum.inl a => Sum.inl a
                    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                  (Sum.inr []) l with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
      (fun val h =>
        (_ :
            Sum.inr val =
              match
                List.foldr
                  (fun c o =>
                    match o with
                    | Sum.inl a => Sum.inl a
                    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
                  (Sum.inr []) l with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
      (match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (_ :
        (match
            List.foldr
              (fun c o =>
                match o with
                | Sum.inl a => Sum.inl a
                | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
              (Sum.inr []) l with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          match
            List.foldr
              (fun c o =>
                match o with
                | Sum.inl a => Sum.inl a
                | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
              (Sum.inr []) l with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
cases'
  List.foldr
    (fun c o =>
      match o with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (Sum.inr List.nil) l with
  a ls
[GOAL]
case cons.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
a : α
⊢ Sum.rec (motive := fun t => Sum.inl a = t → Prop) (fun val h => (_ : Sum.inl val = Sum.inl a) ▸ ∃ c, c ∈ l ∧ val ∈ c)
      (fun val h => (_ : Sum.inr val = Sum.inl a) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
      (Sum.inl a) (_ : Sum.inl a = Sum.inl a) →
    Sum.rec (motive := fun t =>
      (match Sum.inl a with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          t →
        Prop)
      (fun val h =>
        (_ :
            Sum.inl val =
              match Sum.inl a with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
      (fun val h =>
        (_ :
            Sum.inr val =
              match Sum.inl a with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
      (match Sum.inl a with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (_ :
        (match Sum.inl a with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          match Sum.inl a with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
intro IH
[GOAL]
case cons.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
⊢ Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
      (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
      (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
      (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls) →
    Sum.rec (motive := fun t =>
      (match Sum.inr ls with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          t →
        Prop)
      (fun val h =>
        (_ :
            Sum.inl val =
              match Sum.inr ls with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
      (fun val h =>
        (_ :
            Sum.inr val =
              match Sum.inr ls with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
          ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
      (match Sum.inr ls with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
      (_ :
        (match Sum.inr ls with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
          match Sum.inr ls with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
intro IH
[GOAL]
case cons.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
a : α
IH :
  Sum.rec (motive := fun t => Sum.inl a = t → Prop) (fun val h => (_ : Sum.inl val = Sum.inl a) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inl a) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (Sum.inl a)
    (_ : Sum.inl a = Sum.inl a)
⊢ Sum.rec (motive := fun t =>
    (match Sum.inl a with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        t →
      Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match Sum.inl a with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match Sum.inl a with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (match Sum.inl a with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (_ :
      (match Sum.inl a with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        match Sum.inl a with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
simp only [parallel.aux2]
[GOAL]
case cons.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
⊢ Sum.rec (motive := fun t =>
    (match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        t →
      Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (match Sum.inr ls with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (_ :
      (match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
simp only [parallel.aux2]
[GOAL]
case cons.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
a : α
IH :
  Sum.rec (motive := fun t => Sum.inl a = t → Prop) (fun val h => (_ : Sum.inl val = Sum.inl a) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inl a) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (Sum.inl a)
    (_ : Sum.inl a = Sum.inl a)
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a ∈ c_1
[PROOFSTEP]
rcases IH with ⟨c', cl, ac⟩
[GOAL]
case cons.inl.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l : List (Computation α)
a : α
c' : Computation α
cl : c' ∈ l
ac : a ∈ c'
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a ∈ c_1
[PROOFSTEP]
refine' ⟨c', List.Mem.tail _ cl, ac⟩
[GOAL]
case cons.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
⊢ Sum.rec (motive := fun t => rmap (fun c' => c' :: ls) (destruct c) = t → Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (rmap (fun c' => c' :: ls) (destruct c))
    (_ :
      (match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) =
        match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
[PROOFSTEP]
induction' h : destruct c with a c'
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h✝¹ : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
a : α
h : destruct c = Sum.inl a
⊢ Sum.rec (motive := fun t => rmap (fun c' => c' :: ls) (Sum.inl a) = t → Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inl a)) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inl a)) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (rmap (fun c' => c' :: ls) (Sum.inl a))
    (_ :
      (match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inl a)) =
        match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inl a))
[PROOFSTEP]
simp only [rmap]
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
⊢ Sum.rec (motive := fun t => rmap (fun c' => c' :: ls) (Sum.inr c') = t → Prop)
    (fun val h =>
      (_ :
          Sum.inl val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inr c')) ▸
        ∃ c_1, c_1 ∈ c :: l ∧ val ∈ c_1)
    (fun val h =>
      (_ :
          Sum.inr val =
            match Sum.inr ls with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inr c')) ▸
        ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1)
    (rmap (fun c' => c' :: ls) (Sum.inr c'))
    (_ :
      (match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inr c')) =
        match Sum.inr ls with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls => rmap (fun c' => c' :: ls) (Sum.inr c'))
[PROOFSTEP]
simp only [rmap]
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h✝¹ : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
a : α
h : destruct c = Sum.inl a
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a ∈ c_1
[PROOFSTEP]
refine' ⟨c, List.mem_cons_self _ _, _⟩
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h✝¹ : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
a : α
h : destruct c = Sum.inl a
⊢ a ∈ c
[PROOFSTEP]
rw [destruct_eq_pure h]
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a✝ : α
h✝¹ : a✝ ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
a : α
h : destruct c = Sum.inl a
⊢ a ∈ pure a
[PROOFSTEP]
apply ret_mem
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
⊢ ∀ (a' : α), (∃ c, c ∈ c' :: ls ∧ a' ∈ c) → ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
intro a' h
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝² : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝¹ : destruct c = x✝
c' : Computation α
h✝ : destruct c = Sum.inr c'
a' : α
h : ∃ c, c ∈ c' :: ls ∧ a' ∈ c
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
rcases h with ⟨d, dm, ad⟩
[GOAL]
case cons.inr.inr.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
dm : d ∈ c' :: ls
ad : a' ∈ d
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
simp at dm
[GOAL]
case cons.inr.inr.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ d
dm : d = c' ∨ d ∈ ls
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
cases' dm with e dl
[GOAL]
case cons.inr.inr.intro.intro.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ d
e : d = c'
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
rw [e] at ad
[GOAL]
case cons.inr.inr.intro.intro.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ c'
e : d = c'
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
refine' ⟨c, List.mem_cons_self _ _, _⟩
[GOAL]
case cons.inr.inr.intro.intro.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ c'
e : d = c'
⊢ a' ∈ c
[PROOFSTEP]
rw [destruct_eq_think h]
[GOAL]
case cons.inr.inr.intro.intro.inl
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ c'
e : d = c'
⊢ a' ∈ think c'
[PROOFSTEP]
exact think_mem ad
[GOAL]
case cons.inr.inr.intro.intro.inr
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d : Computation α
ad : a' ∈ d
dl : d ∈ ls
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
cases' IH a' ⟨d, dl, ad⟩ with d dm
[GOAL]
case cons.inr.inr.intro.intro.inr.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d✝ : Computation α
ad : a' ∈ d✝
dl : d✝ ∈ ls
d : Computation α
dm : d ∈ l ∧ a' ∈ d
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
cases' dm with dm ad
[GOAL]
case cons.inr.inr.intro.intro.inr.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h✝¹ : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
c : Computation α
l ls : List (Computation α)
IH :
  Sum.rec (motive := fun t => Sum.inr ls = t → Prop)
    (fun val h => (_ : Sum.inl val = Sum.inr ls) ▸ ∃ c, c ∈ l ∧ val ∈ c)
    (fun val h => (_ : Sum.inr val = Sum.inr ls) ▸ ∀ (a' : α), (∃ c, c ∈ val ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c)
    (Sum.inr ls) (_ : Sum.inr ls = Sum.inr ls)
x✝ : α ⊕ Computation α
h✝ : destruct c = x✝
c' : Computation α
h : destruct c = Sum.inr c'
a' : α
d✝ : Computation α
ad✝ : a' ∈ d✝
dl : d✝ ∈ ls
d : Computation α
dm : d ∈ l
ad : a' ∈ d
⊢ ∃ c_1, c_1 ∈ c :: l ∧ a' ∈ c_1
[PROOFSTEP]
exact ⟨d, List.Mem.tail _ dm, ad⟩
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
⊢ ∀ (C : Computation α),
    a ∈ C →
      ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
        corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro C aC
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)), corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
apply memRecOn aC <;> [skip; intro C' IH] <;> intro l S e <;> have e' := congr_arg destruct e <;> have := lem1 l <;>
          simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e'  <;>
        revert this e' <;>
      cases' parallel.aux2 l with a' l' <;>
    intro this e' <;>
  [injection e' with h'; injection e'; injection e'; injection e' with h']
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)), corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
apply memRecOn aC <;> [skip; intro C' IH]
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)), corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
apply memRecOn aC
[GOAL]
case h1
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = pure a → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
skip
[GOAL]
case h2
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (s : Computation α),
    (∀ (l : List (Computation α)) (S : WSeq (Computation α)),
        corec parallel.aux1 (l, S) = s → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c) →
      ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
        corec parallel.aux1 (l, S) = think s → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro C' IH
[GOAL]
case h1
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = pure a → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro l S e
[GOAL]
case h2
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
h : a ∈ parallel S
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
⊢ ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = think C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro l S e
[GOAL]
case h1
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
have e' := congr_arg destruct e
[GOAL]
case h2
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
have e' := congr_arg destruct e
[GOAL]
case h1
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
e' : destruct (corec parallel.aux1 (l, S)) = destruct (pure a)
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
have := lem1 l
[GOAL]
case h2
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
e' : destruct (corec parallel.aux1 (l, S)) = destruct (think C')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
have := lem1 l
[GOAL]
case h1
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
e' : destruct (corec parallel.aux1 (l, S)) = destruct (pure a)
this : F l (parallel.aux2 l)
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e'
[GOAL]
case h2
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
e' : destruct (corec parallel.aux1 (l, S)) = destruct (think C')
this : F l (parallel.aux2 l)
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e'
[GOAL]
case h1
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
this : F l (parallel.aux2 l)
e' :
  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 a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
revert this e'
[GOAL]
case h2
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
this : F l (parallel.aux2 l)
e' :
  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.inr C'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
revert this e'
[GOAL]
case h1
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
⊢ F l (parallel.aux2 l) →
    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 a →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
cases' parallel.aux2 l with a' l'
[GOAL]
case h2
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
⊢ F l (parallel.aux2 l) →
    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.inr C' →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
cases' parallel.aux2 l with a' l'
[GOAL]
case h1.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
a' : α
⊢ F 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 a →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro this e'
[GOAL]
case h1.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
l' : List (Computation α)
⊢ F l (Sum.inr l') →
    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.inr l')) =
        Sum.inl a →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro this e'
[GOAL]
case h2.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
a' : α
⊢ F 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.inr C' →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro this e'
[GOAL]
case h2.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
⊢ F l (Sum.inr l') →
    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.inr l')) =
        Sum.inr C' →
      ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
intro this e'
[GOAL]
case h1.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
a' : α
this : F l (Sum.inl a')
e' :
  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 a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
injection e' with h'
[GOAL]
case h1.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
l' : List (Computation α)
this : F l (Sum.inr l')
e' :
  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.inr l')) =
    Sum.inl a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
injection e'
[GOAL]
case h2.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
a' : α
this : F l (Sum.inl a')
e' :
  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.inr C'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
injection e'
[GOAL]
case h2.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
e' :
  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.inr l')) =
    Sum.inr C'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
injection e' with h'
[GOAL]
case h1.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
a' : α
this : F l (Sum.inl a')
h' : a' = a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rw [h'] at this
[GOAL]
case h1.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
a' : α
this : F l (Sum.inl a)
h' : a' = a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rcases this with ⟨c, cl, ac⟩
[GOAL]
case h1.inl.intro.intro
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = pure a
a' : α
h' : a' = a
c : Computation α
cl : c ∈ l
ac : a ∈ c
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
exact ⟨c, Or.inl cl, ac⟩
[GOAL]
case h2.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
h' :
  corec parallel.aux1
      ((fun l' =>
          match Seq.destruct S with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
induction' e : Seq.destruct S with a
[GOAL]
case h2.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
h' :
  corec parallel.aux1
      ((fun l' =>
          match Seq.destruct S with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
e : Seq.destruct S = none
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rw [e] at h'
[GOAL]
case h2.inr.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a✝ ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a✝ ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
h' :
  corec parallel.aux1
      ((fun l' =>
          match Seq.destruct S with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
a : Seq1 (Option (Computation α))
e : Seq.destruct S = some a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a✝ ∈ c
[PROOFSTEP]
rw [e] at h'
[GOAL]
case h2.inr.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
h' :
  corec parallel.aux1
      ((fun l' =>
          match none with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
e : Seq.destruct S = none
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
exact
  let ⟨d, o, ad⟩ := IH _ _ h'
  let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (WSeq.not_mem_nil _), ad⟩
  ⟨c, Or.inl cl, ac⟩
[GOAL]
case h2.inr.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a✝ : α
h : a✝ ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a✝ ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a✝ ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
a : Seq1 (Option (Computation α))
h' :
  corec parallel.aux1
      ((fun l' =>
          match some a with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
e : Seq.destruct S = some a
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a✝ ∈ c
[PROOFSTEP]
cases' a with o S'
[GOAL]
case h2.inr.some.mk
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
o : Option (Computation α)
S' : Stream'.Seq (Option (Computation α))
h' :
  corec parallel.aux1
      ((fun l' =>
          match some (o, S') with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
e : Seq.destruct S = some (o, S')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
cases' o with c
[GOAL]
case h2.inr.some.mk.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' :
  corec parallel.aux1
      ((fun l' =>
          match some (none, S') with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
e : Seq.destruct S = some (none, S')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
simp [parallel.aux1] at h'
[GOAL]
case h2.inr.some.mk.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' :
  corec parallel.aux1
      ((fun l' =>
          match some (some c, S') with
          | none => (l', Seq.nil)
          | some (none, S') => (l', S')
          | some (some c, S') => (c :: l', S'))
        l') =
    C'
e : Seq.destruct S = some (some c, S')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
simp [parallel.aux1] at h'
[GOAL]
case h2.inr.some.mk.none
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' : corec parallel.aux1 (l', S') = C'
e : Seq.destruct S = some (none, S')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
[GOAL]
case h2.inr.some.mk.some
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
[GOAL]
case h2.inr.some.mk.none.intro.intro.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' : corec parallel.aux1 (l', S') = C'
e : Seq.destruct S = some (none, S')
d : Computation α
ad : a ∈ d
dl : d ∈ l'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
exact
  let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
  ⟨c, Or.inl cl, ac⟩
[GOAL]
case h2.inr.some.mk.none.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' : corec parallel.aux1 (l', S') = C'
e : Seq.destruct S = some (none, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
refine' ⟨d, Or.inr _, ad⟩
[GOAL]
case h2.inr.some.mk.none.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' : corec parallel.aux1 (l', S') = C'
e : Seq.destruct S = some (none, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ d ∈ S
[PROOFSTEP]
rw [Seq.destruct_eq_cons e]
[GOAL]
case h2.inr.some.mk.none.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
h' : corec parallel.aux1 (l', S') = C'
e : Seq.destruct S = some (none, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ d ∈ Seq.cons none S'
[PROOFSTEP]
exact Seq.mem_cons_of_mem _ dS'
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dl : d ∈ c :: l'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
simp at dl
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dl : d = c ∨ d ∈ l'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
cases' dl with dc dl
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dc : d = c
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
rw [dc] at ad
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ c
dc : d = c
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
refine' ⟨c, Or.inr _, ad⟩
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ c
dc : d = c
⊢ c ∈ S
[PROOFSTEP]
rw [Seq.destruct_eq_cons e]
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl.inl
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ c
dc : d = c
⊢ c ∈ Seq.cons (some c) S'
[PROOFSTEP]
apply Seq.mem_cons
[GOAL]
case h2.inr.some.mk.some.intro.intro.inl.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dl : d ∈ l'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
exact
  let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
  ⟨c, Or.inl cl, ac⟩
[GOAL]
case h2.inr.some.mk.some.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
[PROOFSTEP]
refine' ⟨d, Or.inr _, ad⟩
[GOAL]
case h2.inr.some.mk.some.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ d ∈ S
[PROOFSTEP]
rw [Seq.destruct_eq_cons e]
[GOAL]
case h2.inr.some.mk.some.intro.intro.inr
α : Type u
β : Type v
S✝ : WSeq (Computation α)
a : α
h : a ∈ parallel S✝
F : List (Computation α) → α ⊕ List (Computation α) → Prop :=
  fun l a =>
    Sum.casesOn (motive := fun t => a = t → Prop) a (fun a_1 h => (_ : Sum.inl a_1 = a) ▸ ∃ c, c ∈ l ∧ a_1 ∈ c)
      (fun l' h => (_ : Sum.inr l' = a) ▸ ∀ (a' : α), (∃ c, c ∈ l' ∧ a' ∈ c) → ∃ c, c ∈ l ∧ a' ∈ c) (_ : a = a)
lem1 : ∀ (l : List (Computation α)), F l (parallel.aux2 l)
C : Computation α
aC : a ∈ C
C' : Computation α
IH :
  ∀ (l : List (Computation α)) (S : WSeq (Computation α)),
    corec parallel.aux1 (l, S) = C' → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
l : List (Computation α)
S : WSeq (Computation α)
e✝¹ : corec parallel.aux1 (l, S) = think C'
l' : List (Computation α)
this : F l (Sum.inr l')
x✝ : Option (Seq1 (Option (Computation α)))
e✝ : Seq.destruct S = x✝
S' : Stream'.Seq (Option (Computation α))
c : Computation α
h' : corec parallel.aux1 (c :: l', S') = C'
e : Seq.destruct S = some (some c, S')
d : Computation α
ad : a ∈ d
dS' : d ∈ S'
⊢ d ∈ Seq.cons (some c) S'
[PROOFSTEP]
exact Seq.mem_cons_of_mem _ dS'
[GOAL]
α : Type u
β : Type v
f : α → β
S : WSeq (Computation α)
⊢ map f (parallel S) = parallel (WSeq.map (map f) S)
[PROOFSTEP]
refine'
  eq_of_bisim
    (fun c1 c2 =>
      ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (l.map (map f), S.map (map f)))
    _ ⟨[], S, rfl, rfl⟩
[GOAL]
α : Type u
β : Type v
f : α → β
S : WSeq (Computation α)
⊢ IsBisimulation fun c1 c2 =>
    ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
[PROOFSTEP]
intro c1 c2 h
[GOAL]
α : Type u
β : Type v
f : α → β
S : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
⊢ BisimO
    (fun c1 c2 =>
      ∃ l S,
        c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S))
    (destruct c1) (destruct c2)
[PROOFSTEP]
exact
  match c1, c2, h with
  | _, _, ⟨l, S, rfl, rfl⟩ =>
    by
    have : parallel.aux2 (l.map (map f)) = lmap f (rmap (List.map (map f)) (parallel.aux2 l)) :=
      by
      simp [parallel.aux2]
      induction' l with c l IH <;> simp
      rw [IH]
      cases
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
            (Sum.inr List.nil) l <;>
        simp [parallel.aux2]
      cases destruct c <;> simp
    simp [parallel.aux1]
    rw [this]
    cases' parallel.aux2 l with a l' <;> simp
    induction' S using WSeq.recOn with c S S <;> simp <;> exact ⟨_, _, rfl, rfl⟩
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
⊢ BisimO
    (fun c1 c2 =>
      ∃ l S,
        c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S))
    (destruct (map f (corec parallel.aux1 (l, S))))
    (destruct (corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)))
[PROOFSTEP]
have : parallel.aux2 (l.map (map f)) = lmap f (rmap (List.map (map f)) (parallel.aux2 l)) :=
  by
  simp [parallel.aux2]
  induction' l with c l IH <;> simp
  rw [IH]
  cases
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
        (Sum.inr List.nil) l <;>
    simp [parallel.aux2]
  cases destruct c <;> simp
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
⊢ parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
[PROOFSTEP]
simp [parallel.aux2]
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
⊢ List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
induction' l with c l IH
[GOAL]
case nil
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
⊢ List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) []) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) [] with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
⊢ List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) (c :: l)) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) (c :: l) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
⊢ (match
      List.foldr
        (fun c o =>
          match o with
          | Sum.inl a => Sum.inl a
          | Sum.inr ls =>
            match destruct c with
            | Sum.inl a => Sum.inl a
            | Sum.inr b => Sum.inr (b :: ls))
        (Sum.inr []) (List.map (map f) l) with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match
        match
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (map f b) with
        | Sum.inl a => Sum.inl (f a)
        | Sum.inr b => Sum.inr b with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    match
      match
        match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls =>
                match destruct c with
                | Sum.inl a => Sum.inl a
                | Sum.inr b => Sum.inr (b :: ls))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
rw [IH]
[GOAL]
case cons
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
⊢ (match
      match
        match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls =>
                match destruct c with
                | Sum.inl a => Sum.inl a
                | Sum.inr b => Sum.inr (b :: ls))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (List.map (map f) b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match
        match
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (map f b) with
        | Sum.inl a => Sum.inl (f a)
        | Sum.inr b => Sum.inr b with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    match
      match
        match
          List.foldr
            (fun c o =>
              match o with
              | Sum.inl a => Sum.inl a
              | Sum.inr ls =>
                match destruct c with
                | Sum.inl a => Sum.inl a
                | Sum.inr b => Sum.inr (b :: ls))
            (Sum.inr []) l with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
cases
  List.foldr
    (fun c o =>
      match o with
      | Sum.inl a => Sum.inl a
      | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
    (Sum.inr List.nil) l
[GOAL]
case cons.inl
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
val✝ : α
⊢ (match
      match
        match Sum.inl val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (List.map (map f) b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match
        match
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (map f b) with
        | Sum.inl a => Sum.inl (f a)
        | Sum.inr b => Sum.inr b with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    match
      match
        match Sum.inl val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp [parallel.aux2]
[GOAL]
case cons.inr
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
val✝ : List (Computation α)
⊢ (match
      match
        match Sum.inr val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (List.map (map f) b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr ls =>
      match
        match
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (map f b) with
        | Sum.inl a => Sum.inl (f a)
        | Sum.inr b => Sum.inr b with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (b :: ls)) =
    match
      match
        match Sum.inr val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp [parallel.aux2]
[GOAL]
case cons.inr
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
val✝ : List (Computation α)
⊢ (match
      match
        match destruct c with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (map f b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: List.map (map f) val✝)) =
    match
      match
        match destruct c with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: val✝) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
cases destruct c
[GOAL]
case cons.inr.inl
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
val✝¹ : List (Computation α)
val✝ : α
⊢ (match
      match
        match Sum.inl val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (map f b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: List.map (map f) val✝¹)) =
    match
      match
        match Sum.inl val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: val✝¹) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp
[GOAL]
case cons.inr.inr
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
S : WSeq (Computation α)
c : Computation α
l : List (Computation α)
IH :
  List.foldr
      (fun c o =>
        match o with
        | Sum.inl a => Sum.inl a
        | Sum.inr ls =>
          match destruct c with
          | Sum.inl a => Sum.inl a
          | Sum.inr b => Sum.inr (b :: ls))
      (Sum.inr []) (List.map (map f) l) =
    match
      match
        List.foldr
          (fun c o =>
            match o with
            | Sum.inl a => Sum.inl a
            | Sum.inr ls =>
              match destruct c with
              | Sum.inl a => Sum.inl a
              | Sum.inr b => Sum.inr (b :: ls))
          (Sum.inr []) l with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
val✝¹ : List (Computation α)
val✝ : Computation α
⊢ (match
      match
        match Sum.inr val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (map f b) with
      | Sum.inl a => Sum.inl (f a)
      | Sum.inr b => Sum.inr b with
    | Sum.inl a => Sum.inl a
    | Sum.inr b => Sum.inr (b :: List.map (map f) val✝¹)) =
    match
      match
        match Sum.inr val✝ with
        | Sum.inl a => Sum.inl a
        | Sum.inr b => Sum.inr (b :: val✝¹) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (List.map (map f) b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b
[PROOFSTEP]
simp
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
⊢ BisimO
    (fun c1 c2 =>
      ∃ l S,
        c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S))
    (destruct (map f (corec parallel.aux1 (l, S))))
    (destruct (corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)))
[PROOFSTEP]
simp [parallel.aux1]
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
⊢ match
    match
      match
        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) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (map f b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b,
    match
      match parallel.aux2 (List.map (map f) l) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b =>
        Sum.inr
          (match Seq.destruct (WSeq.map (map f) 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) with
  | Sum.inl a, Sum.inl a' => a = a'
  | Sum.inr s, Sum.inr s' =>
    ∃ l S, s = map f (corec parallel.aux1 (l, S)) ∧ s' = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
  | x, x_1 => False
[PROOFSTEP]
rw [this]
[GOAL]
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
⊢ match
    match
      match
        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) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (map f b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b,
    match
      match lmap f (rmap (List.map (map f)) (parallel.aux2 l)) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b =>
        Sum.inr
          (match Seq.destruct (WSeq.map (map f) 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) with
  | Sum.inl a, Sum.inl a' => a = a'
  | Sum.inr s, Sum.inr s' =>
    ∃ l S, s = map f (corec parallel.aux1 (l, S)) ∧ s' = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
  | x, x_1 => False
[PROOFSTEP]
cases' parallel.aux2 l with a l'
[GOAL]
case inl
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
a : α
⊢ match
    match
      match
        match
          match Sum.inl a 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) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (map f b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b,
    match
      match lmap f (rmap (List.map (map f)) (Sum.inl a)) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b =>
        Sum.inr
          (match Seq.destruct (WSeq.map (map f) 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) with
  | Sum.inl a, Sum.inl a' => a = a'
  | Sum.inr s, Sum.inr s' =>
    ∃ l S, s = map f (corec parallel.aux1 (l, S)) ∧ s' = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
  | x, x_1 => False
[PROOFSTEP]
simp
[GOAL]
case inr
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
⊢ match
    match
      match
        match
          match Sum.inr 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) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b => Sum.inr (map f b) with
    | Sum.inl a => Sum.inl (f a)
    | Sum.inr b => Sum.inr b,
    match
      match lmap f (rmap (List.map (map f)) (Sum.inr l')) with
      | Sum.inl a => Sum.inl a
      | Sum.inr b =>
        Sum.inr
          (match Seq.destruct (WSeq.map (map f) 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) with
  | Sum.inl a, Sum.inl a' => a = a'
  | Sum.inr s, Sum.inr s' =>
    ∃ l S, s = map f (corec parallel.aux1 (l, S)) ∧ s' = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
  | x, x_1 => False
[PROOFSTEP]
simp
[GOAL]
case inr
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
S : WSeq (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
⊢ ∃ l S_1,
    map f
          (corec parallel.aux1
            (match Seq.destruct S with
            | none => (l', Seq.nil)
            | some (none, S') => (l', S')
            | some (some c, S') => (c :: l', S'))) =
        map f (corec parallel.aux1 (l, S_1)) ∧
      corec parallel.aux1
          (match Seq.destruct (WSeq.map (map f) S) with
          | none => (List.map (map f) l', Seq.nil)
          | some (none, S') => (List.map (map f) l', S')
          | some (some c, S') => (c :: List.map (map f) l', S')) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S_1)
[PROOFSTEP]
induction' S using WSeq.recOn with c S S
[GOAL]
case inr.h1
α : Type u
β : Type v
f : α → β
S : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
⊢ ∃ l S,
    map f
          (corec parallel.aux1
            (match Seq.destruct WSeq.nil with
            | none => (l', Seq.nil)
            | some (none, S') => (l', S')
            | some (some c, S') => (c :: l', S'))) =
        map f (corec parallel.aux1 (l, S)) ∧
      corec parallel.aux1
          (match Seq.destruct (WSeq.map (map f) WSeq.nil) with
          | none => (List.map (map f) l', Seq.nil)
          | some (none, S') => (List.map (map f) l', S')
          | some (some c, S') => (c :: List.map (map f) l', S')) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
[PROOFSTEP]
simp
[GOAL]
case inr.h2
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
c : Computation α
S : WSeq (Computation α)
⊢ ∃ l S_1,
    map f
          (corec parallel.aux1
            (match Seq.destruct (WSeq.cons c S) with
            | none => (l', Seq.nil)
            | some (none, S') => (l', S')
            | some (some c, S') => (c :: l', S'))) =
        map f (corec parallel.aux1 (l, S_1)) ∧
      corec parallel.aux1
          (match Seq.destruct (WSeq.map (map f) (WSeq.cons c S)) with
          | none => (List.map (map f) l', Seq.nil)
          | some (none, S') => (List.map (map f) l', S')
          | some (some c, S') => (c :: List.map (map f) l', S')) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S_1)
[PROOFSTEP]
simp
[GOAL]
case inr.h3
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
S : WSeq (Computation α)
⊢ ∃ l S_1,
    map f
          (corec parallel.aux1
            (match Seq.destruct (WSeq.think S) with
            | none => (l', Seq.nil)
            | some (none, S') => (l', S')
            | some (some c, S') => (c :: l', S'))) =
        map f (corec parallel.aux1 (l, S_1)) ∧
      corec parallel.aux1
          (match Seq.destruct (WSeq.map (map f) (WSeq.think S)) with
          | none => (List.map (map f) l', Seq.nil)
          | some (none, S') => (List.map (map f) l', S')
          | some (some c, S') => (c :: List.map (map f) l', S')) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S_1)
[PROOFSTEP]
simp
[GOAL]
case inr.h1
α : Type u
β : Type v
f : α → β
S : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
⊢ ∃ l S,
    map f (corec parallel.aux1 (l', Seq.nil)) = map f (corec parallel.aux1 (l, S)) ∧
      corec parallel.aux1 (List.map (map f) l', Seq.nil) = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
[PROOFSTEP]
exact ⟨_, _, rfl, rfl⟩
[GOAL]
case inr.h2
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
c : Computation α
S : WSeq (Computation α)
⊢ ∃ l S_1,
    map f (corec parallel.aux1 (c :: l', S)) = map f (corec parallel.aux1 (l, S_1)) ∧
      corec parallel.aux1 (map f c :: List.map (map f) l', WSeq.map (map f) S) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S_1)
[PROOFSTEP]
exact ⟨_, _, rfl, rfl⟩
[GOAL]
case inr.h3
α : Type u
β : Type v
f : α → β
S✝ : WSeq (Computation α)
c1 c2 : Computation β
h : ∃ l S, c1 = map f (corec parallel.aux1 (l, S)) ∧ c2 = corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S)
l : List (Computation α)
this : parallel.aux2 (List.map (map f) l) = lmap f (rmap (List.map (map f)) (parallel.aux2 l))
l' : List (Computation α)
S : WSeq (Computation α)
⊢ ∃ l S_1,
    map f (corec parallel.aux1 (l', S)) = map f (corec parallel.aux1 (l, S_1)) ∧
      corec parallel.aux1 (List.map (map f) l', WSeq.map (map f) S) =
        corec parallel.aux1 (List.map (map f) l, WSeq.map (map f) S_1)
[PROOFSTEP]
exact ⟨_, _, rfl, rfl⟩
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
h : WSeq.head S ~> none
x✝ : Terminates (parallel S)
a : α
m : a ∈ parallel S
⊢ False
[PROOFSTEP]
let ⟨c, cs, _⟩ := exists_of_mem_parallel m
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
h : WSeq.head S ~> none
x✝ : Terminates (parallel S)
a : α
m : a ∈ parallel S
c : Computation α
cs : c ∈ S
right✝ : a ∈ c
⊢ False
[PROOFSTEP]
let ⟨n, nm⟩ := WSeq.exists_get?_of_mem cs
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
h : WSeq.head S ~> none
x✝ : Terminates (parallel S)
a : α
m : a ∈ parallel S
c : Computation α
cs : c ∈ S
right✝ : a ∈ c
n : ℕ
nm : some c ∈ WSeq.get? S n
⊢ False
[PROOFSTEP]
let ⟨c', h'⟩ := WSeq.head_some_of_get?_some nm
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
h : WSeq.head S ~> none
x✝ : Terminates (parallel S)
a : α
m : a ∈ parallel S
c : Computation α
cs : c ∈ S
right✝ : a ∈ c
n : ℕ
nm : some c ∈ WSeq.get? S n
c' : Computation α
h' : some c' ∈ WSeq.head S
⊢ False
[PROOFSTEP]
injection h h'
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
⊢ C a
[PROOFSTEP]
let T : WSeq (Computation (α × Computation α)) := S.map fun c => c.map fun a => (a, c)
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
⊢ C a
[PROOFSTEP]
have : S = T.map (map fun c => c.1) := by
  rw [← WSeq.map_comp]
  refine' (WSeq.map_id _).symm.trans (congr_arg (fun f => WSeq.map f S) _)
  funext c
  dsimp [id, Function.comp]
  rw [← map_comp]
  exact (map_id _).symm
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
⊢ S = WSeq.map (map fun c => c.fst) T
[PROOFSTEP]
rw [← WSeq.map_comp]
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
⊢ S = WSeq.map ((map fun c => c.fst) ∘ fun c => map (fun a => (a, c)) c) S
[PROOFSTEP]
refine' (WSeq.map_id _).symm.trans (congr_arg (fun f => WSeq.map f S) _)
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
⊢ id = (map fun c => c.fst) ∘ fun c => map (fun a => (a, c)) c
[PROOFSTEP]
funext c
[GOAL]
case h
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
c : Computation α
⊢ id c = ((map fun c => c.fst) ∘ fun c => map (fun a => (a, c)) c) c
[PROOFSTEP]
dsimp [id, Function.comp]
[GOAL]
case h
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
c : Computation α
⊢ c = map (fun c => c.fst) (map (fun a => (a, c)) c)
[PROOFSTEP]
rw [← map_comp]
[GOAL]
case h
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
c : Computation α
⊢ c = map ((fun c => c.fst) ∘ fun a => (a, c)) c
[PROOFSTEP]
exact (map_id _).symm
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this : S = WSeq.map (map fun c => c.fst) T
⊢ C a
[PROOFSTEP]
have pe := congr_arg parallel this
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = parallel (WSeq.map (map fun c => c.fst) T)
⊢ C a
[PROOFSTEP]
rw [← map_parallel] at pe
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
⊢ C a
[PROOFSTEP]
have h' := h
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ parallel S
⊢ C a
[PROOFSTEP]
rw [pe] at h'
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
⊢ C a
[PROOFSTEP]
haveI : Terminates (parallel T) := (terminates_map_iff _ _).1 ⟨⟨_, h'⟩⟩
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
⊢ C a
[PROOFSTEP]
induction' e : get (parallel T) with a' c
[GOAL]
case mk
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
e : get (parallel T) = (a', c)
⊢ C a
[PROOFSTEP]
have : a ∈ c ∧ c ∈ S := by
  rcases exists_of_mem_map h' with ⟨d, dT, cd⟩
  rw [get_eq_of_mem _ dT] at e
  cases e
  dsimp at cd
  cases cd
  rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
  rcases WSeq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
  rw [← e'] at ad'
  rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩
  injection e' with i1 i2
  constructor
  rwa [i1, i2] at ac'
  rwa [i2] at cs'
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
e : get (parallel T) = (a', c)
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rcases exists_of_mem_map h' with ⟨d, dT, cd⟩
[GOAL]
case intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
e : get (parallel T) = (a', c)
d : α × Computation α
dT : d ∈ parallel T
cd : d.fst = a
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rw [get_eq_of_mem _ dT] at e
[GOAL]
case intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
d : α × Computation α
e : d = (a', c)
dT : d ∈ parallel T
cd : d.fst = a
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
cases e
[GOAL]
case intro.intro.refl
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
a' : α
c : Computation α
dT : (a', c) ∈ parallel T
cd : (a', c).fst = a
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
dsimp at cd
[GOAL]
case intro.intro.refl
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
a' : α
c : Computation α
dT : (a', c) ∈ parallel T
cd : a' = a
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
cases cd
[GOAL]
case intro.intro.refl.refl
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
[GOAL]
case intro.intro.refl.refl.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
ad' : (a, c) ∈ d'
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rcases WSeq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
ad' : (a, c) ∈ d'
c' : Computation α
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rw [← e'] at ad'
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e'✝ : map (fun a => (a, c')) c' = d'
a' : α
ac' : a' ∈ c'
e' : (a', c') = (a, c)
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
injection e' with i1 i2
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro.intro.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
a' : α
ac' : a' ∈ c'
i1 : a' = a
i2 : c' = c
⊢ a ∈ c ∧ c ∈ S
[PROOFSTEP]
constructor
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro.intro.intro.left
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
a' : α
ac' : a' ∈ c'
i1 : a' = a
i2 : c' = c
⊢ a ∈ c
case intro.intro.refl.refl.intro.intro.intro.intro.intro.intro.right
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
a' : α
ac' : a' ∈ c'
i1 : a' = a
i2 : c' = c
⊢ c ∈ S
[PROOFSTEP]
rwa [i1, i2] at ac'
[GOAL]
case intro.intro.refl.refl.intro.intro.intro.intro.intro.intro.right
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e : get (parallel T) = x✝
c : Computation α
dT : (a, c) ∈ parallel T
d' : Computation (α × Computation α)
dT' : d' ∈ T
c' : Computation α
ad' : (a, c) ∈ map (fun a => (a, c')) c'
cs' : c' ∈ S
e' : map (fun a => (a, c')) c' = d'
a' : α
ac' : a' ∈ c'
i1 : a' = a
i2 : c' = c
⊢ c ∈ S
[PROOFSTEP]
rwa [i2] at cs'
[GOAL]
case mk
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝¹ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this✝ : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
e : get (parallel T) = (a', c)
this : a ∈ c ∧ c ∈ S
⊢ C a
[PROOFSTEP]
cases' this with ac cs
[GOAL]
case mk.intro
α : Type u
β : Type v
S : WSeq (Computation α)
C : α → Sort v
H : (s : Computation α) → s ∈ S → (a : α) → a ∈ s → C a
a : α
h : a ∈ parallel S
T : WSeq (Computation (α × Computation α)) := WSeq.map (fun c => map (fun a => (a, c)) c) S
this✝ : S = WSeq.map (map fun c => c.fst) T
pe : parallel S = map (fun c => c.fst) (parallel T)
h' : a ∈ map (fun c => c.fst) (parallel T)
this : Terminates (parallel T)
x✝ : α × Computation α
e✝ : get (parallel T) = x✝
a' : α
c : Computation α
e : get (parallel T) = (a', c)
ac : a ∈ c
cs : c ∈ S
⊢ C a
[PROOFSTEP]
apply H _ cs _ ac
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
H : ∀ (s : Computation α), s ∈ S → s ~> a
c : Computation α
cs : c ∈ S
ac : a ∈ c
⊢ a ∈ parallel S
[PROOFSTEP]
haveI := terminates_of_mem ac
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
H : ∀ (s : Computation α), s ∈ S → s ~> a
c : Computation α
cs : c ∈ S
ac : a ∈ c
this : Terminates c
⊢ a ∈ parallel S
[PROOFSTEP]
haveI := terminates_parallel cs
[GOAL]
α : Type u
β : Type v
S : WSeq (Computation α)
a : α
H : ∀ (s : Computation α), s ∈ S → s ~> a
c : Computation α
cs : c ∈ S
ac : a ∈ c
this✝ : Terminates c
this : Terminates (parallel S)
⊢ a ∈ parallel S
[PROOFSTEP]
exact mem_of_promises _ (parallel_promises H)
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel S
⊢ a' ∈ parallel T
[PROOFSTEP]
have aa := parallel_promises h1 h
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel S
aa : a = a'
⊢ a' ∈ parallel T
[PROOFSTEP]
rw [← aa]
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel S
aa : a = a'
⊢ a ∈ parallel T
[PROOFSTEP]
rw [← aa] at h
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a ∈ parallel S
aa : a = a'
⊢ a ∈ parallel T
[PROOFSTEP]
exact
  let ⟨s, sS, as⟩ := exists_of_mem_parallel h
  let ⟨t, tT, st⟩ := WSeq.exists_of_liftRel_left H sS
  let aT := (st _).1 as
  mem_parallel h2 tT aT
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel T
⊢ a' ∈ parallel S
[PROOFSTEP]
have aa := parallel_promises h2 h
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel T
aa : a = a'
⊢ a' ∈ parallel S
[PROOFSTEP]
rw [← aa]
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a' ∈ parallel T
aa : a = a'
⊢ a ∈ parallel S
[PROOFSTEP]
rw [← aa] at h
[GOAL]
α : Type u
β : Type v
S T : WSeq (Computation α)
a : α
h1 : ∀ (s : Computation α), s ∈ S → s ~> a
H : WSeq.LiftRel Equiv S T
h2 : ∀ (t : Computation α), t ∈ T → t ~> a := Iff.mp (parallel_congr_lem H) h1
a' : α
h : a ∈ parallel T
aa : a = a'
⊢ a ∈ parallel S
[PROOFSTEP]
exact
  let ⟨s, sS, as⟩ := exists_of_mem_parallel h
  let ⟨t, tT, st⟩ := WSeq.exists_of_liftRel_right H sS
  let aT := (st _).2 as
  mem_parallel h1 tT aT