Definition codeSubTermTerms : nat -> nat -> nat -> nat :=
  evalStrongRec 2
    (fun t recs v s : nat =>
     cPair
       (switchPR (cPairPi1 t)
          (cPair (cPairPi1 t) (cPairPi2 (codeNth (t - S (cPairPi2 t)) recs)))
          (switchPR (charFunction 2 beq_nat (cPairPi2 t) v) s t))
       (switchPR t
          (S
             (cPair (cPairPi1 (codeNth (t - S (cPairPi1 (pred t))) recs))
                (cPairPi2 (codeNth (t - S (cPairPi2 (pred t))) recs)))) 0)).Definition codeSubTerm (t s v : nat) : nat :=
  cPairPi1 (codeSubTermTerms t s v).Definition codeSubTerms (t s v : nat) : nat :=
  cPairPi2 (codeSubTermTerms t s v).

(* Specifications: *)
Lemma codeSubTermCorrect : forall (t : Term) (v : nat) (s : Term), codeSubTerm (codeTerm L codeF t) v (codeTerm L codeF s) = codeTerm L codeF (substituteTerm L t v s).
Lemma codeSubTermsCorrect : forall (n : nat) (ts : Terms n) (v : nat) (s : Term), codeSubTerms (codeTerms L codeF n ts) v (codeTerm L codeF s) = codeTerms L codeF n (substituteTerms L n ts v s).
Lemma codeSubTermTermsIsPR : isPR 3 codeSubTermTerms.
Lemma codeSubTermIsPR : isPR 3 codeSubTerm.
Lemma codeSubTermsIsPR : isPR 3 codeSubTerms.