Skip to content

Commit 5b6828f

Browse files
committed
fix some notations
1 parent bc7153c commit 5b6828f

2 files changed

Lines changed: 29 additions & 30 deletions

File tree

digitn.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Proof. by rewrite /digitn divn1. Qed.
2626
Lemma digitnS b n m : digitn b n m.+1 = digitn b (n %/ b) m.
2727
Proof. by rewrite /digitn -divnMA expnS. Qed.
2828

29-
Lemma ltn_pdigit b n m : 0 < b -> digitn b n m < b.
29+
Lemma ltn_digitn b n m : 0 < b -> digitn b n m < b.
3030
Proof. by apply: ltn_pmod. Qed.
3131

3232
Lemma digitnE b n m : n < b ^ m -> n = \sum_(i < m) digitn b n i * b ^ i.
@@ -53,7 +53,7 @@ case: ltngtP=> [mLn|nLm|->]; rewrite /digitn.
5353
by rewrite divnn expn_gt0 ltnW // modn_small.
5454
Qed.
5555

56-
Lemma digitn_mulD b m d n : d < b -> digitn b (b * m + d) n.+1 = digitn b m n.
56+
Lemma digitnMD b m d n : d < b -> digitn b (b * m + d) n.+1 = digitn b m n.
5757
Proof.
5858
move=> dLb.
5959
have b_pos : 0 < b by apply: leq_ltn_trans dLb.
@@ -226,7 +226,7 @@ move=> mLbn.
226226
rewrite {1}rdigitnE [RHS](digitnE mLbn).
227227
apply: eq_bigr => i _; congr (_ * _).
228228
rewrite rdigitnE.
229-
pose f1 := [ffun i : 'I_n => (Ordinal (@ltn_pdigit b m (n.-1 - i) b_gt0)) ].
229+
pose f1 := [ffun i : 'I_n => (Ordinal (@ltn_digitn b m (n.-1 - i) b_gt0)) ].
230230
have G : \sum_(i < n) digitn b m (n.-1 - i) * b ^ i =
231231
\sum_(i < n) (f1 i * b ^ i).
232232
by apply: eq_bigr => j _; rewrite ffunE.
@@ -243,7 +243,7 @@ rewrite big_ord_recr /= -addSn.
243243
have -> : (b ^ n.+1 = b ^ n + b.-1 * b ^ n)%nat.
244244
by rewrite expnS -[X in X * _ = _](prednK b_gt0) mulSn.
245245
rewrite leq_add // leq_mul2r expn_eq0 eqn0Ngt b_gt0 /= -ltnS prednK //.
246-
by rewrite ltn_pdigit.
246+
by rewrite ltn_digitn.
247247
Qed.
248248

249249
Lemma ltn_rdigitn b n m : 0 < b -> rdigitn b n m < b ^ n.
@@ -315,15 +315,15 @@ have H i :
315315
\sum_(j < p) 'X^(p ^ i) ^+ j *+ 'C(digitn p m i, j).
316316
under eq_bigr do rewrite expr1n mul1r.
317317
rewrite -!(big_mkord xpredT (fun j => 'X^(p ^ i) ^+ j *+ 'C(digitn p m i, j))).
318-
rewrite (big_cat_nat _ (ltn_pdigit m i (prime_gt0 Pp))) //=.
318+
rewrite (big_cat_nat _ (ltn_digitn m i (prime_gt0 Pp))) //=.
319319
rewrite [X in _ = _ + X]big_nat_cond [X in _ = _ + X]big1 ?addr0 // => j.
320320
by case/andP=> /andP[/bin_small->]; rewrite mulr0n.
321321
under eq_bigr do rewrite {}H.
322322
rewrite bigA_distr_bigA /= coef_sum.
323323
under eq_bigr do under eq_bigr do rewrite -exprM mulnC.
324324
under eq_bigr do rewrite prodrMn -expr_sum coefMn coefXn.
325325
pose f : {ffun 'I_k -> 'I_p} :=
326-
[ffun i : 'I_k => Ordinal (ltn_pdigit n i (prime_gt0 Pp))].
326+
[ffun i : 'I_k => Ordinal (ltn_digitn n i (prime_gt0 Pp))].
327327
rewrite (bigD1 f) //= [X in (_ %% X)%N]Fp_cast //= .
328328
rewrite [in X in ((_ + X) = _ %[mod _])%N]big1 ?addn0 => [| i iDf].
329329
rewrite (_ : _ == _) ?mulr1n.

factorion.v

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,32 @@ move=> n_pos b_gt1 d_digit.
5252
rewrite /sum_fact ndigitsMD // big_ord_recl; congr (_ + _).
5353
by rewrite digitn0 mulnC modnMDl modn_small.
5454
apply: eq_bigr => /= i _.
55-
by rewrite digitn_mulD // ltnW.
55+
by rewrite digitnMD // ltnW.
5656
Qed.
5757

5858
Lemma sum_factM b n :
5959
0 < n -> 1 < b -> sum_fact b (b * n) = (sum_fact b n).+1.
6060
Proof. by move=> ? ?; rewrite -[b * n]addn0 sum_factMD // ltnW. Qed.
6161

62-
Definition factorion (n : nat) := sum_fact 10 n == n.
62+
Definition factorion := [qualify a n | sum_fact 10 n == n].
6363

64-
Lemma factorion0 : ~ factorion 0.
65-
Proof. by rewrite /factorion /sum_fact !big_ord_recr /= big_ord0. Qed.
64+
Lemma factorion0 : 0 \isn't a factorion.
65+
Proof. by rewrite qualifE /sum_fact !big_ord_recr /= big_ord0. Qed.
6666

67-
Lemma factorion1 : factorion 1.
68-
Proof. by rewrite /factorion /sum_fact !big_ord_recr /= big_ord0. Qed.
67+
Lemma factorion1 : 1 \is a factorion.
68+
Proof. by rewrite qualifE /sum_fact !big_ord_recr /= big_ord0. Qed.
6969

70-
Lemma factorion2 : factorion 2.
71-
Proof. by rewrite /factorion /sum_fact !big_ord_recr /= big_ord0. Qed.
70+
Lemma factorion2 : 2 \is a factorion.
71+
Proof. by rewrite qualifE /sum_fact !big_ord_recr /= big_ord0. Qed.
7272

73-
Lemma factorion145 : factorion 145.
73+
Lemma factorion145 : 145 \is a factorion.
7474
Proof.
75-
by rewrite /factorion /sum_fact -[ndigits 10 145]/3 !big_ord_recr big_ord0.
75+
by rewrite qualifE /sum_fact -[ndigits 10 145]/3 !big_ord_recr big_ord0.
7676
Qed.
7777

78-
Lemma factorion40585 : factorion v40585.
78+
Lemma factorion40585 : v40585 \is a factorion.
7979
Proof.
80-
by rewrite /factorion /sum_fact -[ndigits 10 v40585]/5 !big_ord_recr big_ord0.
80+
by rewrite qualifE /sum_fact -[ndigits 10 v40585]/5 !big_ord_recr big_ord0.
8181
Qed.
8282

8383
Lemma sum_fact_bound b n : 1 < b -> sum_fact b n <= ndigits b n * b.-1 `!.
@@ -87,12 +87,12 @@ rewrite -[X in _ <= X * _]subn0 -[X in _ <= X]sum_nat_const_nat big_mkord.
8787
elim: ndigits => [|k IH]; first by rewrite !big_ord0.
8888
rewrite !big_ord_recr /= leq_add //.
8989
case: (b) b_pos => // [] [|b1] // _.
90-
case: digitn (ltn_pdigit n k (isT : 0 < b1.+2))=> [_ |d dLb] //.
90+
case: digitn (ltn_digitn n k (isT : 0 < b1.+2))=> [_ |d dLb] //.
9191
by rewrite -[0 `!]/(1 `!) leq_pfact.
9292
by rewrite leq_pfact.
9393
Qed.
9494

95-
Lemma sum_fact10_increasing n : 7 < ndigits 10 n -> sum_fact 10 n < n.
95+
Lemma ltn_sum_fact10 n : 7 < ndigits 10 n -> sum_fact 10 n < n.
9696
Proof.
9797
move=> nL7.
9898
have n_pos : 0 < n by case: n nL7.
@@ -109,9 +109,9 @@ rewrite leq_pmul2r // -subSS subSn // -[X in X <= _](subnK nL7).
109109
by elim: (_ - _) => // k IH; rewrite (leq_ltn_trans IH _) // ltn_exp2l.
110110
Qed.
111111

112-
Lemma factorion_upperbound n : factorion n -> ndigits 10 n <= 7.
112+
Lemma factorion_upperbound n : n \is a factorion -> ndigits 10 n <= 7.
113113
Proof.
114-
by move=> Hf; case: leqP => // /sum_fact10_increasing; rewrite (eqP Hf) ltnn.
114+
by move=> Hf; case: leqP => // /ltn_sum_fact10; rewrite (eqP Hf) ltnn.
115115
Qed.
116116

117117
Fixpoint fact_look_up1 (r : rel N) (k : nat) (n p : N) (l : seq N) : seq N :=
@@ -279,7 +279,7 @@ case=> [d9E|].
279279
by congr ((_ * (_ * (_ * _)%coq_nat)%coq_nat)%coq_nat + _)%coq_nat.
280280
move=> d d1E.
281281
suff : d1 < 10 by rewrite d1E.
282-
by apply: ltn_pdigit.
282+
by apply: ltn_digitn.
283283
Qed.
284284

285285
Definition fact_look_up r k : seq N :=
@@ -351,10 +351,10 @@ case => [d9E mE|].
351351
by congr (_ * (_ * _)%coq_nat)%coq_nat.
352352
move=> d d1E.
353353
suff : d1 < 10 by rewrite d1E.
354-
by apply: ltn_pdigit.
354+
by apply: ltn_digitn.
355355
Qed.
356356

357-
Lemma factorionE m : factorion m = (m \in [::1; 2; 145; v40585]).
357+
Lemma factorionE m : m \is a factorion = (m \in [::1; 2; 145; v40585]).
358358
Proof.
359359
apply/idP/idP; last first.
360360
rewrite !inE; case/or4P => /eqP->.
@@ -377,7 +377,7 @@ have := ndigits_gt0 10 m.
377377
pose get_factorion d := fact_look_up [rel m n | (m =? n)%num] d.
378378
have : N.of_nat m \in get_factorion (ndigits 10 m).-1.
379379
apply: fact_look_up_spec => /=.
380-
by case: (m) mF factorion0 => // [].
380+
by case: (m) mF factorion0 => // ? /negP[].
381381
by rewrite (eqP mF); case: N.eqb_spec.
382382
case: ndigits => //.
383383
case.
@@ -549,7 +549,7 @@ by rewrite -[169 in LHS]Nat2N.id -Nsum_fact10_spec.
549549
Qed.
550550

551551
(* *)
552-
Lemma sum_fact10_iter_increase n :
552+
Lemma leq_sum_fact10_iter n :
553553
exists k, let v := iter k (sum_fact 10) n in v <= (sum_fact 10 v).
554554
Proof.
555555
have [k nLk]:= ubnP n; elim: k n nLk => [[]//|k IH n nLk].
@@ -590,7 +590,6 @@ Qed.
590590
Definition cend_in_cycle n m :=
591591
if (n <? m)%num then ~~ check_loop m 60 else false.
592592

593-
Check fact_look_up_spec .
594593
Lemma cend_in_cycleN_spec n m :
595594
~~ cend_in_cycle n m -> (n <? m)%num -> m = Nsum_fact10 n ->
596595
exists k,
@@ -613,7 +612,7 @@ Qed.
613612
Lemma factorion_no_large_cycle n :
614613
exists k, iter k (sum_fact 10) n \in [:: 1; 2; 145; v40585; 871; 872; 169].
615614
Proof.
616-
case: (sum_fact10_iter_increase n) => k.
615+
case: (leq_sum_fact10_iter n) => k.
617616
set v := iter k (sum_fact 10) n => /=.
618617
rewrite leq_eqVlt => /orP[/eqP vE| vLs].
619618
exists k; rewrite -/v.
@@ -626,7 +625,7 @@ suff [k1 Hk1] : exists k,
626625
have [|v_pos] := leqP v 0.
627626
by rewrite leqn0 => /eqP->; exists 1; rewrite /= sum_fact0 !inE.
628627
have nL7 : ndigits 10 v <= 7.
629-
by case: leqP => // /sum_fact10_increasing; rewrite ltnNge leq_eqVlt vLs orbT.
628+
by case: leqP => // /ltn_sum_fact10; rewrite ltnNge leq_eqVlt vLs orbT.
630629
pose get_list := fact_look_up cend_in_cycle.
631630
suff g_nil : get_list (ndigits 10 v).-1 = [::].
632631
have Hv := @fact_look_up_spec cend_in_cycle _ v_pos.

0 commit comments

Comments
 (0)