l3lab/ntp-mathlib huggingface dataset:
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals 

Proof state:
case nil.node.nil.node.refl.refl.hc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rrx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' nil rx (node 1 nil rrx nil))
sr : Sized (node rs nil rx (node 1 nil rrx nil))
⊢ 0 + 1 + 1 > 0

Next tactic:
dsimp only [size]
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; 

Proof state:
case nil.node.nil.node.refl.refl.hc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rrx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' nil rx (node 1 nil rrx nil))
sr : Sized (node rs nil rx (node 1 nil rrx nil))
⊢ 0 + 1 + 1 > 0

Next tactic:
decide
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals 

Proof state:
case nil.node.nil.node.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rrx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' nil rx (node 1 nil rrx nil))
sr : Sized (node rs nil rx (node 1 nil rrx nil))
⊢ ¬0 + (0 + 1 + 1) ≤ 1

Next tactic:
dsimp only [size]
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; 

Proof state:
case nil.node.nil.node.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rrx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' nil rx (node 1 nil rrx nil))
sr : Sized (node rs nil rx (node 1 nil rrx nil))
⊢ ¬0 + (0 + 1 + 1) ≤ 1

Next tactic:
decide
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · 

Proof state:
case nil.node.node.nil
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rll : Ordnode α
rlx : α
rlr : Ordnode α
hr : Balanced (node' (node rls rll rlx rlr) rx nil)
sr : Sized (node rs (node rls rll rlx rlr) rx nil)
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) =
    if 0 + (rls + 1) ≤ 1 then node' nil x (node' (node rls rll rlx rlr) rx nil)
    else
      if rls + 1 > 0 then rotateL nil x (node' (node rls rll rlx rlr) rx nil)
      else
        if 0 > delta * (rls + 1) then rotateR nil x (node' (node rls rll rlx rlr) rx nil)
        else node' nil x (node' (node rls rll rlx rlr) rx nil)

Next tactic:
have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          

Proof state:
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rll : Ordnode α
rlx : α
rlr : Ordnode α
hr : Balanced (node' (node rls rll rlx rlr) rx nil)
sr : Sized (node rs (node rls rll rlx rlr) rx nil)
⊢ size rll = 0 ∧ size rlr = 0

Next tactic:
have := balancedSz_zero.1 hr.1
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          

Proof state:
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rll : Ordnode α
rlx : α
rlr : Ordnode α
hr : Balanced (node' (node rls rll rlx rlr) rx nil)
sr : Sized (node rs (node rls rll rlx rlr) rx nil)
this : size (node rls rll rlx rlr) ≤ 1
⊢ size rll = 0 ∧ size rlr = 0

Next tactic:
rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        

Proof state:
case nil.node.node.nil
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rll : Ordnode α
rlx : α
rlr : Ordnode α
hr : Balanced (node' (node rls rll rlx rlr) rx nil)
sr : Sized (node rs (node rls rll rlx rlr) rx nil)
this : size rll = 0 ∧ size rlr = 0
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) =
    if 0 + (rls + 1) ≤ 1 then node' nil x (node' (node rls rll rlx rlr) rx nil)
    else
      if rls + 1 > 0 then rotateL nil x (node' (node rls rll rlx rlr) rx nil)
      else
        if 0 > delta * (rls + 1) then rotateR nil x (node' (node rls rll rlx rlr) rx nil)
        else node' nil x (node' (node rls rll rlx rlr) rx nil)

Next tactic:
cases sr.2.1.2.1.size_eq_zero.1 this.1
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        

Proof state:
case nil.node.node.nil.refl
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rlx : α
rlr : Ordnode α
hr : Balanced (node' (node rls nil rlx rlr) rx nil)
sr : Sized (node rs (node rls nil rlx rlr) rx nil)
this : size nil = 0 ∧ size rlr = 0
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) =
    if 0 + (rls + 1) ≤ 1 then node' nil x (node' (node rls nil rlx rlr) rx nil)
    else
      if rls + 1 > 0 then rotateL nil x (node' (node rls nil rlx rlr) rx nil)
      else
        if 0 > delta * (rls + 1) then rotateR nil x (node' (node rls nil rlx rlr) rx nil)
        else node' nil x (node' (node rls nil rlx rlr) rx nil)

Next tactic:
cases sr.2.1.2.2.size_eq_zero.1 this.2
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        

Proof state:
case nil.node.node.nil.refl.refl
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx : α
rls : ℕ
rlx : α
hr : Balanced (node' (node rls nil rlx nil) rx nil)
sr : Sized (node rs (node rls nil rlx nil) rx nil)
this : size nil = 0 ∧ size nil = 0
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) =
    if 0 + (rls + 1) ≤ 1 then node' nil x (node' (node rls nil rlx nil) rx nil)
    else
      if rls + 1 > 0 then rotateL nil x (node' (node rls nil rlx nil) rx nil)
      else
        if 0 > delta * (rls + 1) then rotateR nil x (node' (node rls nil rlx nil) rx nil)
        else node' nil x (node' (node rls nil rlx nil) rx nil)

Next tactic:
obtain rfl : rls = 1 := sr.2.1.1
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        

Proof state:
case nil.node.node.nil.refl.refl
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) =
    if 0 + (1 + 1) ≤ 1 then node' nil x (node' (node 1 nil rlx nil) rx nil)
    else
      if 1 + 1 > 0 then rotateL nil x (node' (node 1 nil rlx nil) rx nil)
      else
        if 0 > delta * (1 + 1) then rotateR nil x (node' (node 1 nil rlx nil) rx nil)
        else node' nil x (node' (node 1 nil rlx nil) rx nil)

Next tactic:
rw [if_neg, if_pos, rotateL, if_neg]
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        rw [if_neg, if_pos, rotateL, if_neg]; · 

Proof state:
case nil.node.node.nil.refl.refl
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx) = node4L nil x (node 1 nil rlx nil) rx nil

Next tactic:
rfl
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        rw [if_neg, if_pos, rotateL, if_neg]; · rfl
        

Proof state:
case nil.node.node.nil.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ ¬size (node 1 nil rlx nil) < ratio * size nil
case nil.node.node.nil.refl.refl.hc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ 1 + 1 > 0
case nil.node.node.nil.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ ¬0 + (1 + 1) ≤ 1

Next tactic:
all_goals dsimp only [size]; decide
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        rw [if_neg, if_pos, rotateL, if_neg]; · rfl
        all_goals 

Proof state:
case nil.node.node.nil.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ ¬size (node 1 nil rlx nil) < ratio * size nil

Next tactic:
dsimp only [size]
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        rw [if_neg, if_pos, rotateL, if_neg]; · rfl
        all_goals dsimp only [size]; 

Proof state:
case nil.node.node.nil.refl.refl.hnc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ ¬1 < ratio * 0

Next tactic:
decide
theorem balance_eq_balance' {l x r} (hl : Balanced l) (hr : Balanced r) (sl : Sized l)
    (sr : Sized r) : @balance α l x r = balance' l x r := by
  cases' l with ls ll lx lr
  · cases' r with rs rl rx rr
    · rfl
    · rw [sr.eq_node'] at hr ⊢
      cases' rl with rls rll rlx rlr <;> cases' rr with rrs rrl rrx rrr <;>
        dsimp [balance, balance']
      · rfl
      · have : size rrl = 0 ∧ size rrr = 0 := by
          have := balancedSz_zero.1 hr.1.symm
          rwa [size, sr.2.2.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.2.2.1.size_eq_zero.1 this.1
        cases sr.2.2.2.2.size_eq_zero.1 this.2
        obtain rfl : rrs = 1 := sr.2.2.1
        rw [if_neg, if_pos, rotateL, if_pos]; · rfl
        all_goals dsimp only [size]; decide
      · have : size rll = 0 ∧ size rlr = 0 := by
          have := balancedSz_zero.1 hr.1
          rwa [size, sr.2.1.1, Nat.succ_le_succ_iff, le_zero_iff, add_eq_zero_iff] at this
        cases sr.2.1.2.1.size_eq_zero.1 this.1
        cases sr.2.1.2.2.size_eq_zero.1 this.2
        obtain rfl : rls = 1 := sr.2.1.1
        rw [if_neg, if_pos, rotateL, if_neg]; · rfl
        all_goals 

Proof state:
case nil.node.node.nil.refl.refl.hc
α : Type u_1
x : α
hl : Balanced nil
sl : Sized nil
rs : ℕ
rx rlx : α
this : size nil = 0 ∧ size nil = 0
hr : Balanced (node' (node 1 nil rlx nil) rx nil)
sr : Sized (node rs (node 1 nil rlx nil) rx nil)
⊢ 1 + 1 > 0

Next tactic:
dsimp only [size]