(* 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 *)

Require Import Bool.
Require Import Words.
Require Import Alternate.
Require Import Opposite.
Require Import Paired.


(***********************)
(* 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)).
Proof.
(* Goal: forall (u v w : word) (_ : shuffle u v w) (b : bool) (_ : alt b u), or (and (odd u) (or (and (odd v) (and (forall _ : alt (negb b) v, paired w) (forall _ : alt b v, paired_bet b w))) (and (even v) (and (forall _ : alt b v, paired_odd_l b w) (forall _ : alt (negb b) v, paired_odd_r (negb b) w))))) (and (even u) (or (and (odd v) (and (forall _ : alt (negb b) v, paired_odd_r b w) (forall _ : alt b v, paired_odd_l b w))) (and (even v) (and (forall _ : alt b v, paired_rot b w) (forall _ : alt (negb b) v, paired w))))) *)
simple induction 1; intros.
(* 0. empty case *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_rot b empty *)
(* Goal: paired empty *)
(* Goal: or (and (odd (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b w0)))))) (and (even (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired (bit b w0)))))) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_rot_empty.
(* Goal: paired empty *)
(* Goal: or (and (odd (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b w0)))))) (and (even (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired (bit b w0)))))) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_empty.
(* 1. u before v *)
(* Goal: or (and (odd (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b w0)))))) (and (even (bit b u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) v0, paired (bit b w0)))))) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
elim (alt_eq b0 b u0); trivial.
(* Goal: or (and (odd (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))))) (and (even (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b0 w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired (bit b0 w0)))))) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
elim (H1 (negb b0)); intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.1. *) right.
(* Goal: and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0))))) *)
(* Goal: alt b0 u0 *)
elim H3; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
elim H5; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.1.1. *) left.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros. 
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_odd_r b0 (bit b0 w0) *)
(* Goal: paired_odd_l b0 (bit b0 w0) *)
(* Goal: or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b0 w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired (bit b0 w0)))) *)
(* Goal: or (and (odd (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))))) (and (even (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b0 w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired (bit b0 w0)))))) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_r_from_bet; auto.
(* Goal: paired_odd_l b0 (bit b0 w0) *)
(* Goal: or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b0 w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired (bit b0 w0)))) *)
(* Goal: or (and (odd (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))))) (and (even (bit b0 u0)) (or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired_odd_r b0 (bit b0 w0)) (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_rot b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired (bit b0 w0)))))) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_l_intro; apply H9; rewrite (negb_elim b0); auto.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.1.2. *) right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro. 
apply paired_rot_bit; rewrite (negb_intro b0); apply H10;
 rewrite (negb_elim b0); auto.
(* Goal: paired (bit b0 w0) *)
(* Goal: paired_bet b0 (bit b0 w0) *)
(* Goal: or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_l_elim; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.2. *) left.
(* Goal: and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0))))) *)
(* Goal: alt b0 u0 *)
elim H3; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
elim H5; intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.2.1. *) left. 
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros. 
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto. 
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro. 
(* Goal: paired (bit b0 w0) *)
(* Goal: paired_bet b0 (bit b0 w0) *)
(* Goal: or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_l_elim; auto.
(* Goal: paired_bet b0 (bit b0 w0) *)
(* Goal: or (and (odd v0) (and (forall _ : alt (negb b0) v0, paired (bit b0 w0)) (forall _ : alt b0 v0, paired_bet b0 (bit b0 w0)))) (and (even v0) (and (forall _ : alt b0 v0, paired_odd_l b0 (bit b0 w0)) (forall _ : alt (negb b0) v0, paired_odd_r (negb b0) (bit b0 w0)))) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_bet_bit; apply H9; rewrite (negb_elim b0); auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 1.2.2. *) right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros. 
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_odd_l b0 (bit b0 w0) *)
(* Goal: paired_odd_r (negb b0) (bit b0 w0) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_l_intro; apply H10; rewrite (negb_elim b0); auto.
(* Goal: paired_odd_r (negb b0) (bit b0 w0) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
pattern b0 at 2 in |- *; rewrite (negb_intro b0).
(* Goal: paired_odd_r (negb b0) (bit (negb (negb b0)) w0) *)
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply paired_odd_r_from_rot; auto.
(* Goal: alt (negb b0) u0 *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
apply alt_neg_intro with b; trivial.
(* 2. v before u *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
elim (H1 b0); intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.1. *) left.
(* Goal: and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0))))) *)
(* Goal: alt b0 u0 *)
elim H3; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
elim H5; intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.1.1. *) right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq b0 b v0); trivial.
(* Goal: paired_odd_l b0 (bit b0 w0) *)
(* Goal: paired_odd_r (negb b0) (bit b w0) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply paired_odd_l_intro; apply H9; apply alt_neg_intro with b; auto.
(* Goal: paired_odd_r b0 (bit b w0) *)
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq (negb b0) b v0); trivial.
apply paired_odd_r_from_bet; rewrite (negb_elim b0); apply H10;
 apply alt_neg_elim with b; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.1.2. *) left.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired (bit (negb b0) w0) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
apply paired_odd_l_elim.
(* Goal: paired_odd_r b0 (bit b w0) *)
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq (negb b0) b v0); trivial.
(* Goal: paired_odd_l (negb (negb b0)) w0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
rewrite (negb_elim b0).
(* Goal: paired_odd_l b0 w0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply H9.
(* Goal: alt b0 v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
rewrite (negb_intro b0).
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply alt_neg_intro with b; auto.
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq b0 b v0); trivial.
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply paired_bet_bit; apply H10; apply alt_neg_intro with b; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.2. *) right.
(* Goal: and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0))))) *)
(* Goal: alt b0 u0 *)
elim H3; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
elim H5; intros.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.2.1. *) right.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq b0 b v0); trivial.
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply paired_rot_bit; apply H9; apply alt_neg_intro with b; auto.
(* Goal: paired_odd_r b0 (bit b w0) *)
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq (negb b0) b v0); trivial.
(* Goal: paired (bit (negb b0) w0) *)
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
apply paired_odd_l_elim.
rewrite (negb_elim b0); apply H10; rewrite (negb_intro b0);
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
 apply alt_neg_intro with b; auto.
(* Goal: or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))) *)
(* Goal: alt b0 u0 *)
(* 2.2.2. *) left.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H6; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
elim H8; intros.
(* Goal: and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0))) *)
(* Goal: alt b0 u0 *)
split; auto.
(* Goal: and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) *)
(* Goal: alt b0 u0 *)
split; intro.
(* Goal: paired_odd_r b0 (bit b w0) *)
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq (negb b0) b v0); trivial.
apply paired_odd_r_from_rot; apply H9; rewrite (negb_intro b0);
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
 apply alt_neg_intro with b; auto.
(* Goal: paired_odd_l b0 (bit b w0) *)
(* Goal: alt b0 u0 *)
elim (alt_eq b0 b v0); trivial.
(* Goal: alt (negb (negb b0)) v0 *)
(* Goal: paired_bet b0 (bit b w0) *)
(* Goal: or (and (odd u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)) (forall _ : alt b0 (bit b v0), paired_bet b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired_odd_r (negb b0) (bit b w0)))))) (and (even u0) (or (and (odd (bit b v0)) (and (forall _ : alt (negb b0) (bit b v0), paired_odd_r b0 (bit b w0)) (forall _ : alt b0 (bit b v0), paired_odd_l b0 (bit b w0)))) (and (even (bit b v0)) (and (forall _ : alt b0 (bit b v0), paired_rot b0 (bit b w0)) (forall _ : alt (negb b0) (bit b v0), paired (bit b w0)))))) *)
(* Goal: alt b0 u0 *)
apply paired_odd_l_intro; apply H10; apply alt_neg_intro with b; auto.
(* Goal: alt b0 u0 *)
trivial.
Qed.
