theorem dual_balanceL (l : Ordnode α) (x : α) (r : Ordnode α) :
    dual (balanceL l x r) = balanceR (dual r) x (dual l) := by
  unfold balanceL balanceR
  cases' r with rs rl rx rr
  · cases' l with ls ll lx lr; · rfl
    cases' ll with lls lll llx llr <;> 

Proof state:
case nil.node.node
α : Type u_1
x : α
ls : ℕ
lx : α
lr : Ordnode α
lls : ℕ
lll : Ordnode α
llx : α
llr : Ordnode α
⊢ dual
      (Ordnode.casesOn (motive := fun t => id nil = t → Ordnode α) (id nil)
        (fun h =>
          Ordnode.casesOn (motive := fun t => id (node ls (node lls lll llx llr) lx lr) = t → Ordnode α)
            (id (node ls (node lls lll llx llr) lx lr)) (fun h => Ordnode.singleton x)
            (fun ls_1 ll lx_1 lr_1 h =>
              Ordnode.casesOn (motive := fun t => id ll = t → Ordnode α) (id ll)
                (fun h =>
                  Ordnode.casesOn (motive := fun t => lr_1 = t → Ordnode α) lr_1
                    (fun h => node 2 (node ls (node lls lll llx llr) lx lr) x nil)
                    (fun size l lrx r h => node 3 (Ordnode.singleton lx_1) lrx (Ordnode.singleton x)) (_ : lr_1 = lr_1))
                (fun lls l x_1 r h =>
                  Ordnode.casesOn (motive := fun t => id lr_1 = t → Ordnode α) (id lr_1)
                    (fun h => node 3 ll lx_1 (Ordnode.singleton x))
                    (fun lrs lrl lrx lrr h =>
                      if lrs < ratio * lls then node (ls_1 + 1) ll lx_1 (node (lrs + 1) lr_1 x nil)
                      else node (ls_1 + 1) (node (lls + size lrl + 1) ll lx_1 lrl) lrx (node (size lrr + 1) lrr x nil))
                    (_ : id lr_1 = id lr_1))
                (_ : id ll = id ll))
            (_ : id (node ls (node lls lll llx llr) lx lr) = id (node ls (node lls lll llx llr) lx lr)))
        (fun rs l x_1 r h =>
          Ordnode.casesOn (motive := fun t => id (node ls (node lls lll llx llr) lx lr) = t → Ordnode α)
            (id (node ls (node lls lll llx llr) lx lr)) (fun h => node (rs + 1) nil x nil)
            (fun ls_1 ll lx_1 lr_1 h =>
              if ls_1 > delta * rs then
                Ordnode.casesOn (motive := fun t => id ll = t → Ordnode α) (id ll) (fun h => nil)
                  (fun lls l x_2 r h =>
                    Ordnode.casesOn (motive := fun t => id lr_1 = t → Ordnode α) (id lr_1) (fun h => nil)
                      (fun lrs lrl lrx lrr h =>
                        if lrs < ratio * lls then node (ls_1 + rs + 1) ll lx_1 (node (rs + lrs + 1) lr_1 x nil)
                        else
                          node (ls_1 + rs + 1) (node (lls + size lrl + 1) ll lx_1 lrl) lrx
                            (node (size lrr + rs + 1) lrr x nil))
                      (_ : id lr_1 = id lr_1))
                  (_ : id ll = id ll)
              else node (ls_1 + rs + 1) (node ls (node lls lll llx llr) lx lr) x nil)
            (_ : id (node ls (node lls lll llx llr) lx lr) = id (node ls (node lls lll llx llr) lx lr)))
        (_ : id nil = id nil)) =
    Ordnode.casesOn (motive := fun t => id (dual nil) = t → Ordnode α) (id (dual nil))
      (fun h =>
        Ordnode.casesOn (motive := fun t => id (dual (node ls (node lls lll llx llr) lx lr)) = t → Ordnode α)
          (id (dual (node ls (node lls lll llx llr) lx lr))) (fun h => Ordnode.singleton x)
          (fun rs rl rx rr h =>
            Ordnode.casesOn (motive := fun t => id rr = t → Ordnode α) (id rr)
              (fun h =>
                Ordnode.casesOn (motive := fun t => rl = t → Ordnode α) rl
                  (fun h => node 2 nil x (dual (node ls (node lls lll llx llr) lx lr)))
                  (fun size l rlx r h => node 3 (Ordnode.singleton x) rlx (Ordnode.singleton rx)) (_ : rl = rl))
              (fun rrs l x_1 r h =>
                Ordnode.casesOn (motive := fun t => id rl = t → Ordnode α) (id rl)
                  (fun h => node 3 (Ordnode.singleton x) rx rr)
                  (fun rls rll rlx rlr h =>
                    if rls < ratio * rrs then node (rs + 1) (node (rls + 1) nil x rl) rx rr
                    else node (rs + 1) (node (size rll + 1) nil x rll) rlx (node (size rlr + rrs + 1) rlr rx rr))
                  (_ : id rl = id rl))
              (_ : id rr = id rr))
          (_ : id (dual (node ls (node lls lll llx llr) lx lr)) = id (dual (node ls (node lls lll llx llr) lx lr))))
      (fun ls_1 l x_1 r h =>
        Ordnode.casesOn (motive := fun t => id (dual (node ls (node lls lll llx llr) lx lr)) = t → Ordnode α)
          (id (dual (node ls (node lls lll llx llr) lx lr))) (fun h => node (ls_1 + 1) (dual nil) x nil)
          (fun rs rl rx rr h =>
            if rs > delta * ls_1 then
              Ordnode.casesOn (motive := fun t => id rr = t → Ordnode α) (id rr) (fun h => nil)
                (fun rrs l x_2 r h =>
                  Ordnode.casesOn (motive := fun t => id rl = t → Ordnode α) (id rl) (fun h => nil)
                    (fun rls rll rlx rlr h =>
                      if rls < ratio * rrs then node (ls_1 + rs + 1) (node (ls_1 + rls + 1) (dual nil) x rl) rx rr
                      else
                        node (ls_1 + rs + 1) (node (ls_1 + size rll + 1) (dual nil) x rll) rlx
                          (node (size rlr + rrs + 1) rlr rx rr))
                    (_ : id rl = id rl))
                (_ : id rr = id rr)
            else node (ls_1 + rs + 1) (dual nil) x (dual (node ls (node lls lll llx llr) lx lr)))
          (_ : id (dual (node ls (node lls lll llx llr) lx lr)) = id (dual (node ls (node lls lll llx llr) lx lr))))
      (_ : id (dual nil) = id (dual nil))

Next tactic:
cases' lr with lrs lrl lrx lrr