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; · 

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

Next tactic:
rfl