proposition: Lemma inv_ind_false : forall t n : nat, (n <= size -> BV_to_nat (appbv (stripbv (R1 n) (size - n)) (R2 n)) = BV_to_nat V2 * BV_to_nat (truncbv V1 n)) -> S n <= size -> n <= size -> BV_to_nat (appbv (stripbv (appbv (highs (R1 n)) (Mux false (abit (BV_full_adder_sum (R2 n) V2 false) 0) (consbv (lowbit (R2 n)) nilbv))) (size - S n)) (appbv (highs (Mux false (BV_full_adder_sum (R2 n) V2 false) (R2 n))) (Mux false (consbv (BV_full_adder_carry (R2 n) V2 false) nilbv) (consbv false nilbv)))) = BV_to_nat V2 * BV_to_nat (appbv (truncbv V1 n) (consbv false nilbv)).
proof: Proof. intros. simpl in |- *. do 3 rewrite BV_to_nat_app2. simpl in |- *. elim mult_n_O. elim mult_n_O. elim plus_n_O. elim plus_n_O. rewrite (length_strip bool). rewrite <- H. clear H. rewrite (length_app bool). rewrite highs_is_strip. rewrite (length_strip bool). rewrite length_R1. simpl in |- *. replace (size - 1 + 1) with size. rewrite minus_minus_lem2. rewrite (strip_app bool). rewrite BV_to_nat_app2. rewrite (strip_strip bool). rewrite (length_strip bool). rewrite length_R1. rewrite (length_strip bool). rewrite BV_to_nat_app2. rewrite (length_strip bool). rewrite length_R1. rewrite minus_minus_lem2. replace (1 + (size - S n)) with (size - n). rewrite minus_minus_lem2. rewrite (minus_le_O (size - S n) (size - 1)). rewrite (strip_O bool). rewrite plus_assoc_reverse. replace (power2 n * BV_to_nat (consbv (lowbit (R2 n)) nilbv) + power2 (S n) * BV_to_nat (highs (R2 n))) with (power2 n * BV_to_nat (R2 n)). trivial with arith. symmetry in |- *. apply BV_nat_lem1. rewrite length_R2. exact size_not_O. exact H1. apply le_minus_minus; auto with arith. exact H1. simpl in |- *. rewrite minus_Sn_m. auto with arith. exact H0. exact H1. exact H1. rewrite length_R1. auto with arith. exact H1. rewrite length_R1. auto with arith. exact H1. exact H1. rewrite length_R1. simpl in |- *. rewrite minus_Sn_m. simpl in |- *. auto with arith. exact H0. exact H1. exact H0. rewrite plus_comm. simpl in |- *. rewrite minus_Sn_m; auto with arith. exact H1. rewrite length_R1. auto with arith. exact H1. exact H1. rewrite (length_app bool). rewrite length_highs. rewrite length_R1. simpl in |- *. rewrite plus_n_SO. replace (pred size) with (size - 1). rewrite minus_Sn_m. simpl in |- *. elim minus_n_O. apply minus_le_lem2; auto with arith. auto with arith. apply minus_n_SO. exact H1. apply (not_nil bool). rewrite length_R1; auto with arith. Qed.
imports: Definitions LemPrelim AdderProof