Definition codeOpen : nat -> nat :=
  evalStrongRec 0
    (fun f recs : nat =>
     switchPR (cPairPi1 f)
       (switchPR (pred (cPairPi1 f))
          (switchPR (pred (pred (cPairPi1 f)))
             (switchPR (pred (pred (pred (cPairPi1 f)))) f
                (codeNth (f - S (cPairPi2 (cPairPi2 f))) recs)) f) f) f).

Lemma codeOpenCorrect : forall f : Formula, codeOpen (codeFormula f) = codeFormula (open f).