Require Vector.
Section close.
Variable L : Language.
Variable codeF : Functions L -> nat.
Variable codeR : Relations L -> nat.
Let Formula := Formula L.
Let codeFormula := codeFormula L codeF codeR.
Definition codeCloseList : nat -> nat -> nat :=
evalStrongRec 1
(fun l recs f : nat =>
switchPR l
(cPair 3
(cPair (cPairPi1 (pred l))
(codeNth (l - S (cPairPi2 (pred l))) recs))) f).

(* Specifications: *)
Lemma codeCloseListCorrect :
forall (l : list nat) (f : Formula),
codeCloseList (codeList l) (codeFormula f) = codeFormula (closeList L l f).
Lemma codeCloseListIsPR : isPR 2 codeCloseList.
Definition codeClose (f : nat) : nat :=
codeCloseList (codeNoDup (codeFreeVarFormula f)) f.
Lemma codeCloseCorrect :
forall f : Formula, codeClose (codeFormula f) = codeFormula (close L f).
Lemma codeCloseIsPR : isPR 1 codeClose.
End close.