l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> 

Proof state:
case h1
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ BisimO (fun s1 s2 => ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS)))
    (destruct (append nil (Seq.join (Seq.join SS)))) (destruct (append nil (Seq.join (Seq.map join SS))))

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> 

Proof state:
case h2
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ ∀ (x : α) (s : Seq α),
    BisimO (fun s1 s2 => ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS)))
      (destruct (append (Seq.cons x s) (Seq.join (Seq.join SS))))
      (destruct (append (Seq.cons x s) (Seq.join (Seq.map join SS))))

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · 

Proof state:
case h1
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ match destruct (Seq.join (Seq.join SS)), destruct (Seq.join (Seq.map join SS)) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
apply recOn SS
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> 

Proof state:
case h1.h1
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ match destruct (Seq.join (Seq.join nil)), destruct (Seq.join (Seq.map join nil)) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> 

Proof state:
case h1.h2
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ ∀ (x : Seq1 (Seq1 α)) (s : Seq (Seq1 (Seq1 α))),
    match destruct (Seq.join (Seq.join (Seq.cons x s))), destruct (Seq.join (Seq.map join (Seq.cons x s))) with
    | none, none => True
    | some (a, s), some (a', s') =>
      a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
    | x, x_1 => False

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · 

Proof state:
case h1.h2
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ ∀ (x : Seq1 (Seq1 α)) (s : Seq (Seq1 (Seq1 α))),
    match destruct (Seq.join (Seq.join (Seq.cons x s))), destruct (Seq.join (Seq.cons (join x) (Seq.map join s))) with
    | none, none => True
    | some (a, s), some (a', s') =>
      a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
    | x, x_1 => False

Next tactic:
intro S SS
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            

Proof state:
case h1.h2
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS✝ : Seq (Seq1 (Seq1 α))
S : Seq1 (Seq1 α)
SS : Seq (Seq1 (Seq1 α))
⊢ match destruct (Seq.join (Seq.join (Seq.cons S SS))), destruct (Seq.join (Seq.cons (join S) (Seq.map join SS))) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
cases' S with s S
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; 

Proof state:
case h1.h2.mk
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
s : Seq1 α
S : Seq (Seq1 α)
⊢ match destruct (Seq.join (Seq.join (Seq.cons (s, S) SS))),
    destruct (Seq.join (Seq.cons (join (s, S)) (Seq.map join SS))) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
cases' s with x s
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; 

Proof state:
case h1.h2.mk.mk
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ match destruct (Seq.join (Seq.join (Seq.cons ((x, s), S) SS))),
    destruct (Seq.join (Seq.cons (join ((x, s), S)) (Seq.map join SS))) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
simp [map]
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            

Proof state:
case h1.h2.mk.mk
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ match some (x, append s (append (Seq.join S) (Seq.join (Seq.join SS)))),
    destruct (Seq.join (Seq.cons (join ((x, s), S)) (Seq.map join SS))) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
apply recOn s
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> 

Proof state:
case h1.h2.mk.mk.h1
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ match some (x, append nil (append (Seq.join S) (Seq.join (Seq.join SS)))),
    destruct (Seq.join (Seq.cons (join ((x, nil), S)) (Seq.map join SS))) with
  | none, none => True
  | some (a, s), some (a', s') =>
    a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
  | x, x_1 => False

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> 

Proof state:
case h1.h2.mk.mk.h2
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ ∀ (x_1 : α) (s : Seq α),
    match some (x, append (Seq.cons x_1 s) (append (Seq.join S) (Seq.join (Seq.join SS)))),
      destruct (Seq.join (Seq.cons (join ((x, Seq.cons x_1 s), S)) (Seq.map join SS))) with
    | none, none => True
    | some (a, s), some (a', s') =>
      a = a' ∧ ∃ s_1 SS, s = append s_1 (Seq.join (Seq.join SS)) ∧ s' = append s_1 (Seq.join (Seq.map join SS))
    | x, x_2 => False

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · 

Proof state:
case h1.h2.mk.mk.h1
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ ∃ s SS_1,
    append (Seq.join S) (Seq.join (Seq.join SS)) = append s (Seq.join (Seq.join SS_1)) ∧
      append (Seq.join S) (Seq.join (Seq.map join SS)) = append s (Seq.join (Seq.map join SS_1))

Next tactic:
exact ⟨_, _, rfl, rfl⟩
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · 

Proof state:
case h1.h2.mk.mk.h2
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x : α
s : Seq α
⊢ ∀ (x : α) (s : Seq α),
    ∃ s_1 SS_1,
      Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.join SS)))) = append s_1 (Seq.join (Seq.join SS_1)) ∧
        Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.map join SS)))) =
          append s_1 (Seq.join (Seq.map join SS_1))

Next tactic:
intro x s
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              

Proof state:
case h1.h2.mk.mk.h2
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝¹ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x✝ : α
s✝ : Seq α
x : α
s : Seq α
⊢ ∃ s_1 SS_1,
    Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.join SS)))) = append s_1 (Seq.join (Seq.join SS_1)) ∧
      Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.map join SS)))) =
        append s_1 (Seq.join (Seq.map join SS_1))

Next tactic:
refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> 

Proof state:
case h1.h2.mk.mk.h2.refine'_1
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝¹ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x✝ : α
s✝ : Seq α
x : α
s : Seq α
⊢ Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.join SS)))) =
    append (Seq.cons x (append s (Seq.join S))) (Seq.join (Seq.join SS))

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> 

Proof state:
case h1.h2.mk.mk.h2.refine'_2
α : Type u
β : Type v
γ : Type w
SS✝¹ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝¹ : Seq α
SS✝ SS : Seq (Seq1 (Seq1 α))
S : Seq (Seq1 α)
x✝ : α
s✝ : Seq α
x : α
s : Seq α
⊢ Seq.cons x (append s (append (Seq.join S) (Seq.join (Seq.map join SS)))) =
    append (Seq.cons x (append s (Seq.join S))) (Seq.join (Seq.map join SS))

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> simp
        · 

Proof state:
case h2
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s : Seq α
SS : Seq (Seq1 (Seq1 α))
⊢ α →
    ∀ (s : Seq α),
      ∃ s_1 SS_1,
        append s (Seq.join (Seq.join SS)) = append s_1 (Seq.join (Seq.join SS_1)) ∧
          append s (Seq.join (Seq.map join SS)) = append s_1 (Seq.join (Seq.map join SS_1))

Next tactic:
intro _ s
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> simp
        · intro _ s
          

Proof state:
case h2
α : Type u
β : Type v
γ : Type w
SS✝ : Seq (Seq1 (Seq1 α))
s1 s2 : Seq α
h : ∃ s SS, s1 = append s (Seq.join (Seq.join SS)) ∧ s2 = append s (Seq.join (Seq.map join SS))
s✝ : Seq α
SS : Seq (Seq1 (Seq1 α))
x✝ : α
s : Seq α
⊢ ∃ s_1 SS_1,
    append s (Seq.join (Seq.join SS)) = append s_1 (Seq.join (Seq.join SS_1)) ∧
      append s (Seq.join (Seq.map join SS)) = append s_1 (Seq.join (Seq.map join SS_1))

Next tactic:
exact ⟨s, SS, rfl, rfl⟩
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> simp
        · intro _ s
          exact ⟨s, SS, rfl, rfl⟩
  · 

Proof state:
case r
α : Type u
β : Type v
γ : Type w
SS : Seq (Seq1 (Seq1 α))
⊢ ∃ s SS_1,
    Seq.join (Seq.join SS) = append s (Seq.join (Seq.join SS_1)) ∧
      Seq.join (Seq.map join SS) = append s (Seq.join (Seq.map join SS_1))

Next tactic:
refine' ⟨nil, SS, _, _⟩
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> simp
        · intro _ s
          exact ⟨s, SS, rfl, rfl⟩
  · refine' ⟨nil, SS, _, _⟩ <;> 

Proof state:
case r.refine'_1
α : Type u
β : Type v
γ : Type w
SS : Seq (Seq1 (Seq1 α))
⊢ Seq.join (Seq.join SS) = append nil (Seq.join (Seq.join SS))

Next tactic:
simp
@[simp]
theorem join_join (SS : Seq (Seq1 (Seq1 α))) :
    Seq.join (Seq.join SS) = Seq.join (Seq.map join SS) := by
  apply
    Seq.eq_of_bisim fun s1 s2 =>
      ∃ s SS,
        s1 = Seq.append s (Seq.join (Seq.join SS)) ∧ s2 = Seq.append s (Seq.join (Seq.map join SS))
  · intro s1 s2 h
    exact
      match s1, s2, h with
      | _, _, ⟨s, SS, rfl, rfl⟩ => by
        apply recOn s <;> simp
        · apply recOn SS <;> simp
          · intro S SS
            cases' S with s S; cases' s with x s; simp [map]
            apply recOn s <;> simp
            · exact ⟨_, _, rfl, rfl⟩
            · intro x s
              refine' ⟨Seq.cons x (append s (Seq.join S)), SS, _, _⟩ <;> simp
        · intro _ s
          exact ⟨s, SS, rfl, rfl⟩
  · refine' ⟨nil, SS, _, _⟩ <;> 

Proof state:
case r.refine'_2
α : Type u
β : Type v
γ : Type w
SS : Seq (Seq1 (Seq1 α))
⊢ Seq.join (Seq.map join SS) = append nil (Seq.join (Seq.map join SS))

Next tactic:
simp
@[simp]
theorem bind_assoc (s : Seq1 α) (f : α → Seq1 β) (g : β → Seq1 γ) :
    bind (bind s f) g = bind s fun x : α => bind (f x) g := by
  

Proof state:
α : Type u
β : Type v
γ : Type w
s : Seq1 α
f : α → Seq1 β
g : β → Seq1 γ
⊢ bind (bind s f) g = bind s fun x => bind (f x) g

Next tactic:
cases' s with a s