case nil
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
hr : Valid' (↑x) nil o₂
H1 : ¬size l + size nil ≤ 1
H2 : delta * size l < size nil
H3 : 2 * size nil ≤ 9 * size l + 5 ∨ size nil ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x nil) o₂

case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l < size (Ordnode.node rs rl rx rr)
H3 : 2 * size (Ordnode.node rs rl rx rr) ≤ 9 * size l + 5 ∨ size (Ordnode.node rs rl rx rr) ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
r : Ordnode α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
hr : Valid' (↑x) r o₂
H1 : ¬size l + size r ≤ 1
H2 : delta * size l < size r
H3 : 2 * size r ≤ 9 * size l + 5 ∨ size r ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x r) o₂
cases' r with rs rl rx rr
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * size (Ordnode.node rs rl rx rr) ≤ 9 * size l + 5 ∨ size (Ordnode.node rs rl rx rr) ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l < size (Ordnode.node rs rl rx rr)
H3 : 2 * size (Ordnode.node rs rl rx rr) ≤ 9 * size l + 5 ∨ size (Ordnode.node rs rl rx rr) ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
rw [hr.2.size_eq, Nat.lt_succ_iff] at H2
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr + 1) ≤ 9 * size l + 5 ∨ size rl + size rr + 1 ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * size (Ordnode.node rs rl rx rr) ≤ 9 * size l + 5 ∨ size (Ordnode.node rs rl rx rr) ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
rw [hr.2.size_eq] at H3
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr + 1) ≤ 9 * size l + 5 ∨ size rl + size rr + 1 ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
replace H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2 :=
  H3.imp (@Nat.le_of_add_le_add_right _ 2 _) Nat.le_of_succ_le_succ
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
have H3_0 : size l = 0 → size rl + size rr ≤ 2 := by
  intro l0; rw [l0] at H3
  exact
    (or_iff_right_of_imp fun h => (mul_le_mul_left (by decide)).1 (le_trans h (by decide))).1 H3
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
have H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3 := fun l0 : 1 ≤ size l =>
  (or_iff_left_of_imp <| by intro; linarith).1 H3
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
have ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1 := by intros ; linarith
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
have hlp : size l > 0 → ¬size rl + size rr ≤ 1 := fun l0 hb =>
  absurd (le_trans (le_trans (Nat.mul_le_mul_left _ l0) H2) hb) (by decide)
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
⊢ Valid' o₁ (if size rl < ratio * size rr then Ordnode.node3L l x rl rx rr else Ordnode.node4L l x rl rx rr) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
⊢ Valid' o₁ (Ordnode.rotateL l x (Ordnode.node rs rl rx rr)) o₂
rw [rotateL]
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
⊢ Valid' o₁ (Ordnode.node3L l x rl rx rr) o₂

case node.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
⊢ Valid' o₁ (if size rl < ratio * size rr then Ordnode.node3L l x rl rx rr else Ordnode.node4L l x rl rx rr) o₂
split_ifs with h
no goals
case nil
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
hr : Valid' (↑x) nil o₂
H1 : ¬size l + size nil ≤ 1
H2 : delta * size l < size nil
H3 : 2 * size nil ≤ 9 * size l + 5 ∨ size nil ≤ 3
⊢ Valid' o₁ (Ordnode.rotateL l x nil) o₂
cases H2
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
⊢ size rl + size rr ≤ 2
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
⊢ size l = 0 → size rl + size rr ≤ 2
intro l0
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * 0 + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
⊢ size rl + size rr ≤ 2
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
⊢ size rl + size rr ≤ 2
rw [l0] at H3
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * 0 + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
⊢ size rl + size rr ≤ 2
exact
  (or_iff_right_of_imp fun h => (mul_le_mul_left (by decide)).1 (le_trans h (by decide))).1 H3
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * 0 + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
h : 2 * (size rl + size rr) ≤ 9 * 0 + 3
⊢ 0 < 2
decide
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * 0 + 3 ∨ size rl + size rr ≤ 2
l0 : size l = 0
h : 2 * (size rl + size rr) ≤ 9 * 0 + 3
⊢ 9 * 0 + 3 ≤ 2 * 2
decide
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
l0 : 1 ≤ size l
a✝ : size rl + size rr ≤ 2
⊢ 2 * (size rl + size rr) ≤ 9 * size l + 3
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
l0 : 1 ≤ size l
⊢ size rl + size rr ≤ 2 → 2 * (size rl + size rr) ≤ 9 * size l + 3
intro
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
l0 : 1 ≤ size l
a✝ : size rl + size rr ≤ 2
⊢ 2 * (size rl + size rr) ≤ 9 * size l + 3
linarith
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
a✝² b✝ : ℕ
a✝¹ : 1 ≤ a✝²
a✝ : a✝² + b✝ ≤ 2
⊢ b✝ ≤ 1
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
⊢ ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
intros
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
a✝² b✝ : ℕ
a✝¹ : 1 ≤ a✝²
a✝ : a✝² + b✝ ≤ 2
⊢ b✝ ≤ 1
linarith
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
l0 : size l > 0
hb : size rl + size rr ≤ 1
⊢ ¬delta * Nat.succ 0 ≤ 1
decide
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
⊢ Valid' o₁ (Ordnode.node3L l x rl rx rr) o₂
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
⊢ Valid' o₁ (Ordnode.node3L l x rl rx rr) o₂
have rr0 : size rr > 0 :=
  (mul_lt_mul_left (by decide)).1 (lt_of_le_of_lt (Nat.zero_le _) h : ratio * 0 < _)
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
⊢ Valid' o₁ (Ordnode.node3L l x rl rx rr) o₂
suffices BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr) by
  exact hl.node3L hr.left hr.right this.1 this.2
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)

case node.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
case node.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
cases' Nat.eq_zero_or_pos (size l) with l0 l0
case node.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
case node.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
replace H3 := H3p l0
case node.inl.inr.intro
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
case node.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
rcases hr.3.1.resolve_left (hlp l0) with ⟨_, hb₂⟩
case node.inl.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size l ≤ delta * size rl

case node.inl.inr.intro.refine'_2
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size rl ≤ delta * size l

case node.inl.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size l + size rl + 1 ≤ delta * size rr

case node.inl.inr.intro.refine'_4
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size rr ≤ delta * (size l + size rl + 1)
case node.inl.inr.intro
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
refine' ⟨Or.inr ⟨_, _⟩, Or.inr ⟨_, _⟩⟩
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
⊢ 0 < ratio
decide
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
this : BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
⊢ Valid' o₁ (Ordnode.node3L l x rl rx rr) o₂
exact hl.node3L hr.left hr.right this.1 this.2
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
⊢ BalancedSz (size l) (size rl) ∧ BalancedSz (size l + size rl + 1) (size rr)
rw [l0]
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
replace H3 := H3_0 l0
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
have := hr.3.1
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)

case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
cases' Nat.eq_zero_or_pos (size rl) with rl0 rl0
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
have rr1 : size rr = 1 := le_antisymm (ablem rl0 H3) rr0
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rr + size rl ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
rw [add_comm] at H3
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rr + size rl ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 1 ∧ BalancedSz (0 + 1 + 1) 1
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rr + size rl ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
rw [rr1, show size rl = 1 from le_antisymm (ablem rr0 H3) rl0]
no goals
case node.inl.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rr + size rl ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl > 0
rr1 : size rr = 1
⊢ BalancedSz 0 1 ∧ BalancedSz (0 + 1 + 1) 1
decide
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz 0 (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 0 ∧ BalancedSz (0 + 0 + 1) (size rr)
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz (size rl) (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 (size rl) ∧ BalancedSz (0 + size rl + 1) (size rr)
rw [rl0] at this ⊢
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz 0 (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 0 ∧ BalancedSz (0 + 0 + 1) 1
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz 0 (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 0 ∧ BalancedSz (0 + 0 + 1) (size rr)
rw [le_antisymm (balancedSz_zero.1 this.symm) rr0]
no goals
case node.inl.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
this : BalancedSz 0 (size rr)
rl0 : size rl = 0
⊢ BalancedSz 0 0 ∧ BalancedSz (0 + 0 + 1) 1
decide
no goals
case node.inl.inr.intro.refine'_1
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size l ≤ delta * size rl
exact Valid'.rotateL_lemma₁ H2 hb₂
no goals
case node.inl.inr.intro.refine'_2
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size rl ≤ delta * size l
exact Nat.le_of_lt_succ (Valid'.rotateL_lemma₂ H3 h)
no goals
case node.inl.inr.intro.refine'_3
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size l + size rl + 1 ≤ delta * size rr
exact Valid'.rotateL_lemma₃ H2 h
no goals
case node.inl.inr.intro.refine'_4
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : size rl < ratio * size rr
rr0 : size rr > 0
l0 : size l > 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3
left✝ : size rl ≤ delta * size rr
hb₂ : size rr ≤ delta * size rl
⊢ size rr ≤ delta * (size l + size rl + 1)
exact
  le_trans hb₂
    (Nat.mul_le_mul_left _ <| le_trans (Nat.le_add_left _ _) (Nat.le_add_right _ _))
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂

case node.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
cases' Nat.eq_zero_or_pos (size rl) with rl0 rl0
case node.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
refine' hl.node4L hr.left hr.right rl0 _
case node.inr.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr

case node.inr.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
cases' Nat.eq_zero_or_pos (size l) with l0 l0
no goals
case node.inr.inr.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
exact
  Or.inr ⟨l0, not_lt.1 h, H2, Valid'.rotateL_lemma₄ (H3p l0), (hr.3.1.resolve_left (hlp l0)).1⟩
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ratio = 0 ∨ size rr = 0
rl0 : size rl = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
rw [rl0, not_lt, le_zero_iff, Nat.mul_eq_zero] at h
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ratio = 0 ∨ size rr = 0
rl0 : size rl = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
replace h := h.resolve_left (by decide)
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
erw [rl0, h, le_zero_iff, Nat.mul_eq_zero] at H2
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬0 + (0 + 0 + 1) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
rw [hr.2.size_eq, rl0, h, H2.resolve_left (by decide)] at H1
no goals
case node.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬0 + (0 + 0 + 1) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ Valid' o₁ (Ordnode.node4L l x rl rx rr) o₂
cases H1 (by decide)
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ratio = 0 ∨ size rr = 0
rl0 : size rl = 0
⊢ ¬ratio = 0
decide
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + (0 + 0 + 1) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ ¬delta = 0
decide
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬0 + (0 + 0 + 1) ≤ 1
H2 : delta = 0 ∨ size l = 0
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
rl0 : size rl = 0
h : size rr = 0
⊢ 0 + (0 + 0 + 1) ≤ 1
decide
case node.inr.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3 : 2 * (size rl + size rr) ≤ 9 * size l + 3 ∨ size rl + size rr ≤ 2
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
replace H3 := H3_0 l0
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr

case node.inr.inr.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
cases' Nat.eq_zero_or_pos (size rr) with rr0 rr0
no goals
case node.inr.inr.inl.inr
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr > 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
exact Or.inl ⟨l0, le_antisymm (ablem rr0 <| by rwa [add_comm]) rl0, ablem rl0 H3⟩
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
this : BalancedSz (size rl) (size rr)
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
have := hr.3.1
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
this : BalancedSz (size rl) 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
this : BalancedSz (size rl) (size rr)
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
rw [rr0] at this
no goals
case node.inr.inr.inl.inl
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr = 0
this : BalancedSz (size rl) 0
⊢ size l = 0 ∧ size rl = 1 ∧ size rr ≤ 1 ∨
    0 < size l ∧
      ratio * size rr ≤ size rl ∧
        delta * size l ≤ size rl + size rr ∧ 3 * (size rl + size rr) ≤ 16 * size l + 9 ∧ size rl ≤ delta * size rr
exact Or.inl ⟨l0, le_antisymm (balancedSz_zero.1 this) rl0, rr0.symm ▸ zero_le_one⟩
no goals
α : Type u_1
inst✝ : Preorder α
l : Ordnode α
x : α
o₁ : WithBot α
o₂ : WithTop α
hl : Valid' o₁ l ↑x
rs : ℕ
rl : Ordnode α
rx : α
rr : Ordnode α
hr : Valid' (↑x) (Ordnode.node rs rl rx rr) o₂
H1 : ¬size l + size (Ordnode.node rs rl rx rr) ≤ 1
H2 : delta * size l ≤ size rl + size rr
H3_0 : size l = 0 → size rl + size rr ≤ 2
H3p : size l > 0 → 2 * (size rl + size rr) ≤ 9 * size l + 3
ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1
hlp : size l > 0 → ¬size rl + size rr ≤ 1
h : ¬size rl < ratio * size rr
rl0 : size rl > 0
l0 : size l = 0
H3 : size rl + size rr ≤ 2
rr0 : size rr > 0
⊢ size rr + size rl ≤ 2
rwa [add_comm]