α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ destruct
      (corec
        (fun x =>
          match destruct x.fst with
          | none =>
            match destruct x.snd with
            | none => none
            | some (a, b) => some (a, nil, b)
          | some (a, s₁') => some (a, s₁', x.snd))
        (cons a s, t)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ destruct (append (cons a s) t) = some (a, append s t)
dsimp [append]
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ omap
      (corec fun x =>
        match destruct x.fst with
        | none =>
          match destruct x.snd with
          | none => none
          | some (a, b) => some (a, nil, b)
        | some (a, s₁') => some (a, s₁', x.snd))
      (match destruct (cons a s, t).fst with
      | none =>
        match destruct (cons a s, t).snd with
        | none => none
        | some (a, b) => some (a, nil, b)
      | some (a_1, s₁') => some (a_1, s₁', (cons a s, t).snd)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ destruct
      (corec
        (fun x =>
          match destruct x.fst with
          | none =>
            match destruct x.snd with
            | none => none
            | some (a, b) => some (a, nil, b)
          | some (a, s₁') => some (a, s₁', x.snd))
        (cons a s, t)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
rw [corec_eq]
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ (match
      match destruct (cons a s) with
      | none =>
        match destruct t with
        | none => none
        | some (a, b) => some (a, nil, b)
      | some (a, s₁') => some (a, s₁', t) with
    | none => none
    | some (a, b) =>
      some
        (a,
          corec
            (fun x =>
              match destruct x.fst with
              | none =>
                match destruct x.snd with
                | none => none
                | some (a, b) => some (a, nil, b)
              | some (a, s₁') => some (a, s₁', x.snd))
            b)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ omap
      (corec fun x =>
        match destruct x.fst with
        | none =>
          match destruct x.snd with
          | none => none
          | some (a, b) => some (a, nil, b)
        | some (a, s₁') => some (a, s₁', x.snd))
      (match destruct (cons a s, t).fst with
      | none =>
        match destruct (cons a s, t).snd with
        | none => none
        | some (a, b) => some (a, nil, b)
      | some (a_1, s₁') => some (a_1, s₁', (cons a s, t).snd)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
dsimp [append]
no goals
α : Type u
β : Type v
γ : Type w
a : α
s t : Seq α
⊢ (match
      match destruct (cons a s) with
      | none =>
        match destruct t with
        | none => none
        | some (a, b) => some (a, nil, b)
      | some (a, s₁') => some (a, s₁', t) with
    | none => none
    | some (a, b) =>
      some
        (a,
          corec
            (fun x =>
              match destruct x.fst with
              | none =>
                match destruct x.snd with
                | none => none
                | some (a, b) => some (a, nil, b)
              | some (a, s₁') => some (a, s₁', x.snd))
            b)) =
    some
      (a,
        corec
          (fun x =>
            match destruct x.fst with
            | none =>
              match destruct x.snd with
              | none => none
              | some (a, b) => some (a, nil, b)
            | some (a, s₁') => some (a, s₁', x.snd))
          (s, t))
rw [destruct_cons]