Section Primative_Recursive_Representable.
Let Representable := Representable NN.
Let RepresentableAlternate := RepresentableAlternate NN closedNN1.
Let RepresentableHelp := RepresentableHelp NN.
Let Representable_ext := Representable_ext NN.
Definition beta (a z : nat) : nat :=
snd
(proj1_sig
(modulo (coPrimeBeta z (cPairPi1 a)) (gtBeta z (cPairPi1 a))
(cPairPi2 a))).
Definition betaFormula : Formula :=
existH 3
(andH (LT (var 3) (Succ (var 2)))
(existH 4
(andH (LT (var 4) (Succ (var 2)))
(andH
(equal
(Plus
(Times (Plus (var 3) (var 4))
(Succ (Plus (var 3) (var 4))))
(Times (natToTerm 2) (var 3)))
(Times (natToTerm 2) (var 2)))
(andH (LT (var 0) (Succ (Times (var 3) (Succ (var 1)))))
(existH 5
(andH (LT (var 5) (Succ (var 4)))
(equal
(Plus (var 0)
(Times (var 5)
(Succ (Times (var 3) (Succ (var 1))))))
(var 4))))))))).
Fixpoint addExists (m n : nat) (f : Formula) {struct n} : Formula :=
match n with
| O => f
| S n' => existH (n' + m) (addExists m n' f)
end.
Fixpoint addForalls (m n : nat) (f : Formula) {struct n} : Formula :=
match n with
| O => f
| S n' => forallH (n' + m) (addForalls m n' f)
end.

Lemma subAddForallsNice :
forall (n m : nat) (A : Formula) (v : nat) (s : Term),
n + m <= v \/ v < m ->
(forall v : nat, In v (freeVarTerm LNN s) -> n + m <= v \/ v < m) ->
substituteFormula LNN (addForalls m n A) v s =
addForalls m n (substituteFormula LNN A v s).