Require Vector.
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))))))))).

Lemma subAddExistsNice :
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 (addExists m n A) v s =
addExists m n (substituteFormula LNN A v s).