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 <;> cases' lr with lrs lrl lrx lrr <;> dsimp only [dual, id] <;>
      try rfl
    split_ifs with h <;> repeat simp [h, add_comm]
  · cases' l with ls ll lx lr; · rfl
    

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

Next tactic:
dsimp only [dual, id]