(**************************************************************)
(*   Copyright Dominique Larchey-Wendling [*]                 *)
(*                                                            *)
(*                             [*] Affiliation LORIA -- CNRS  *)
(**************************************************************)
(*      This file is distributed under the terms of the       *)
(*         CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT          *)
(**************************************************************)
(** ** The DPRM theorem *)
Set Implicit Arguments.
Local Notation "P /MM/ s ↓" := (sss_terminates (@mm_sss _) P s) (at level 70, no associativity).
Local Notation "l '/F/' x ↓" := (fractran_terminates l x) (at level 70, no associativity).
Local Notation "'⟦' p '⟧'" := (fun φ ν => dp_eval φ ν p).
(** Definitions of n-ary recursive enumerable predicates *)
Definition mm_recognisable_n n (R : vec nat n -> Prop) :=
{ m & { M : list (mm_instr (n+m)) | forall v, R v <-> (1,M) /MM/ (1,vec_app v vec_zero) ↓ } }.
Definition diophantine_n n (R : vec nat n -> Prop) :=
{ m : nat &
{ p : dio_polynomial (pos m) (pos n) &
{ q : dio_polynomial (pos m) (pos n) |
forall v, R v <-> exists w, ⟦p⟧ (vec_pos w) (vec_pos v)
= ⟦q⟧ (vec_pos w) (vec_pos v) } } }.
Section DPRM_n.
Variable (n : nat) (R : vec nat n -> Prop) (HR : mm_recognisable_n R).
(* There is a FRACTRAN program simulating R *)
Let FRACTRAN : { l | forall v, R v <-> l /F/ ps 1 * exp 1 v ↓ }.
(* Then R is diophantine_n *)

Theorem DPRM_n : diophantine_n R.
End DPRM_n.