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

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

Next tactic:
rfl