Require Export Coq.Lists.List.
Require Vector.
Definition codeLength : nat -> nat :=
evalStrongRec 0
(fun n Hrecs : nat =>
switchPR n (S (codeNth (n - S (cPairPi2 (pred n))) Hrecs)) 0).
Definition codeApp : nat -> nat -> nat :=
evalStrongRec 1
(fun n Hrecs p1 : nat =>
switchPR n
(S
(cPair (cPairPi1 (pred n))
(codeNth (n - S (cPairPi2 (pred n))) Hrecs))) p1).
Definition codeListRemove (a l : nat) : nat :=
evalStrongRec 1
(fun n Hrecs p1 : nat =>
switchPR n
(switchPR (charFunction 2 beq_nat (cPairPi1 (pred n)) p1)
(codeNth (n - S (cPairPi2 (pred n))) Hrecs)
(S
(cPair (cPairPi1 (pred n))
(codeNth (n - S (cPairPi2 (pred n))) Hrecs))))
(codeList nil)) l a.
Definition codeIn (a l : nat) : nat :=
evalStrongRec 1
(fun n Hrecs p1 : nat =>
switchPR n
(switchPR (charFunction 2 beq_nat (cPairPi1 (pred n)) p1) 1
(codeNth (n - S (cPairPi2 (pred n))) Hrecs)) 0) l a.
Definition codeNoDup : nat -> nat :=
evalStrongRec 0
(fun l recs : nat =>
switchPR l
(switchPR
(codeIn (cPairPi1 (pred l))
(codeNth (l - S (cPairPi2 (pred l))) recs))
(codeNth (l - S (cPairPi2 (pred l))) recs)
(S
(cPair (cPairPi1 (pred l))
(codeNth (l - S (cPairPi2 (pred l))) recs)))) 0).

Lemma codeNoDupCorrect :
forall l : list nat,
codeNoDup (codeList l) = codeList (no_dup _ eq_nat_dec l).