case nil
α : Type u_1
inst✝ : Preorder α
r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hr : Valid' o₁ r o₂
hl : Valid' o₁ nil o₂
sep : All (fun x => All (fun y => x < y) r) nil
bal : BalancedSz (size nil) (size r)
⊢ Valid' o₁ (glue nil r) o₂ ∧ size (glue nil r) = size nil + size r

case node
α : Type u_1
inst✝ : Preorder α
r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hr : Valid' o₁ r o₂
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
sep : All (fun x => All (fun y => x < y) r) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size r)
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) r) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) r) = size (Ordnode.node ls ll lx lr) + size r
α : Type u_1
inst✝ : Preorder α
l r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l o₂
hr : Valid' o₁ r o₂
sep : All (fun x => All (fun y => x < y) r) l
bal : BalancedSz (size l) (size r)
⊢ Valid' o₁ (glue l r) o₂ ∧ size (glue l r) = size l + size r
cases' l with ls ll lx lr
case node.nil
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
hr : Valid' o₁ nil o₂
sep : All (fun x => All (fun y => x < y) nil) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size nil)
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) nil) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) nil) = size (Ordnode.node ls ll lx lr) + size nil

case node.node
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) (Ordnode.node rs rl rx rr)) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) (Ordnode.node rs rl rx rr)) =
      size (Ordnode.node ls ll lx lr) + size (Ordnode.node rs rl rx rr)
case node
α : Type u_1
inst✝ : Preorder α
r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hr : Valid' o₁ r o₂
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
sep : All (fun x => All (fun y => x < y) r) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size r)
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) r) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) r) = size (Ordnode.node ls ll lx lr) + size r
cases' r with rs rl rx rr
case node.node
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
⊢ Valid' o₁
      (if ls > rs then Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)
      else Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd)
      o₂ ∧
    size
        (if ls > rs then Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)
        else Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) =
      ls + rs
case node.node
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) (Ordnode.node rs rl rx rr)) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) (Ordnode.node rs rl rx rr)) =
      size (Ordnode.node ls ll lx lr) + size (Ordnode.node rs rl rx rr)
dsimp [glue]
case node.node.inl
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ Valid' o₁ (Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)) o₂ ∧
    size (Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)) = ls + rs

case node.node.inr
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ Valid' o₁ (Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) o₂ ∧
    size (Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) = ls + rs
case node.node
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
⊢ Valid' o₁
      (if ls > rs then Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)
      else Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd)
      o₂ ∧
    size
        (if ls > rs then Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)
        else Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) =
      ls + rs
split_ifs
no goals
case nil
α : Type u_1
inst✝ : Preorder α
r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hr : Valid' o₁ r o₂
hl : Valid' o₁ nil o₂
sep : All (fun x => All (fun y => x < y) r) nil
bal : BalancedSz (size nil) (size r)
⊢ Valid' o₁ (glue nil r) o₂ ∧ size (glue nil r) = size nil + size r
exact ⟨hr, (zero_add _).symm⟩
no goals
case node.nil
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
hr : Valid' o₁ nil o₂
sep : All (fun x => All (fun y => x < y) nil) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size nil)
⊢ Valid' o₁ (glue (Ordnode.node ls ll lx lr) nil) o₂ ∧
    size (glue (Ordnode.node ls ll lx lr) nil) = size (Ordnode.node ls ll lx lr) + size nil
exact ⟨hl, rfl⟩
case node.node.inl
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
case node.node.inl
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ Valid' o₁ (Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)) o₂ ∧
    size (Ordnode.balanceR (splitMax' ll lx lr).fst (splitMax' ll lx lr).snd (Ordnode.node rs rl rx rr)) = ls + rs
rw [splitMax_eq]
case node.node.inl.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
case node.node.inl
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
cases' Valid'.eraseMax_aux hl with v e
case node.node.inl.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H : ?m.349956
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ ?m.349956

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
case node.node.inl.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
suffices H
case node.node.inl.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ Bounded nil (↑(eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).snd) o₂

case node.node.inl.intro.refine'_2
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ All (fun x => x > (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).snd)
    (Ordnode.node rs rl rx rr)

case node.node.inl.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ size
      (Ordnode.balanceR (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
    ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
case node.node.inl.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H : ?m.349956
⊢ Valid' o₁
      (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr))
      o₂ ∧
    size
        (Ordnode.balanceR (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).fst
          (eraseMax (Ordnode.node ?node.node.inl.s ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
      ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ ?m.349956

case node.node.inl.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
⊢ ℕ
refine' ⟨Valid'.balanceR v (hr.of_gt _ _) H, _⟩
case node.node.inl.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ ∀ (a : α), All (fun y => a < y) (Ordnode.node rs rl rx rr) → Bounded nil (↑a) o₂
case node.node.inl.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ Bounded nil (↑(eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).snd) o₂
refine' findMax'_all (P := fun a : α => Bounded nil (a : WithTop α) o₂)
  lx lr hl.1.2.to_nil (sep.2.2.imp _)
no goals
case node.node.inl.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ ∀ (a : α), All (fun y => a < y) (Ordnode.node rs rl rx rr) → Bounded nil (↑a) o₂
exact fun x h => hr.1.2.to_nil.mono_left (le_of_lt h.2.1)
case node.node.inl.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ size (Ordnode.node' ll lx lr) + size (Ordnode.node rs rl rx rr) = size ll + size lr + 1 + rs
case node.node.inl.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ size
      (Ordnode.balanceR (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst
        (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).snd (Ordnode.node rs rl rx rr)) =
    ls + rs
rw [size_balanceR v.3 hr.3 v.2 hr.2 H, add_right_comm, ← e, hl.2.1]
no goals
case node.node.inl.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
H :
  (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
⊢ size (Ordnode.node' ll lx lr) + size (Ordnode.node rs rl rx rr) = size ll + size lr + 1 + rs
rfl
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ BalancedSz (size (Ordnode.node' ll lx lr)) (size (Ordnode.node rs rl rx rr))
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ (∃ l',
      Raised (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) l' ∧
        BalancedSz l' (size (Ordnode.node rs rl rx rr))) ∨
    ∃ r',
      Raised r' (size (Ordnode.node rs rl rx rr)) ∧
        BalancedSz (size (eraseMax (Ordnode.node (size ll + size lr + 1) ll lx lr), findMax' lx lr).fst) r'
refine' Or.inl ⟨_, Or.inr e, _⟩
no goals
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ls > rs
v : Valid' o₁ (eraseMax (Ordnode.node' ll lx lr)) ↑(findMax' lx lr)
e : size (Ordnode.node' ll lx lr) = size (eraseMax (Ordnode.node' ll lx lr)) + 1
⊢ BalancedSz (size (Ordnode.node' ll lx lr)) (size (Ordnode.node rs rl rx rr))
rwa [hl.2.eq_node'] at bal
case node.node.inr
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
case node.node.inr
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ Valid' o₁ (Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) o₂ ∧
    size (Ordnode.balanceL (Ordnode.node ls ll lx lr) (splitMin' rl rx rr).fst (splitMin' rl rx rr).snd) = ls + rs
rw [splitMin_eq]
case node.node.inr.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
case node.node.inr
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
cases' Valid'.eraseMin_aux hr with v e
case node.node.inr.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H : ?m.351034
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ ?m.351034

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
case node.node.inr.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
suffices H
case node.node.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ Bounded nil o₁ ↑(findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).fst

case node.node.inr.intro.refine'_2
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ All (fun x => x < (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).fst)
    (Ordnode.node ls ll lx lr)

case node.node.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ size
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) =
    ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
case node.node.inr.intro
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H : ?m.351034
⊢ Valid' o₁
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd)
      o₂ ∧
    size
        (Ordnode.balanceL (Ordnode.node ls ll lx lr)
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).fst
          (findMin' rl rx, eraseMin (Ordnode.node ?node.node.inr.s rl rx rr)).snd) =
      ls + rs

case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ ?m.351034

case node.node.inr.s
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
⊢ ℕ
refine' ⟨Valid'.balanceL (hl.of_lt _ _) v H, _⟩
case node.node.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ ∀ (a : α), lx < a → Bounded nil o₁ ↑a
case node.node.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ Bounded nil o₁ ↑(findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).fst
refine' @findMin'_all (P := fun a : α => Bounded nil o₁ (a : WithBot α))
  rl rx (sep.2.1.1.imp _) hr.1.1.to_nil
no goals
case node.node.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ ∀ (a : α), lx < a → Bounded nil o₁ ↑a
exact fun y h => hl.1.1.to_nil.mono_right (le_of_lt h)
case node.node.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ size (Ordnode.node ls ll lx lr) + size (Ordnode.node' rl rx rr) = ls + (size rl + size rr + 1)
case node.node.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ size
      (Ordnode.balanceL (Ordnode.node ls ll lx lr)
        (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).fst
        (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) =
    ls + rs
rw [size_balanceL hl.3 v.3 hl.2 v.2 H, add_assoc, ← e, hr.2.1]
no goals
case node.node.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
H :
  (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
⊢ size (Ordnode.node ls ll lx lr) + size (Ordnode.node' rl rx rr) = ls + (size rl + size rr + 1)
rfl
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node' rl rx rr))
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ (∃ l',
      Raised l' (size (Ordnode.node ls ll lx lr)) ∧
        BalancedSz l' (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd)) ∨
    ∃ r',
      Raised (size (findMin' rl rx, eraseMin (Ordnode.node (size rl + size rr + 1) rl rx rr)).snd) r' ∧
        BalancedSz (size (Ordnode.node ls ll lx lr)) r'
refine' Or.inr ⟨_, Or.inr e, _⟩
no goals
case H
α : Type u_1
inst✝ : Preorder α
o₁ : WithBot α
o₂ : WithTop α
ls : ℕ
ll : Ordnode α
lx : α
lr : Ordnode α
hl : Valid' o₁ (Ordnode.node ls ll lx lr) o₂
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' o₁ (Ordnode.node rs rl rx rr) o₂
sep : All (fun x => All (fun y => x < y) (Ordnode.node rs rl rx rr)) (Ordnode.node ls ll lx lr)
bal : BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node rs rl rx rr))
h✝ : ¬ls > rs
v : Valid' (↑(findMin' rl rx)) (eraseMin (Ordnode.node' rl rx rr)) o₂
e : size (Ordnode.node' rl rx rr) = size (eraseMin (Ordnode.node' rl rx rr)) + 1
⊢ BalancedSz (size (Ordnode.node ls ll lx lr)) (size (Ordnode.node' rl rx rr))
rwa [hr.2.eq_node'] at bal