Theorem: Stream'.WSeq.liftRel_join.lem
File: Mathlib/Data/Seq/WSeq.lean

tactic: cases' exists_results_of_mem ma with n h
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
S : WSeq (WSeq α)
T : WSeq (WSeq β)
U : WSeq α → WSeq β → Prop
ST : LiftRel (LiftRel R) S T
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
a : Option (α × WSeq α)
ma : a ∈ destruct (join S)
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: clear ma
state_before: case intro
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
S : WSeq (WSeq α)
T : WSeq (WSeq β)
U : WSeq α → WSeq β → Prop
ST : LiftRel (LiftRel R) S T
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
a : Option (α × WSeq α)
ma : a ∈ destruct (join S)
n : ℕ
h : Results (destruct (join S)) a n
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: revert S T ST a
state_before: case intro
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
S : WSeq (WSeq α)
T : WSeq (WSeq β)
U : WSeq α → WSeq β → Prop
ST : LiftRel (LiftRel R) S T
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
a : Option (α × WSeq α)
n : ℕ
h : Results (destruct (join S)) a n
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: induction' n using Nat.strongInductionOn with n IH
state_before: case intro
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
⊢ ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
    LiftRel (LiftRel R) S T →
      ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a n → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: intro S T ST a ra
state_before: case intro.ind
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
⊢ ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
    LiftRel (LiftRel R) S T →
      ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a n → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: simp [destruct_join] at ra
state_before: case intro.ind
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra : Results (destruct (join S)) a n
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: simp only [destruct_join]
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
x✝¹ : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) none none
x✝ : Results (destruct S) none m
rs2 :
  Results
    (match none with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
mT : none ∈ destruct T
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: exact ⟨none, mem_bind mT (ret_mem _), by rw [eq_of_pure_mem rs2.mem]; trivial⟩
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
x✝¹ : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) none none
x✝ : Results (destruct S) none m
rs2 :
  Results
    (match none with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
mT : none ∈ destruct T
⊢ ∃ b, b ∈ Computation.bind (destruct T) destruct_join.aux ∧ LiftRelO R U a b

tactic: rw [eq_of_pure_mem rs2.mem]
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
x✝¹ : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) none none
x✝ : Results (destruct S) none m
rs2 :
  Results
    (match none with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
mT : none ∈ destruct T
⊢ LiftRelO R U a none

tactic: trivial
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
x✝¹ : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) none none
x✝ : Results (destruct S) none m
rs2 :
  Results
    (match none with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
mT : none ∈ destruct T
⊢ LiftRelO R U none none

tactic: simp [destruct_append] at rs2
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝ : Results (destruct S) (some (s, S')) m
rs2 :
  Results
    (match some (s, S') with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
mT : some (t, T') ∈ destruct T
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: have : n1 < n := by
  rw [en, ek, ek1]
  apply lt_of_lt_of_le _ (Nat.le_add_right _ _)
  apply Nat.lt_succ_of_le (Nat.le_add_right _ _)
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: let ⟨ob, mb, rob⟩ := IH _ this ST' rs5'
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: refine' ⟨ob, _, rob⟩
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b

tactic: rw [en, ek, ek1]
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
⊢ n1 < n

tactic: apply lt_of_lt_of_le _ (Nat.le_add_right _ _)
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
⊢ n1 < n1 + m1 + 1 + m

tactic: apply Nat.lt_succ_of_le (Nat.le_add_right _ _)
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
⊢ n1 < n1 + m1 + 1

tactic: simp [destruct_join]
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈ destruct (join T)

tactic: apply mem_bind mT
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈
    Computation.bind (destruct T) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S)))

tactic: simp [destruct_append]
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈
    match some (t, T') with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S)))

tactic: apply think_mem
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈
    Computation.think
      (Computation.bind (destruct t) fun x =>
        match x with
        | none => destruct (join T')
        | some (a, s) => Computation.pure (some (a, append s (join T'))))

tactic: apply mem_bind mt
state_before: case a
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈
    Computation.bind (destruct t) fun x =>
      match x with
      | none => destruct (join T')
      | some (a, s) => Computation.pure (some (a, append s (join T')))

tactic: exact mb
state_before: case a
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝² : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5 :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
x✝¹ : LiftRelO R (LiftRel R) none none
x✝ : Results (destruct s) none m1
rs5' :
  Results
    (match none with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a n1
mt : none ∈ destruct t
this : n1 < n
ob : Option (β × WSeq β)
mb : ob ∈ destruct (join T')
rob : LiftRelO R U a ob
⊢ ob ∈
    match none with
    | none => destruct (join T')
    | some (a, s) => Computation.pure (some (a, append s (join T')))

tactic: simp at rs5
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 :
  Results
    (match some (a, s') with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
mt : some (b, t') ∈ destruct t
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a✝ b

tactic: refine' ⟨some (b, append t' (join T')), _, _⟩
state_before: α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a✝ b

tactic: rw [eq_of_pure_mem rs5.mem]
state_before: case refine'_2
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ LiftRelO R U a✝ (some (b, append t' (join T')))

tactic: exact ⟨ab, HU _ _ ⟨s', t', S', T', rfl, rfl, st', ST'⟩⟩
state_before: case refine'_2
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ LiftRelO R U (some (a, append s' (join S'))) (some (b, append t' (join T')))

tactic: simp [destruct_join]
state_before: case refine'_1
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈ destruct (join T)

tactic: apply mem_bind mT
state_before: case refine'_1
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈
    Computation.bind (destruct T) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S)))

tactic: simp [destruct_append]
state_before: case refine'_1
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈
    match some (t, T') with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S)))

tactic: apply think_mem
state_before: case refine'_1
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈
    Computation.think
      (Computation.bind (destruct t) fun x =>
        match x with
        | none => destruct (join T')
        | some (a, s) => Computation.pure (some (a, append s (join T'))))

tactic: apply mem_bind mt
state_before: case refine'_1.a
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈
    Computation.bind (destruct t) fun x =>
      match x with
      | none => destruct (join T')
      | some (a, s) => Computation.pure (some (a, append s (join T')))

tactic: apply ret_mem
state_before: case refine'_1.a
α : Type u
β : Type v
γ : Type w
R : α → β → Prop
U : WSeq α → WSeq β → Prop
HU :
  ∀ (s1 : WSeq α) (s2 : WSeq β),
    (∃ s t S T, s1 = append s (join S) ∧ s2 = append t (join T) ∧ LiftRel R s t ∧ LiftRel (LiftRel R) S T) → U s1 s2
n : ℕ
IH :
  ∀ (m : ℕ),
    m < n →
      ∀ {S : WSeq (WSeq α)} {T : WSeq (WSeq β)},
        LiftRel (LiftRel R) S T →
          ∀ {a : Option (α × WSeq α)}, Results (destruct (join S)) a m → ∃ b, b ∈ destruct (join T) ∧ LiftRelO R U a b
S : WSeq (WSeq α)
T : WSeq (WSeq β)
ST : LiftRel (LiftRel R) S T
a✝ : Option (α × WSeq α)
ra :
  Results
    (Computation.bind (destruct S) fun x =>
      match x with
      | none => Computation.pure none
      | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ n
o : Option (WSeq α × WSeq (WSeq α))
m k : ℕ
rs1 : Results (destruct S) o m
rs2✝ :
  Results
    (match o with
    | none => Computation.pure none
    | some (s, S) => Computation.think (destruct (append s (join S))))
    a✝ k
en : n = k + m
p : Option (WSeq β × WSeq (WSeq β))
mT✝ : p ∈ destruct T
rop : LiftRelO (LiftRel R) (LiftRel (LiftRel R)) o p
s : WSeq α
S' : WSeq (WSeq α)
t : WSeq β
T' : WSeq (WSeq β)
st : LiftRel R s t
ST' : LiftRel (LiftRel R) S' T'
x✝¹ : Results (destruct S) (some (s, S')) m
mT : some (t, T') ∈ destruct T
rs2 :
  Results
    (Computation.think
      (Computation.bind (destruct s) fun x =>
        match x with
        | none => destruct (join S')
        | some (a, s) => Computation.pure (some (a, append s (join S')))))
    a✝ k
k1 : ℕ
rs3 :
  Results
    (Computation.bind (destruct s) fun x =>
      match x with
      | none => destruct (join S')
      | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ k1
ek : k = k1 + 1
o' : Option (α × WSeq α)
m1 n1 : ℕ
rs4 : Results (destruct s) o' m1
rs5✝ :
  Results
    (match o' with
    | none => destruct (join S')
    | some (a, s) => Computation.pure (some (a, append s (join S'))))
    a✝ n1
ek1 : k1 = n1 + m1
p' : Option (β × WSeq β)
mt✝ : p' ∈ destruct t
rop' : LiftRelO R (LiftRel R) o' p'
a : α
s' : WSeq α
b : β
t' : WSeq β
ab : R a b
st' : LiftRel R s' t'
x✝ : Results (destruct s) (some (a, s')) m1
rs5 : Results (Computation.pure (some (a, append s' (join S')))) a✝ n1
mt : some (b, t') ∈ destruct t
⊢ some (b, append t' (join T')) ∈
    match some (b, t') with
    | none => destruct (join T')
    | some (a, s) => Computation.pure (some (a, append s (join T')))