(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA                        ENS-CNRS                *)
(*              Rocquencourt                        Lyon                    *)
(*                                                                          *)
(*                                Coq V5.10                                 *)
(*                                                                          *)
(****************************************************************************)
(*                                Shuffle.v                                 *)
(****************************************************************************)
(* G. Huet - V5.8  Nov. 1994 *)
(*    ported V5.10 June 1995 *)
(***********************)
(* Shuffling two words *)
(***********************)
Inductive shuffle : word -> word -> word -> Prop :=
| shuffle_empty : shuffle empty empty empty
| shuffle_bit_left :
forall u v w : word,
shuffle u v w -> forall b : bool, shuffle (bit b u) v (bit b w)
| shuffle_bit_right :
forall u v w : word,
shuffle u v w -> forall b : bool, shuffle u (bit b v) (bit b w).
(***********************)
(* The shuffling lemma *)
(***********************)

Lemma Shuffling :
forall u v w : word,
shuffle u v w ->
forall b : bool,
alt b u ->
odd u /\
(odd v /\ (alt (negb b) v -> paired w) /\ (alt b v -> paired_bet b w) \/
even v /\
(alt b v -> paired_odd_l b w) /\
(alt (negb b) v -> paired_odd_r (negb b) w)) \/
even u /\
(odd v /\
(alt (negb b) v -> paired_odd_r b w) /\ (alt b v -> paired_odd_l b w) \/
even v /\ (alt b v -> paired_rot b w) /\ (alt (negb b) v -> paired w)).