(* Copyright 2012-2015 by Adam Petcher.				* * Use of this source code is governed by the license described	* * in the LICENSE file at the root of the source tree.		*)
Set Implicit Arguments.
Fixpoint splitVector(A : Set)(n m : nat) : Vector.t A (n + m) -> (Vector.t A n * Vector.t A m) :=
match n with
| 0 =>
fun (v : Vector.t A (O + m)) => (@Vector.nil A, v)
| S n' =>
fun (v : Vector.t A (S n' + m)) =>
let (v1, v2) := splitVector _ _ (Vector.tl v) in
(Vector.cons _ (Vector.hd v) _ v1, v2)
end.
induction v1; intuition; simpl in *.
remember ( splitVector n n2 (Vector.append v1 v2)) as z.
destruct z.
rewrite IHv1 in Heqz.
inversion Heqz; subst.
trivial.
Qed.
induction n1; intuition; simpl in *.
destruct (vector_S x).
destruct H.
subst.
simpl.
remember (splitVector n1 n2 x1) as z.
destruct z.
simpl.
f_equal.
specialize (IHn1 n2 x1).
rewrite <- Heqz in IHn1.
simpl in *.
trivial.
Qed.
intuition.
specialize (append_splitVector_h _ _ x); intuition.
rewrite <- H in H0.
simpl in *.
trivial.
Qed.

Theorem shiftOut_plus :
forall (n1 n2 : nat) s b s',
shiftOut s (n1 + n2) = Some (b, s') ->
exists b1 b2 s'',
shiftOut s n1 = Some (b1, s'') /\
shiftOut s'' n2 = Some (b2, s') /\
splitVector n1 n2 b = (b1, b2).