End const_1_cn.
Section const_1_cs.
Variable (w u u1 u2 : nat).
Hypothesis (H18 : 1+(r-1)*w = power (S (power (S l) 2)) r)
(H19 : u*u = u1 + u2)
(H20 : u1 = (u*u) ⇣ w)
(H21 : u2 = (u*u) ⇣ (2*w))
(H22 : power 2 r + u1 = u + power (power (S l) 2) r)
(H23 : divides (power 4 r) u1).
Let Hw_0 : w = ∑ (S (power (S l) 2)) (fun i => power i r).
Let m := projT1 mk_full.
Let k := proj1_sig (projT2 mk_full).
Let Hu1 : u1 = ∑ (S m) (fun i => power (k i) r).        Proof. apply (proj2_sig (projT2 mk_full)). Qed.
Let Hm : m <= (power (S l) 2).                          Proof. apply (proj2_sig (projT2 mk_full)). Qed.
Let Hk1 : forall i, i < S m -> k i <= power (S l) 2.    Proof. apply (proj2_sig (projT2 mk_full)). Qed.
Let Hk2 : forall i j, i < j < S m -> k i < k j.         Proof. apply (proj2_sig (projT2 mk_full)). Qed.
Let Hh_0 : 4 <= k 0.
Let f1 i := match i with 0 => 2 | S i => k i end.
Let f2 i := if le_lt_dec i m then power (S l) 2 else k i.
Let Hf1_0 : forall i, i <= S m -> f1 i < S (power (S l) 2).
Let Hf1_1 : forall i j, i < j <= S m -> f1 i < f1 j.
Let Hf1_2 : ∑ (S (S m)) (fun i => power (f1 i) r) = u + power (power (S l) 2) r.
Let Hh_1 : k m = power (S l) 2.
Let Hu : u = ∑ (S m) (fun i => power (f1 i) r).
Let Huu : u*u = ∑ (S m) (fun i => power (2*f1 i) r)
+ ∑ (S m) (fun i => ∑ i (fun j => 2*power (f1 i + f1 j) r)).
(* This one should not be that hard given S l < q but to check *)
Let HSl_q : 2 * S (power (S l) 2) < power (2 * q) 2.
Let Hu1_1 : { d | d <= S m /\ u1 = ∑ d (fun i => power (2*f1 i) r) }.
Let Hk_final : k 0 = 4 /\ forall i, i < m -> k (S i) = 2*k i.
Let Hk_is_power i : i <= m -> k i = power (S (S i)) 2.
Let Hm_is_l : S m = l.
Fact obtain_u_u1_value :  u  = ∑ l (fun i => power (power (S i) 2) r)
/\ u1 = ∑ l (fun i => power (power (S (S i)) 2) r).
End const_1_cs.
End const_1.
Variable (l q : nat).
Notation r := (power (4*q) 2).
Definition seqs_of_ones u u1 :=
l+1 < q
/\ u  = ∑ l (fun i => power (power (S i) 2) r)
/\ u1 = ∑ l (fun i => power (power (S (S i)) 2) r).
(* This lemma shows that seqs_of_ones can be encoded by a diophantine expression *)

Lemma seqs_of_ones_dio u u1 :
seqs_of_ones u u1
<-> l = 0 /\ u = 0 /\ u1 = 0 /\ 2 <= q
\/ 0 < l /\ l+1 < q
/\ exists u2 w r0 r1 p1 p2,
r0 = r
/\ r1+1 = r0
/\ p1 = power (1+l) 2
/\ p2 = power p1 r0
/\ 1+r1*w = r0*p2
/\ u*u = u1 + u2
/\ u1 = (u*u) ⇣ w
/\ u2 = (u*u) ⇣ (2*w)
/\ r0*r0 + u1 = u + p2
/\ divides (r0*r0*r0*r0) u1.