Section Sk.
Hypothesis k:nat.
Hypothesis Base_k: k<>0.
Inductive Base: (nat*(list nat))->Prop :=
| Base_intro s
(Base_a0':fst s = S O)
(Base_a:forall i, ai i s = if Nat.ltb i (k*2) then 2^(k*2-i) else O)
(Base_l:to_l s = k*2+1):
Base s.
Ltac pose_Heb Heb Hl e2 Heb2 rw :=
epose proof (embanked_batch_precond'' Heb Hl _ _) as tmp;
edestruct tmp as [e2 Heb2]; clear tmp;
rewrite rw in Heb2;
cbn in Heb2.
Ltac ex_Heb e Heb :=
exists e; eexists;
split;
[ apply Heb | idtac ].
Ltac pose_eb_len Heb Hl0 Hl :=
pose proof (embanked_batch_len Heb) as Hl;
rewrite Hl0 in Hl; symmetry in Hl.
Ltac pose_eb_a0_a1 Heb Ha0 Ha1 rw :=
destruct (embanked_batch_a0_a1 Heb) as [Ha0 Ha1];
rewrite rw in Ha0,Ha1;
cbn in Ha0,Ha1.
Ltac simpl_Add2s :=
unfold ai';
cbn[negb]; cbn[Bool.eqb];
repeat rewrite Bool.andb_true_r;
repeat rewrite Bool.andb_false_r;
repeat (rewrite Nat_leb_S);
repeat (rewrite Nat_leb_S_l; [idtac|congruence]).
Ltac inv_eb_Add2s Heb := pose proof (embanked_batch_Add2s Heb) as tmp; inverts tmp.

(* case of Proposition 4.1 *)
Lemma embanked_8batch m i0 e0 e1:
m+5 < 2^(k*2) ->
ctzS m mod 2 = 0 ->
ctzS (m+1) mod 2 = 0 ->
ctzS (m+2) mod 2 = 0 ->
ctzS (m+3) mod 2 = 1 ->
embanked_batch i0 e0 e1 (2^(k*2)-1-m) (2^(k*2)+m) ->
i0 mod 2 = 1 ->
to_l e1 = k*2+1 ->
ai' 0 e1 = 1+m*2 ->
ai' 1 e1 = 2^(k*2)+2+m*2 ->
exists e2 i2,
embanked_batch i2 e1 e2 (2^(k*2)-1-(m)) (2^(k*2)+(m+1)) /\
exists e3 i3,
embanked_batch i3 e2 e3 (2^(k*2)-1-(m)) (2^(k*2)+(m+2)) /\
exists e4 i4,
embanked_batch i4 e3 e4 (2^(k*2)-1-(m)) (2^(k*2)+(m+3)) /\
exists e5 i5,
embanked_batch i5 e4 e5 (2^(k*2)-1-(m)) (2^(k*2)+(m+4)) /\
exists e6 i6,
embanked_batch i6 e5 e6 (2^(k*2)-1-(m+1)) (2^(k*2)+(m+4)) /\
exists e7 i7,
embanked_batch i7 e6 e7 (2^(k*2)-1-(m+2)) (2^(k*2)+(m+4)) /\
exists e8 i8,
embanked_batch i8 e7 e8 (2^(k*2)-1-(m+3)) (2^(k*2)+(m+4)) /\
exists e9 i9,
embanked_batch i9 e8 e9 (2^(k*2)-1-(m+4)) (2^(k*2)+(m+4)) /\
i9 mod 2 = 1 /\
to_l e9 = k*2+1 /\
ai' 0 e9 = 1+(m+4)*2 /\
ai' 1 e9 = 2^(k*2)+2+(m+4)*2 /\
(forall i, ai i e9 + 2*(m/2^i) = ai i e1 + 2*((m+4)/2^i))
.