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

(* Specifications: *)
Lemma betaRepresentable : Representable 2 beta betaFormula.
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.
Lemma freeVarAddExists1 :
forall (n m v : nat) (A : Formula),
In v (freeVarFormula LNN (addExists m n A)) -> In v (freeVarFormula LNN A).
Lemma freeVarAddExists2 :
forall (n m v : nat) (A : Formula),
In v (freeVarFormula LNN (addExists m n A)) -> n + m <= v \/ v < m.
Lemma reduceAddExistsOneWay :
forall (n m : nat) (A B : Formula),
SysPrf NN (impH A B) -> SysPrf NN (impH (addExists m n A) (addExists m n B)).
Lemma reduceAddExists :
forall (n m : nat) (A B : Formula),
SysPrf NN (iffH A B) -> SysPrf NN (iffH (addExists m n A) (addExists m n B)).
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).