Theorem: Ordnode.Valid'.rotateL
File: Mathlib/Data/Ordmap/Ordset.lean

tactic: cases' r with rs rl rx rr
state_before: α : 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₂

tactic: rw [hr.2.size_eq, Nat.lt_succ_iff] at H2
state_before: 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₂

tactic: rw [hr.2.size_eq] at H3
state_before: 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₂

tactic: 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
state_before: 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₂

tactic: 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
state_before: 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₂

tactic: 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
state_before: 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₂

tactic: have ablem : ∀ {a b : ℕ}, 1 ≤ a → a + b ≤ 2 → b ≤ 1 := by intros ; linarith
state_before: 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₂

tactic: 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)
state_before: 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₂

tactic: rw [rotateL]
state_before: 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₂

tactic: split_ifs with h
state_before: 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₂

tactic: cases H2
state_before: 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₂

tactic: intro l0
state_before: α : 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

tactic: rw [l0] at H3
state_before: α : 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

tactic: exact
  (or_iff_right_of_imp fun h => (mul_le_mul_left (by decide)).1 (le_trans h (by decide))).1 H3
state_before: α : 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

tactic: decide
state_before: α : 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

tactic: decide
state_before: α : 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

tactic: intro
state_before: α : 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

tactic: linarith
state_before: α : 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

tactic: intros
state_before: α : 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

tactic: linarith
state_before: α : 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

tactic: decide
state_before: α : 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

tactic: have rr0 : size rr > 0 :=
  (mul_lt_mul_left (by decide)).1 (lt_of_le_of_lt (Nat.zero_le _) h : ratio * 0 < _)
state_before: 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₂

tactic: 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
state_before: 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₂

tactic: cases' Nat.eq_zero_or_pos (size l) with l0 l0
state_before: 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)

tactic: replace H3 := H3p l0
state_before: 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)

tactic: rcases hr.3.1.resolve_left (hlp l0) with ⟨_, hb₂⟩
state_before: 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)

tactic: refine' ⟨Or.inr ⟨_, _⟩, Or.inr ⟨_, _⟩⟩
state_before: 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)

tactic: decide
state_before: α : 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

tactic: exact hl.node3L hr.left hr.right this.1 this.2
state_before: α : 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₂

tactic: rw [l0]
state_before: 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)

tactic: replace H3 := H3_0 l0
state_before: 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)

tactic: have := hr.3.1
state_before: 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)

tactic: cases' Nat.eq_zero_or_pos (size rl) with rl0 rl0
state_before: 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)

tactic: have rr1 : size rr = 1 := le_antisymm (ablem rl0 H3) rr0
state_before: 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)

tactic: rw [add_comm] at H3
state_before: 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)

tactic: rw [rr1, show size rl = 1 from le_antisymm (ablem rr0 H3) rl0]
state_before: 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)

tactic: decide
state_before: 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

tactic: rw [rl0] at this ⊢
state_before: 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)

tactic: rw [le_antisymm (balancedSz_zero.1 this.symm) rr0]
state_before: 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)

tactic: decide
state_before: 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

tactic: exact Valid'.rotateL_lemma₁ H2 hb₂
state_before: 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

tactic: exact Nat.le_of_lt_succ (Valid'.rotateL_lemma₂ H3 h)
state_before: 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

tactic: exact Valid'.rotateL_lemma₃ H2 h
state_before: 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

tactic: exact
  le_trans hb₂
    (Nat.mul_le_mul_left _ <| le_trans (Nat.le_add_left _ _) (Nat.le_add_right _ _))
state_before: 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)

tactic: cases' Nat.eq_zero_or_pos (size rl) with rl0 rl0
state_before: 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₂

tactic: refine' hl.node4L hr.left hr.right rl0 _
state_before: 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₂

tactic: cases' Nat.eq_zero_or_pos (size l) with l0 l0
state_before: 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

tactic: exact
  Or.inr ⟨l0, not_lt.1 h, H2, Valid'.rotateL_lemma₄ (H3p l0), (hr.3.1.resolve_left (hlp l0)).1⟩
state_before: 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

tactic: rw [rl0, not_lt, le_zero_iff, Nat.mul_eq_zero] at h
state_before: 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₂

tactic: replace h := h.resolve_left (by decide)
state_before: 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₂

tactic: erw [rl0, h, le_zero_iff, Nat.mul_eq_zero] at H2
state_before: 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₂

tactic: rw [hr.2.size_eq, rl0, h, H2.resolve_left (by decide)] at H1
state_before: 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₂

tactic: cases H1 (by decide)
state_before: 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₂

tactic: decide
state_before: α : 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

tactic: decide
state_before: α : 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

tactic: decide
state_before: α : 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

tactic: replace H3 := H3_0 l0
state_before: 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

tactic: cases' Nat.eq_zero_or_pos (size rr) with rr0 rr0
state_before: 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

tactic: exact Or.inl ⟨l0, le_antisymm (ablem rr0 <| by rwa [add_comm]) rl0, ablem rl0 H3⟩
state_before: 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

tactic: have := hr.3.1
state_before: 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

tactic: rw [rr0] at this
state_before: 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

tactic: exact Or.inl ⟨l0, le_antisymm (balancedSz_zero.1 this) rl0, rr0.symm ▸ zero_le_one⟩
state_before: 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

tactic: rwa [add_comm]
state_before: α : 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