(**************************************************************)
(*   Copyright Dominique Larchey-Wendling [*]                 *)
(*                                                            *)
(*                             [*] Affiliation LORIA -- CNRS  *)
(**************************************************************)
(*      This file is distributed under the terms of the       *)
(*         CeCILL v2 FREE SOFTWARE LICENSE AGREEMENT          *)
(**************************************************************)
(** ** Object-level encoding of bounded universal quantification III *)
Set Implicit Arguments.
Local Notation power := (mscal mult 1).
Local Notation "∑" := (msum plus 0).
(** We show the elimination of bounded universal quantification. The proof is based on the paper  "A new technique for obtaining diophantine representations via elimination of bounded universal quantifiers" by Matiyasevich  with two noticable differences  a) we use r = 2^(4*q) instead of r = 2^(2*q) 2*q could work but I think the proof implied by the paper (it is not given) that cc = aa * bb is simulated does not work well because masked digits are can be of the form f i * g j + f j * g i and f _ < 2^q,  g _ < 2^q implies f _ * g _ < 2^(2*q) which is good but *does not* imply  f _ * g _ + f _ * g _ < 2^(2*q) !! The argument could still work though it is going to be much more complicated to establish formally, so I raised 2*q to 4*q to solve straightforwardly the overflow problem of masked digits Anyway, this 2*q value was arbitrary so it only impacts the proof in minor ways  b) The arguments outlined between (26) and (31) are flawed I think One should first split the k_i's in 0 <= k_2 < .... < k_d <= 2^l+1 < .... < k_{m+1} to do the computation. The upper k_i's are masked out and then you can show that d must be m+1 with the other constraints.  *)
Section df_mconj.
Fixpoint df_mconj k f :=
match k with
| 0   => df_true
| S k => df_conj (f 0) (df_mconj k (fun i => f (S i)))
end.
Fact df_mconj_size k f : df_size (df_mconj k f) = 3+k+∑ k (fun i => df_size (f i)).
Fact df_mconj_spec k f ν : df_pred (df_mconj k f) ν <-> forall i, i < k -> df_pred (f i) ν.

(* Specifications: *)
Lemma dio_rel_mconj k (P : nat -> (nat -> nat) -> Prop) :
(forall i, i < k -> dio_rel (P i))
-> dio_rel (fun ν => forall i, i < k -> P i ν).