text
stringlengths
1.3k
3.62M
(* 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 *) (* *) (****************************************************************************) (* Gilbreath.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. Require Import Shuffle. (****************************) (* The Gilbreath card trick *) (****************************) Section Context. Variable x : word. Hypothesis Even_x : even x. Variable b : bool. (* witness for (alternate x) *) Hypothesis A : alt b x. Variable u v : word. Hypothesis C : conc u v x. Variable w : word. Hypothesis S : shuffle u v w. Lemma Alt_u : alt b u. Proof. (* Goal: alt b u *) apply alt_conc_l with v x. (* Goal: conc u v x *) (* Goal: alt b x *) apply C. (* Goal: alt b x *) apply A. Qed. Section Case1_. Hypothesis Odd_u : odd u. Lemma Not_even_u : ~ even u. Proof. (* Goal: not (even u) *) red in |- *; intro. (* Goal: False *) elim not_odd_and_even with u; trivial. Qed. Lemma Odd_v : odd v. Proof. (* Goal: even v *) elim even_conc with u v x. (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; trivial. (* Goal: forall _ : and (even u) (alt b v), alt (negb b) v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; intro; elim Not_even_u; trivial. (* Goal: conc u v x *) (* Goal: alt b x *) apply C. (* Goal: even x *) apply Even_x. Qed. Remark Alt_v_neg : alt (negb b) v. Proof. (* Goal: alt b v *) elim alt_conc_r with u v x b. (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; trivial. (* Goal: forall _ : and (even u) (alt b v), alt (negb b) v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; intro; elim Not_even_u; trivial. (* Goal: conc u v x *) (* Goal: alt b x *) apply C. (* Goal: alt b x *) apply A. Qed. Lemma Opp_uv : opposite u v. Proof. (* Goal: opposite u v *) apply alt_neg_opp with b. (* Goal: odd u *) (* Goal: alt b u *) (* Goal: odd v *) (* Goal: alt (negb b) v *) apply Odd_u. (* Goal: alt b u *) apply Alt_u. (* Goal: odd v *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Odd_v. (* Goal: alt (negb b) v *) (* Goal: paired w *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Alt_v_neg. Qed. Lemma Case1 : paired w. Proof. (* Goal: paired_rot b w *) elim Shuffling with u v w b. simple induction 1; simple induction 2; simple induction 1; simple induction 2; intros P1 P2. (* Goal: paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply P1. (* Goal: alt (negb b) v *) (* Goal: paired w *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Alt_v_neg. (* Goal: paired w *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) elim not_odd_and_even with v; trivial. (* Goal: odd v *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Odd_v. (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) simple induction 1; intro; elim Not_even_u; trivial. (* Goal: shuffle u v w *) (* Goal: alt b u *) apply S. (* Goal: alt b u *) apply Alt_u. Qed. End Case1_. Section Case2_. Hypothesis Even_u : even u. Lemma Not_odd_u : ~ odd u. Proof. (* Goal: False *) red in |- *; intro; elim not_odd_and_even with u; trivial. Qed. Lemma Even_v : even v. Proof. (* Goal: even v *) elim even_conc with u v x. (* Goal: forall _ : and (odd u) (alt (negb b) v), alt b v *) (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; intro; elim Not_odd_u; trivial. (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; trivial. (* Goal: conc u v x *) (* Goal: alt b x *) apply C. (* Goal: even x *) apply Even_x. Qed. Remark Alt_v : alt b v. Proof. (* Goal: alt b v *) elim alt_conc_r with u v x b. (* Goal: forall _ : and (odd u) (alt (negb b) v), alt b v *) (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; intro; elim Not_odd_u; trivial. (* Goal: forall _ : and (even u) (alt b v), alt b v *) (* Goal: conc u v x *) (* Goal: alt b x *) intro H; elim H; trivial. (* Goal: conc u v x *) (* Goal: alt b x *) apply C. (* Goal: alt b x *) apply A. Qed. Lemma Not_opp_uv : ~ opposite u v. Proof. (* Goal: not (opposite u v) *) apply alt_not_opp with b. (* Goal: alt b u *) apply Alt_u. (* Goal: alt b v *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Alt_v. Qed. Lemma Case2 : paired (rotate w). Proof. (* Goal: paired (rotate w) *) apply paired_rotate with b. (* Goal: paired_rot b w *) elim Shuffling with u v w b. (* Goal: forall _ : 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)))), paired_rot b w *) (* Goal: forall _ : 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)))), paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) simple induction 1; intro; elim Not_odd_u; trivial. (* Goal: forall _ : 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)))), paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) simple induction 1; simple induction 2. (* Goal: paired w *) (* Goal: forall _ : 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)))), paired w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) simple induction 1; intros; elim not_odd_and_even with v; trivial. (* Goal: even v *) (* Goal: forall _ : and (even v) (and (forall _ : alt b v, paired_rot b w) (forall _ : alt (negb b) v, paired w)), paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Even_v. (* Goal: forall _ : and (even v) (and (forall _ : alt b v, paired_rot b w) (forall _ : alt (negb b) v, paired w)), paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) simple induction 1; simple induction 2; intros P1 P2. (* Goal: paired_rot b w *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply P1. (* Goal: alt b v *) (* Goal: shuffle u v w *) (* Goal: alt b u *) apply Alt_v. (* Goal: shuffle u v w *) (* Goal: alt b u *) apply S. (* Goal: alt b u *) apply Alt_u. Qed. End Case2_. (* We recall from the prelude the definition of the conditional : Definition IF := [P,Q,R:Prop](P /\ Q) \/ ((~P) /\ R) Syntax IF "IF _ then _ else _" *) Lemma Main : IF opposite u v then paired w else paired (rotate w). Proof. (* Goal: IF_then_else (opposite u v) (paired w) (paired (rotate w)) *) unfold IF_then_else in |- *; elim odd_or_even with u; intros. (* (odd u) : Case 1 *) (* Goal: or (and (opposite u v) (paired w)) (and (not (opposite u v)) (paired (rotate w))) *) (* Goal: or (and (opposite u v) (paired w)) (and (not (opposite u v)) (paired (rotate w))) *) left; split. (* Goal: opposite u v *) (* Goal: paired w *) (* Goal: or (and (opposite u v) (paired w)) (and (not (opposite u v)) (paired (rotate w))) *) apply Opp_uv; trivial. (* Goal: paired w *) (* Goal: or (and (opposite u v) (paired w)) (and (not (opposite u v)) (paired (rotate w))) *) apply Case1; trivial. (* (even u) : Case 2 *) (* Goal: or (and (opposite u v) (paired w)) (and (not (opposite u v)) (paired (rotate w))) *) right; split. (* Goal: not (opposite u v) *) (* Goal: paired (rotate w) *) apply Not_opp_uv; trivial. (* Goal: paired (rotate w) *) apply Case2; trivial. Qed. End Context. (*********************) (* Gilbreath's trick *) (*********************) Theorem Gilbreath : forall x : word, even x -> alternate x -> forall u v : word, conc u v x -> forall w : word, shuffle u v w -> IF opposite u v then paired w else paired (rotate w). Proof. (* Goal: forall (x : word) (_ : even x) (_ : alternate x) (u v : word) (_ : conc u v x) (w : word) (_ : shuffle u v w), IF_then_else (opposite u v) (paired w) (paired (rotate w)) *) simple induction 2; intros. (* Existential intro *) (* Goal: IF_then_else (opposite u v) (paired w) (paired (rotate w)) *) apply Main with x b; trivial. Qed.
(* 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 *) (* *) (****************************************************************************) (* Paired.v *) (****************************************************************************) (* G. Huet - V5.8 Nov. 1994 *) (* ported V5.10 June 1995 *) Require Import Bool. Require Import Words. (****************) (* Paired words *) (****************) (* (paired w) == w = [b1 ~b1 b2 ~b2 ... bn ~bn] *) Inductive paired : word -> Prop := | paired_empty : paired empty | paired_bit : forall w : word, paired w -> forall b : bool, paired (bit (negb b) (bit b w)). (* paired_odd_l b w == w = [b b1 ~b1 b2 ~b2 ... bn ~bn] *) Definition paired_odd_l (b : bool) (w : word) := paired (bit (negb b) w). Lemma paired_odd_l_intro : forall (b : bool) (w : word), paired w -> paired_odd_l b (bit b w). Proof. (* Goal: forall (b : bool) (w : word) (_ : paired_odd_l (negb b) w), paired (bit b w) *) unfold paired_odd_l in |- *; intros. (* Goal: paired (bit (negb (negb b)) (bit (negb b) (append w0 (single (negb (negb b)))))) *) apply paired_bit; trivial. Qed. Lemma paired_odd_l_elim : forall (b : bool) (w : word), paired_odd_l (negb b) w -> paired (bit b w). Proof. (* Goal: forall (b : bool) (w : word) (_ : paired_odd_l (negb b) w), paired (bit b w) *) unfold paired_odd_l in |- *; intros. (* Goal: paired (bit b w) *) rewrite (negb_intro b); trivial. Qed. (* paired_odd_r b w == w = [b1 ~b1 b2 ~b2 ... bn ~bn ~b] *) Definition paired_odd_r (b : bool) (w : word) := paired (append w (single b)). (* paired_rot b w == w = [b b2 ~b2 ... bn ~bn ~b] *) Inductive paired_rot : bool -> word -> Prop := | paired_rot_empty : forall b : bool, paired_rot b empty | paired_rot_bit : forall (b : bool) (w : word), paired_odd_r b w -> paired_rot b (bit b w). Lemma paired_odd_r_from_rot : forall (w : word) (b : bool), paired_rot b w -> paired_odd_r b (bit (negb b) w). Proof. (* Goal: forall (w : word) (b : bool) (_ : paired_rot b w), paired (rotate w) *) simple induction 1. (* Goal: forall b : bool, paired_odd_r b (bit (negb b) empty) *) (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired_odd_r b (bit (negb b) (bit b w)) *) intro; unfold paired_odd_r in |- *; simpl in |- *. (* Goal: paired (bit (negb b0) (single b0)) *) (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired_odd_r b (bit (negb b) (bit b w)) *) unfold single in |- *; apply paired_bit. (* Goal: paired empty *) (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired_odd_r b (bit (negb b) (bit b w)) *) apply paired_empty. (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired_odd_r b (bit (negb b) (bit b w)) *) intros b0 b' w'; unfold paired_odd_r in |- *; intros. (* Goal: paired (append (bit (negb b0) (bit b0 b')) (single b0)) *) simpl in |- *; apply paired_bit; auto. Qed. (* paired_bet b w == w = [b b2 ~b2 ... bn ~bn b] *) Inductive paired_bet (b : bool) : word -> Prop := paired_bet_bit : forall w : word, paired_odd_r (negb b) w -> paired_bet b (bit b w). Lemma paired_odd_r_from_bet : forall (b : bool) (w : word), paired_bet (negb b) w -> paired_odd_r b (bit b w). Proof. (* Goal: forall (b : bool) (w : word) (_ : paired_bet (negb b) w), paired_odd_r b (bit b w) *) intros b w pb. (* Goal: paired_odd_r b (bit b w) *) rewrite (negb_intro b). (* Goal: paired_odd_r (negb (negb b)) (bit (negb (negb b)) w) *) elim pb. (* Goal: forall (w : word) (_ : paired_odd_r (negb (negb b)) w), paired_odd_r (negb (negb b)) (bit (negb (negb b)) (bit (negb b) w)) *) unfold paired_odd_r in |- *. (* Unfolds twice *) (* Goal: forall (w : word) (_ : paired (append w (single (negb (negb b))))), paired (append (bit (negb (negb b)) (bit (negb b) w)) (single (negb (negb b)))) *) intros; simpl in |- *. (* Goal: paired (bit (negb (negb b)) (bit (negb b) (append w0 (single (negb (negb b)))))) *) apply paired_bit; trivial. Qed. (************) (* Rotation *) (************) Definition rotate (w : word) : word := match w with | empty => empty | bit b w => append w (single b) end. Lemma paired_rotate : forall (w : word) (b : bool), paired_rot b w -> paired (rotate w). Proof. (* Goal: forall (w : word) (b : bool) (_ : paired_rot b w), paired (rotate w) *) simple induction 1. (* Goal: paired empty *) (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired_odd_r b (bit (negb b) (bit b w)) *) intro; simpl in |- *; apply paired_empty. (* Goal: forall (b : bool) (w : word) (_ : paired_odd_r b w), paired (rotate (bit b w)) *) intros b' w'; simpl in |- *. (* Goal: forall _ : paired_odd_r b' w', paired (append w' (single b')) *) unfold paired_odd_r in |- *; trivial. Qed.
(* 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 *) (* *) (****************************************************************************) (* Words.v *) (****************************************************************************) (* G. Huet - V5.8 Nov. 1994 *) (* ported V5.10 June 1995 *) Require Import Bool. (*****************) (* Boolean words *) (*****************) Inductive word : Set := | empty : word | bit : bool -> word -> word. (* Remark : word ~ bool list *) (* word concatenation : logical definition *) Inductive conc : word -> word -> word -> Prop := | conc_empty : forall v : word, conc empty v v | conc_bit : forall (u v w : word) (b : bool), conc u v w -> conc (bit b u) v (bit b w). (* word concatenation : functional definition *) Fixpoint append (u : word) : word -> word := fun v : word => match u with | empty => v | bit b w => bit b (append w v) end. (* Relating the two definitions; unused below *) Lemma conc_append : forall u v w : word, conc u v w -> w = append u v. Proof. (* Goal: forall (u v w : word) (_ : conc u v w), @eq word w (append u v) *) simple induction 1; simpl in |- *; trivial. (* Goal: forall (u v w : word) (b : bool) (_ : conc u v w) (_ : @eq word w (append u v)), @eq word (bit b w) (bit b (append u v)) *) simple induction 2; trivial. Qed. (* Associativity of append; unused below *) Lemma assoc_append : forall u v w : word, append u (append v w) = append (append u v) w. Proof. (* Goal: forall u v w : word, @eq word (append u (append v w)) (append (append u v) w) *) simple induction u; simpl in |- *; intros; auto. (* Goal: @eq word (bit b (append w (append v w0))) (bit b (append (append w v) w0)) *) rewrite H; trivial. Qed. (**************) (* Singletons *) (**************) Definition single (b : bool) := bit b empty. (*********************) (* Parities of words *) (*********************) Inductive odd : word -> Prop := even_odd : forall w : word, even w -> forall b : bool, odd (bit b w) with even : word -> Prop := | even_empty : even empty | odd_even : forall w : word, odd w -> forall b : bool, even (bit b w). Hint Resolve odd_even even_empty even_odd. Lemma not_odd_empty : ~ odd empty. Proof. (* Goal: not (odd empty) *) unfold not in |- *; intro od. (* Goal: False *) inversion od. Qed. Hint Resolve not_odd_empty. Lemma inv_odd : forall (w : word) (b : bool), odd (bit b w) -> even w. Proof. (* Goal: forall (w : word) (b : bool) (_ : odd (bit b w)), even w *) intros w b od. (* Goal: even w *) inversion od; trivial. Qed. Lemma inv_even : forall (w : word) (b : bool), even (bit b w) -> odd w. Proof. (* Goal: forall (w : word) (b : bool) (_ : even (bit b w)), odd w *) intros w b ev. (* Goal: odd w *) inversion ev; trivial. Qed. (**********************) (* (odd w) + (even w) *) (**********************) Lemma odd_or_even : forall w : word, odd w \/ even w. Proof. (* Goal: forall w : word, or (odd w) (even w) *) simple induction w; auto. (* Goal: forall (u v w : word) (_ : conc u v w), or (and (odd w) (or (and (odd u) (even v)) (and (even u) (odd v)))) (and (even w) (or (and (odd u) (odd v)) (and (even u) (even v)))) *) simple induction 1; intros. (* Goal: or (odd (bit b w0)) (even (bit b w0)) *) (* Goal: or (odd (bit b w0)) (even (bit b w0)) *) right; auto. (* Goal: or (odd (bit b w0)) (even (bit b w0)) *) left; auto. Qed. Lemma not_odd_and_even : forall w : word, odd w -> even w -> False. Proof. (* Goal: forall (w : word) (_ : odd w) (_ : even w), False *) simple induction w; intros. (* Goal: False *) (* Goal: False *) elim not_odd_empty; trivial. (* Goal: False *) apply H. (* Goal: odd w0 *) (* Goal: even w0 *) apply inv_even with b; trivial. (* Goal: even w0 *) apply inv_odd with b; trivial. Qed. (************************) (* Parities of subwords *) (************************) Lemma odd_even_conc : forall u v w : word, conc u v w -> odd w /\ (odd u /\ even v \/ even u /\ odd v) \/ even w /\ (odd u /\ odd v \/ even u /\ even v). Proof. (* Goal: forall (u v w : word) (_ : conc u v w), or (and (odd w) (or (and (odd u) (even v)) (and (even u) (odd v)))) (and (even w) (or (and (odd u) (odd v)) (and (even u) (even v)))) *) simple induction 1; intros. (* Goal: or (and (odd v0) (or (and (odd empty) (even v0)) (and (even empty) (odd v0)))) (and (even v0) (or (and (odd empty) (odd v0)) (and (even empty) (even v0)))) *) (* Goal: or (and (odd (bit b w0)) (or (and (odd (bit b u0)) (even v0)) (and (even (bit b u0)) (odd v0)))) (and (even (bit b w0)) (or (and (odd (bit b u0)) (odd v0)) (and (even (bit b u0)) (even v0)))) *) elim (odd_or_even v0); auto. (* Goal: or (and (odd (bit b w0)) (or (and (odd (bit b u0)) (even v0)) (and (even (bit b u0)) (odd v0)))) (and (even (bit b w0)) (or (and (odd (bit b u0)) (odd v0)) (and (even (bit b u0)) (even v0)))) *) elim H1; [ right | left ]; intuition. Qed. Lemma even_conc : forall u v w : word, conc u v w -> even w -> odd u /\ odd v \/ even u /\ even v. Proof. (* Goal: forall (u v w : word) (_ : conc u v w) (_ : even w), or (and (odd u) (odd v)) (and (even u) (even v)) *) intros u v w c e; elim odd_even_conc with u v w; intros. (* Goal: or (and (odd u) (odd v)) (and (even u) (even v)) *) (* Goal: or (and (odd u) (odd v)) (and (even u) (even v)) *) (* Goal: conc u v w *) elim H; intro o; elim not_odd_and_even with w; auto. (* Goal: or (and (odd u) (odd v)) (and (even u) (even v)) *) (* Goal: conc u v w *) elim H; intros; trivial. (* Goal: conc u v w *) trivial. Qed.
(* 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.