intros w w' w''; make_fraction w ipattern:(p) ipattern:(q) ipattern:(Heq);
make_fraction w' ipattern:(p') ipattern:(q') ipattern:(Heq');
make_fraction w'' ipattern:(p'') ipattern:(q'') ipattern:(Heq'');
intros Hneq1 Hneq2.
intros H H1 H2; apply Qpositive_le'_to_Qpositive_le;
generalize (Qpositive_le_to_Qpositive_le' _ _ H)
(Qpositive_le_to_Qpositive_le' _ _ H1)
(Qpositive_le_to_Qpositive_le' _ _ H2); clear H H1 H2.
unfold Qpositive_le', Qpositive_sub in |- *; simpl in |- *; rewrite Heq;
rewrite Heq'; rewrite Heq''.
intros Hle Hle1 Hle2.
expand (S p * S q'' - S p'' * S q) (S q * S q'')
(S p * S q'' + S p'' * S q + S q * S q'') ipattern:(d) ipattern:(p3) ipattern:(q3)
ipattern:(Heq3) ipattern:(Heq1) ipattern:(Heq2).
expand (S p' * S q'' - S p'' * S q') (S q' * S q'')
(S p' * S q'' + S p'' * S q' + S q' * S q'') ipattern:(d') ipattern:(p4)
ipattern:(q4) ipattern:(Heq4) ipattern:(Heq5) ipattern:(Heq6).
apply mult_S_le_reg_l with d'.
repeat rewrite (mult_comm (S d')); rewrite (mult_comm (S p4));
repeat rewrite <- mult_assoc.
rewrite <- Heq5; rewrite <- Heq6.
apply mult_S_le_reg_l with d; repeat rewrite mult_assoc;
repeat rewrite (mult_comm (S d)).
rewrite <- Heq1; rewrite <- Heq2.
repeat rewrite mult_minus_distr_r.
rewrite (mult_comm (S q * S q'')).
rewrite mult_minus_distr_r.
replace (S p'' * S q * S q' * S q'') with (S p'' * S q' * (S q * S q'')).
apply le_minus_right.
repeat rewrite <- (mult_comm (S q')); repeat rewrite <- mult_assoc;
apply (fun m n p : nat => mult_le_compat_l p n m).
repeat rewrite mult_assoc; repeat rewrite <- (mult_comm (S q''));
apply (fun m n p : nat => mult_le_compat_l p n m).
rewrite <- (mult_comm (S p)); assumption.
repeat rewrite <- (mult_comm (S q * S q''));
apply (fun m n p : nat => mult_le_compat_l p n m);
assumption.
repeat rewrite mult_assoc; repeat rewrite <- (mult_comm (S q''));
apply (fun m n p : nat => mult_le_compat_l p n m).
repeat rewrite <- mult_assoc;
apply (fun m n p : nat => mult_le_compat_l p n m).
assumption.
ring.
elim (le_gt_dec (S p' * S q'') (S p'' * S q')).
intros a; try assumption.
elim Hneq2.
rewrite <- (construct_correct w' (S p') (S q') (S p' + S q')); auto with *.
rewrite <- (construct_correct w'' (S p'') (S q'') (S p'' + S q''));
auto with *.
apply construct_correct4'; auto with arith.
CaseEq (S p' * S q'' - S p'' * S q').
intros Dummy Dummy2; generalize (minus_O_le _ _ Dummy); intros Dummy1;
elim (le_not_gt _ _ Dummy1 Dummy2).
auto with arith.
apply plus_le_compat_r.
eapply le_trans; [ eapply minus_le | auto with arith ].
case (le_gt_dec (S p * S q'') (S p'' * S q)).
intros l; try assumption.
elim Hneq1.
rewrite <- (construct_correct w (S p) (S q) (S p + S q)); auto with *.
rewrite <- (construct_correct w'' (S p'') (S q'') (S p'' + S q''));
auto with *.
apply construct_correct4'; auto with arith.
CaseEq (S p * S q'' - S p'' * S q).
intros Dummy Dummy2; generalize (minus_O_le _ _ Dummy); intros Dummy1;
elim (le_not_gt _ _ Dummy1 Dummy2).
auto with arith.
apply plus_le_compat_r.
eapply le_trans; [ eapply minus_le | auto with arith ].
Qed.

(* Specifications: *)
Theorem Qpositive_mult_minus_distr :
forall w w' w'' : Qpositive,
w <> w' ->
Qpositive_le w w' ->
Qpositive_mult (Qpositive_sub w' w) w'' =
Qpositive_sub (Qpositive_mult w' w'') (Qpositive_mult w w'').