Section bugFix.
Variable
PdivAux :
positive ->
positive -> Option positive * Option positive.
Fixpoint PdivlessAux (bound p base length : positive) {struct length}
: Option positive * Option positive * nat :=
match Pcompare bound p Datatypes.Eq with
| Datatypes.Gt => (Some _ p, None _, 0)
| _ =>
match PdivAux p base with
| (None, None) => (None _, None _, 1)
| (None, Some r1) => (None _, Some _ r1, 1)
| (Some q1, None) =>
match length with
| xH => (Some _ q1, None _, 0)
| xO length' =>
match PdivlessAux bound q1 base length' with
| (s2, None, n) => (s2, None _, S n)
| (s2, Some r2, n) =>
(s2,
Some _
((fun (x : positive)
(_ : positive -> positive)
(y : positive) => (x * y)%positive) r2
(fun x => x) base), S n)
end
| xI length' =>
match PdivlessAux bound q1 base length' with
| (s2, None, n) => (s2, None _, S n)
| (s2, Some r2, n) =>
(s2,
Some _
((fun (x : positive)
(_ : positive -> positive)
(y : positive) => (x * y)%positive) r2
(fun x => x) base), S n)
end
end
| (Some q1, Some r1) =>
match length with
| xH => (Some _ q1, None _, 0)
| xO length' =>
match PdivlessAux bound q1 base length' with
| (s2, None, n) => (s2, Some _ r1, S n)
| (s2, Some r2, n) =>
(s2,
Some _
((fun (x : positive)
(_ : positive -> positive)
(y : positive) => x * y) r2 (
fun x => x) base + r1)%positive,
S n)
end
| xI length' =>
match PdivlessAux bound q1 base length' with
| (s2, None, n) => (s2, Some _ r1, S n)
| (s2, Some r2, n) =>
(s2,
Some _
((fun (x : positive)
(_ : positive -> positive)
(y : positive) => x * y) r2 (
fun x => x) base + r1)%positive,
S n)
end
end
end
end.
End bugFix.
Definition Pdivless := PdivlessAux Pdiv.
intros bound p q base H; case q; simpl in |- *; auto; intros; rewrite H; auto.
Qed.
intros bound p length base; case length; simpl in |- *;
case (Pcompare bound p Datatypes.Eq); auto;
(intros H; case H; auto; fail) || (intros p' H; case H; auto).
Qed.
intros p q; case (Pcompare p q Datatypes.Eq); auto; right; red in |- *;
intros; discriminate.
Qed.
Hint Resolve lt_O_nat_of_P: arith.
intros p; elim p; auto.
intros q; case q; simpl in |- *.
red in |- *; intros; discriminate.
intros q'; rewrite (fun x y => plus_comm x (S y)); simpl in |- *; red in |- *;
intros; discriminate.
intros p' H q; case q.
simpl in |- *; red in |- *; intros; discriminate.
intros q'; red in |- *; intros H0; case (H q').
replace (2 * q') with (2 * S q' - 2).
rewrite <- H0; simpl in |- *; auto.
repeat rewrite (fun x y => plus_comm x (S y)); simpl in |- *; auto.
simpl in |- *; repeat rewrite (fun x y => plus_comm x (S y)); simpl in |- *;
auto.
case q'; simpl in |- *; auto.
Qed.
intros bound p q base Hb; generalize q; pattern p in |- *;
apply
well_founded_ind
with (R := fun a b => nat_of_P a < nat_of_P b);
auto; clear p q.
apply wf_inverse_image with (R := lt); auto.
exact lt_wf; auto.
intros p Rec q Hq.
case (compare_SUP_dec bound p); intros H1.
rewrite Pdivless1; auto; simpl in |- *.
repeat (split; auto with arith).
ring; auto.
apply nat_of_P_lt_Lt_compare_morphism; apply ZC1; auto.
intros bound' H'1 H2; Contradict H2; apply lt_not_le;
apply nat_of_P_lt_Lt_compare_morphism; apply ZC1;
auto.
rewrite Pdivless2; auto; simpl in |- *.
generalize (Pdiv_correct p base); case (Pdiv p base); simpl in |- *.
intros o1; case o1; simpl in |- *.
intros o1' o2; case o2; simpl in |- *.
intros o2' (Ho1, Ho2).
generalize Hq; case q; simpl in |- *; auto.
intros p0 Hq0;
(cut (nat_of_P o1' <= nat_of_P p0); [ intros Hrec | idtac ]).
cut (nat_of_P o1' < nat_of_P p); [ intros Hrec1 | idtac ].
generalize (Rec _ Hrec1 _ Hrec).
CaseEq (Pdivless bound o1' base p0); simpl in |- *.
intros p1; case p1; simpl in |- *.
intros o3; case o3; simpl in |- *; auto.
intros o3' o4; case o4; simpl in |- *; auto.
intros o4' n Eq1; rewrite nat_of_P_plus_morphism;
rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (S (nat_of_P o4') * nat_of_P base).
simpl in |- *; rewrite (fun x y => plus_comm x (nat_of_P y));
auto with arith.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (nat_of_P base * 1); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
inversion Eq1.
rewrite <- H0.
case (le_or_lt bound' (nat_of_P o1')); intros H'8; auto.
rewrite H'5; auto with arith.
Contradict H'6; auto.
apply lt_not_le; rewrite Ho1; auto.
apply
lt_le_trans
with
(nat_of_P o1' * nat_of_P base + 1 * nat_of_P base);
auto with arith.
simpl in |- *; auto with arith.
rewrite <- mult_plus_distr_r.
replace (nat_of_P o1' + 1) with (S (nat_of_P o1'));
auto with arith.
rewrite H'5; auto with arith.
rewrite <- (fun x y => mult_comm (nat_of_P x) y); auto with arith.
rewrite plus_comm; auto with arith.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto with arith.
intros o4; case o4; simpl in |- *.
intros o4' n Eq1; rewrite nat_of_P_plus_morphism;
rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (S (nat_of_P o4') * nat_of_P base).
simpl in |- *; rewrite (fun x y => plus_comm x (nat_of_P y));
auto with arith.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (nat_of_P base * 1); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
rewrite Ho1; auto.
apply lt_le_trans with (nat_of_P o1' * 1 + nat_of_P o2');
auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
apply le_lt_trans with (nat_of_P o1' + 0); auto with arith.
apply plus_le_lt_compat; auto with arith.
apply mult_S_le_reg_l with (n := pred (nat_of_P base)).
replace (S (pred (nat_of_P base))) with (nat_of_P base).
apply
(fun p n m : nat => plus_le_reg_l n m p) with (p := nat_of_P o2').
rewrite (plus_comm (nat_of_P o2')); simpl in |- *; auto with arith.
rewrite (mult_comm (nat_of_P base)); simpl in |- *; auto with arith.
rewrite <- Ho1; auto with arith.
apply le_trans with (1 := Hq0); auto with arith.
replace (nat_of_P (xI p0)) with (1 + 2 * nat_of_P p0);
auto with arith.
apply plus_le_compat; auto with arith.
unfold nat_of_P in |- *; simpl in |- *; (rewrite ZL6; auto).
generalize (lt_O_nat_of_P base); case (nat_of_P base);
simpl in |- *; auto; intros tmp; inversion tmp.
intros p0 Hq0;
(cut (nat_of_P o1' <= nat_of_P p0); [ intros Hrec | idtac ]).
cut (nat_of_P o1' < nat_of_P p); [ intros Hrec1 | idtac ].
generalize (Rec _ Hrec1 _ Hrec).
CaseEq (Pdivless bound o1' base p0); simpl in |- *.
intros p1; case p1; simpl in |- *.
intros o3; case o3; simpl in |- *; auto.
intros o3' o4; case o4; simpl in |- *; auto.
intros o4' n Eq1; rewrite nat_of_P_plus_morphism;
rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (S (nat_of_P o4') * nat_of_P base).
simpl in |- *; rewrite (fun x y => plus_comm x (nat_of_P y));
auto with arith.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (nat_of_P base * 1); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
inversion Eq1.
rewrite <- H0.
case (le_or_lt bound' (nat_of_P o1')); intros H'8; auto.
rewrite H'5; auto with arith.
Contradict H'6; auto.
apply lt_not_le; rewrite Ho1; auto.
apply
lt_le_trans
with
(nat_of_P o1' * nat_of_P base + 1 * nat_of_P base);
auto with arith.
simpl in |- *; auto with arith.
rewrite <- mult_plus_distr_r.
replace (nat_of_P o1' + 1) with (S (nat_of_P o1'));
auto with arith.
rewrite H'5; auto with arith.
rewrite <- (fun x y => mult_comm (nat_of_P x) y); auto with arith.
rewrite plus_comm; auto with arith.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto with arith.
intros o4; case o4; simpl in |- *.
intros o4' n Eq1; rewrite nat_of_P_plus_morphism;
rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (S (nat_of_P o4') * nat_of_P base).
simpl in |- *; rewrite (fun x y => plus_comm x (nat_of_P y));
auto with arith.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (nat_of_P base * 1); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
rewrite Ho1; auto.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
apply lt_le_trans with (nat_of_P o1' * 1 + nat_of_P o2');
auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
apply le_lt_trans with (nat_of_P o1' + 0); auto with arith.
apply plus_le_lt_compat; auto with arith.
rewrite Ho1; auto with arith.
apply mult_S_le_reg_l with (n := pred (nat_of_P base)).
replace (S (pred (nat_of_P base))) with (nat_of_P base).
apply
(fun p n m : nat => plus_le_reg_l n m p) with (p := nat_of_P o2').
rewrite (plus_comm (nat_of_P o2')); simpl in |- *; auto with arith.
rewrite (mult_comm (nat_of_P base)); simpl in |- *; auto with arith.
rewrite <- Ho1; auto with arith.
apply le_trans with (1 := Hq0); auto with arith.
replace (nat_of_P (xO p0)) with (0 + 2 * nat_of_P p0);
auto with arith.
apply plus_le_compat; auto with arith.
unfold nat_of_P in |- *; simpl in |- *; (rewrite ZL6; auto).
generalize (lt_O_nat_of_P base); case (nat_of_P base);
simpl in |- *; auto; intros tmp; inversion tmp.
replace (nat_of_P 1) with 1; auto with arith.
rewrite Ho1; generalize (lt_O_nat_of_P o2');
(case (nat_of_P o2'); simpl in |- *).
intros tmp; Contradict tmp; auto with arith.
generalize (lt_O_nat_of_P o1');
(case (nat_of_P o1'); simpl in |- *).
intros tmp; Contradict tmp; auto with arith.
generalize (lt_O_nat_of_P base);
(case (nat_of_P base); simpl in |- *).
intros tmp; Contradict tmp; auto with arith.
intros n H n0 H0 n1 H01; rewrite (fun x y => plus_comm x (S y));
simpl in |- *.
intros tmp; Contradict tmp; auto with arith.
generalize Hq; case q; simpl in |- *; auto.
intros p0 Hq0 (Ho1, Ho2);
(cut (nat_of_P o1' <= nat_of_P p0); [ intros Hrec | idtac ]).
cut (nat_of_P o1' < nat_of_P p); [ intros Hrec1 | idtac ].
generalize (Rec _ Hrec1 _ Hrec).
CaseEq (Pdivless bound o1' base p0); simpl in |- *.
intros p1; case p1; simpl in |- *.
intros o3; case o3; simpl in |- *; auto.
intros o3' o4; case o4; simpl in |- *; auto.
intros o4' n Eq1; rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
apply lt_le_trans with (nat_of_P base * 1); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
inversion Eq1.
rewrite <- H0.
case (le_or_lt bound' (nat_of_P o1')); intros H'8; auto.
rewrite H'5; auto with arith.
Contradict H'6; auto.
apply lt_not_le; rewrite Ho1; auto.
apply
lt_le_trans
with
(nat_of_P o1' * nat_of_P base + 1 * nat_of_P base);
auto with arith.
simpl in |- *; auto with arith.
rewrite <- mult_plus_distr_r.
replace (nat_of_P o1' + 1) with (S (nat_of_P o1'));
auto with arith.
rewrite H'5; auto with arith.
rewrite <- (fun x y => mult_comm (nat_of_P x) y); auto with arith.
rewrite plus_comm; auto with arith.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto with arith.
intros o4; case o4; simpl in |- *.
intros o4' n Eq1; rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, (H'2, H'3)).
generalize (lt_O_nat_of_P o1'); rewrite H'1; intros tmp; inversion tmp.
rewrite Ho1; auto.
apply le_lt_trans with (nat_of_P o1' * 1 + 0); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
repeat rewrite (fun x => plus_comm x 0); simpl in |- *; auto with arith.
apply mult_S_le_reg_l with (n := pred (nat_of_P base)).
replace (S (pred (nat_of_P base))) with (nat_of_P base).
rewrite (mult_comm (nat_of_P base)); simpl in |- *; auto with arith.
rewrite (fun x => plus_comm x 0) in Ho1; simpl in Ho1; rewrite <- Ho1.
generalize Hq0; clear Hq0;
replace (nat_of_P (xI p0)) with (2 * nat_of_P p0 + 1);
try intros Hq0.
case (le_lt_or_eq _ _ Hq0); auto.
rewrite (fun x y => plus_comm x (S y)); intros Hl1.
apply le_trans with (2 * nat_of_P p0); auto with arith.
generalize Hb Ho1; case (nat_of_P base); auto.
intros tmp; Contradict tmp; auto with arith.
intros base'; case base'.
intros tmp; Contradict tmp; auto with arith.
intros base''; case base''.
replace (nat_of_P (xI p0)) with (1 + 2 * nat_of_P p0);
auto with arith.
intros Hb0 Ho0 H; Contradict H; rewrite Ho0.
rewrite (fun x y => mult_comm x (S y)).
apply Compare.not_eq_sym.
apply odd_even_lem.
unfold nat_of_P in |- *; simpl in |- *; (rewrite ZL6; auto).
intros n Hb0 Ho0 H; rewrite H.
apply le_trans with (S (S n) * nat_of_P p0 + nat_of_P p0);
auto with arith.
apply plus_le_compat; auto with arith.
rewrite plus_comm; simpl in |- *; auto with arith.
rewrite plus_comm; unfold nat_of_P in |- *; simpl in |- *;
(rewrite ZL6; unfold nat_of_P in |- *; auto).
generalize (lt_O_nat_of_P base); case (nat_of_P base);
simpl in |- *; auto; intros tmp; inversion tmp.
intros p0 Hq0 (Ho1, Ho2);
(cut (nat_of_P o1' <= nat_of_P p0); [ intros Hrec | idtac ]).
cut (nat_of_P o1' < nat_of_P p); [ intros Hrec1 | idtac ].
generalize (Rec _ Hrec1 _ Hrec).
CaseEq (Pdivless bound o1' base p0); simpl in |- *.
intros p1; case p1; simpl in |- *.
intros o3; case o3; simpl in |- *; auto.
intros o3' o4; case o4; simpl in |- *; auto.
intros o4' n Eq1; rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
replace 0 with (0 * exp (nat_of_P base) n); auto with arith.
intros bound' H'5 H'6;
case (le_or_lt (nat_of_P bound) (nat_of_P o1'));
intros H'7; auto.
apply (H'4 bound'); auto.
rewrite Pdivless1 in Eq1; auto.
inversion Eq1.
rewrite <- H0.
case (le_or_lt bound' (nat_of_P o1')); intros H'8; auto.
rewrite H'5; auto with arith.
Contradict H'6; auto.
apply lt_not_le; rewrite Ho1; auto.
apply
lt_le_trans
with
(nat_of_P o1' * nat_of_P base + 1 * nat_of_P base);
auto with arith.
simpl in |- *; auto with arith.
rewrite <- mult_plus_distr_r.
replace (nat_of_P o1' + 1) with (S (nat_of_P o1'));
auto with arith.
rewrite H'5; auto with arith.
rewrite <- (fun x y => mult_comm (nat_of_P x) y); auto with arith.
rewrite plus_comm; auto with arith.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto with arith.
intros o4; case o4; simpl in |- *.
intros o4' n Eq1; rewrite nat_of_P_mult_morphism.
intros (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
rewrite (fun x y => mult_comm x (nat_of_P y)); auto with arith.
intros bound' H H0; apply (H'4 bound'); auto.
case (le_or_lt (nat_of_P bound) (nat_of_P o1')); intros H'8;
auto.
rewrite Pdivless1 in Eq1; auto.
discriminate.
apply nat_of_P_gt_Gt_compare_complement_morphism; auto.
intros n Eq1 (H'1, ((H'2, H'3), H'4)); repeat (split; auto).
rewrite Ho1; rewrite H'1; ring.
replace 0 with (0 * exp (nat_of_P base) n); auto with arith.
intros bound' H H0; Contradict H0; rewrite Ho1; rewrite H'1; simpl in |- *;
auto with arith.
rewrite Ho1; auto with arith.
apply le_lt_trans with (nat_of_P o1' * 1 + 0); auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
apply mult_S_le_reg_l with (n := pred (nat_of_P base)).
replace (S (pred (nat_of_P base))) with (nat_of_P base).
apply le_trans with (nat_of_P p); auto.
rewrite Ho1; rewrite (fun x => plus_comm x 0); simpl in |- *; auto.
rewrite (mult_comm (nat_of_P base)); simpl in |- *; auto with arith.
apply le_trans with (1 := Hq0); auto with arith.
replace (nat_of_P (xO p0)) with (2 * nat_of_P p0);
auto with arith.
unfold nat_of_P in |- *; simpl in |- *; (rewrite ZL6; auto).
generalize (lt_O_nat_of_P base); case (nat_of_P base);
simpl in |- *; auto; intros tmp; inversion tmp.
replace (nat_of_P 1) with 1; auto with arith.
intros Hq0 (H, H0); Contradict Hq0.
apply lt_not_le.
rewrite H.
generalize (lt_O_nat_of_P o1'); case (nat_of_P o1');
simpl in |- *; auto.
intros tmp; Contradict tmp; auto with arith.
intros n H2; generalize Hb.
case (nat_of_P base); simpl in |- *; auto.
intros tmp; Contradict tmp; auto with arith.
intros base'; case base'; simpl in |- *; auto with arith.
intros tmp; Contradict tmp; auto with arith.
intros o2; case o2; simpl in |- *; auto with arith.
intros o2' (Ho1, Ho2); repeat (split; auto with arith).
rewrite mult_comm; simpl in |- *; auto with arith.
intros bound' H H0; Contradict Ho2.
apply le_not_lt.
rewrite <- Ho1.
generalize H; case bound'.
rewrite mult_comm; simpl in |- *; auto.
intros Eq2; generalize (lt_O_nat_of_P bound); rewrite Eq2; intros tmp;
Contradict tmp; auto with arith.
intros n Eq2; apply le_trans with (nat_of_P bound); auto with arith.
rewrite Eq2; auto with arith.
rewrite mult_comm; simpl in |- *; auto with arith.
intros (Ho1, Ho2); generalize (lt_O_nat_of_P p); rewrite Ho1; intros tmp;
Contradict tmp; auto with arith.
Qed.
Definition PdivBound bound p base := Pdivless bound p base p.
intros; unfold PdivBound in |- *; apply Pdivless_correct; auto.
Qed.
intros bound p base H; generalize (PdivBound_correct bound p base); intuition.
Qed.
intros bound p base H; generalize (PdivBound_correct bound p base); intuition.
Qed.
intros bound p base H; (unfold PdivBound in |- *; apply Pdivless1; auto).
apply nat_of_P_gt_Gt_compare_complement_morphism; auto with arith.
Qed.

Theorem PdivBound_correct4 :
forall bound p base bound',
1 < nat_of_P base ->
nat_of_P bound = nat_of_P base * bound' ->
nat_of_P bound <= nat_of_P p ->
nat_of_P bound <=
nat_of_P base * oZ (fst (fst (PdivBound bound p base))).