1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| A.Asperti, C.Sacerdoti Coen, *)
8 (* ||A|| E.Tassi, S.Zacchiroli *)
10 (* \ / Matita is distributed under the terms of the *)
11 (* v GNU Lesser General Public License Version 2.1 *)
13 (**************************************************************************)
17 (* the following factorization algorithm looks for the largest prime
19 definition max_prime_factor \def \lambda n:nat.
20 (max n (\lambda p:nat.eqb (n \mod (nth_prime p)) O)).
22 theorem lt_SO_max_prime: \forall m. S O < m \to
23 S O < max m (λi:nat.primeb i∧divides_b i m).
25 apply (lt_to_le_to_lt ? (smallest_factor m))
26 [apply lt_SO_smallest_factor.assumption
28 [apply le_smallest_factor_n
29 |apply true_to_true_to_andb_true
30 [apply prime_to_primeb_true.
31 apply prime_smallest_factor_n.
33 |apply divides_to_divides_b_true
34 [apply lt_O_smallest_factor.apply lt_to_le.assumption
35 |apply divides_smallest_factor_n.
36 apply lt_to_le.assumption
42 (* max_prime_factor is indeed a factor *)
43 theorem divides_max_prime_factor_n:
44 \forall n:nat. (S O) < n
45 \to nth_prime (max_prime_factor n) \divides n.
47 apply divides_b_true_to_divides.
48 apply (f_max_true (\lambda p:nat.eqb (n \mod (nth_prime p)) O) n);
49 cut (\exists i. nth_prime i = smallest_factor n);
51 apply (ex_intro nat ? a);
53 [ apply (trans_le a (nth_prime a));
55 exact lt_nth_prime_n_nth_prime_Sn;
57 apply le_smallest_factor_n; ]
59 change with (divides_b (smallest_factor n) n = true);
60 apply divides_to_divides_b_true;
61 [ apply (trans_lt ? (S O));
62 [ unfold lt; apply le_n;
63 | apply lt_SO_smallest_factor; assumption; ]
64 | apply divides_smallest_factor_n;
66 | apply prime_to_nth_prime;
69 apply prime_to_nth_prime;
70 apply prime_smallest_factor_n;
74 lemma divides_to_prime_divides : \forall n,m.1 < m \to m < n \to m \divides n \to
75 \exists p.p \leq m \land prime p \land p \divides n.
76 intros;apply (ex_intro ? ? (nth_prime (max_prime_factor m)));split
79 [apply lt_to_le;assumption
80 |apply divides_max_prime_factor_n;assumption]
81 |apply prime_nth_prime;]
82 |apply (transitive_divides ? ? ? ? H2);apply divides_max_prime_factor_n;
86 theorem divides_to_max_prime_factor : \forall n,m. (S O) < n \to O < m \to n \divides m \to
87 max_prime_factor n \le max_prime_factor m.
88 intros.unfold max_prime_factor.
91 apply le_max_n.apply divides_to_le.assumption.assumption.
92 change with (divides_b (nth_prime (max_prime_factor n)) m = true).
93 apply divides_to_divides_b_true.
94 cut (prime (nth_prime (max_prime_factor n))).
95 apply lt_O_nth_prime_n.apply prime_nth_prime.
96 cut (nth_prime (max_prime_factor n) \divides n).
100 [ apply (transitive_divides ? n);
101 [ apply divides_max_prime_factor_n.
105 | apply divides_b_true_to_divides;
106 [ apply lt_O_nth_prime_n.
107 | apply divides_to_divides_b_true;
108 [ apply lt_O_nth_prime_n.
109 | apply divides_max_prime_factor_n.
117 theorem divides_to_max_prime_factor1 : \forall n,m. O < n \to O < m \to n \divides m \to
118 max_prime_factor n \le max_prime_factor m.
120 elim (le_to_or_lt_eq ? ? H)
121 [apply divides_to_max_prime_factor
122 [assumption|assumption|assumption]
124 simplify.apply le_O_n.
128 theorem max_prime_factor_to_not_p_ord_O : \forall n,p,r.
130 p = max_prime_factor n \to
131 p_ord n (nth_prime p) \neq pair nat nat O r.
132 intros.unfold Not.intro.
133 apply (p_ord_O_to_not_divides ? ? ? ? H2)
134 [apply (trans_lt ? (S O))[apply lt_O_S|assumption]
136 apply divides_max_prime_factor_n.
141 theorem p_ord_to_lt_max_prime_factor: \forall n,p,q,r. O < n \to
142 p = max_prime_factor n \to
143 (pair nat nat q r) = p_ord n (nth_prime p) \to
144 (S O) < r \to max_prime_factor r < p.
147 cut (max_prime_factor r \lt max_prime_factor n \lor
148 max_prime_factor r = max_prime_factor n).
149 elim Hcut.assumption.
150 absurd (nth_prime (max_prime_factor n) \divides r).
152 apply divides_max_prime_factor_n.
153 assumption.unfold Not.
155 cut (r \mod (nth_prime (max_prime_factor n)) \neq O);
156 [ apply Hcut1; autobatch depth=2;
158 apply Hcut1.apply divides_to_mod_O;
159 [ apply lt_O_nth_prime_n.
163 | unfold p_ord in H2; lapply depth=0 le_n; autobatch width = 4 depth = 2;
164 (*apply (p_ord_aux_to_not_mod_O n n ? q r);
165 [ apply lt_SO_nth_prime_n.
168 | rewrite < H1.assumption.
172 apply (le_to_or_lt_eq (max_prime_factor r) (max_prime_factor n)).
173 apply divides_to_max_prime_factor.
174 assumption.assumption.
175 apply (witness r n ((nth_prime p) \sup q)).
177 apply (p_ord_aux_to_exp n n ? q r).
178 apply lt_O_nth_prime_n.assumption.
181 theorem p_ord_to_lt_max_prime_factor1: \forall n,p,q,r. O < n \to
182 max_prime_factor n \le p \to
183 (pair nat nat q r) = p_ord n (nth_prime p) \to
184 (S O) < r \to max_prime_factor r < p.
186 cut (max_prime_factor n < p \lor max_prime_factor n = p).
187 elim Hcut.apply (le_to_lt_to_lt ? (max_prime_factor n)).
188 apply divides_to_max_prime_factor.assumption.assumption.
189 apply (witness r n ((nth_prime p) \sup q)).
191 apply (p_ord_aux_to_exp n n).
192 apply lt_O_nth_prime_n.
193 assumption.assumption.
194 apply (p_ord_to_lt_max_prime_factor n ? q).
195 assumption.apply sym_eq.assumption.assumption.assumption.
196 apply (le_to_or_lt_eq ? p H1).
199 lemma lt_max_prime_factor_to_not_divides: \forall n,p:nat.
200 O < n \to n=S O \lor max_prime_factor n < p \to
201 (nth_prime p \ndivides n).
202 intros.unfold Not.intro.
205 apply (le_to_not_lt (nth_prime p) (S O))
206 [apply divides_to_le[apply le_n|assumption]
207 |apply lt_SO_nth_prime_n
209 |apply (not_le_Sn_n p).
211 apply (le_to_lt_to_lt ? ? ? ? H3).
212 unfold max_prime_factor.
214 [apply (trans_le ? (nth_prime p))
216 apply lt_n_nth_prime_n
217 |apply divides_to_le;assumption
219 |apply eq_to_eqb_true.
220 apply divides_to_mod_O
221 [apply lt_O_nth_prime_n|assumption]
226 (* datatypes and functions *)
228 inductive nat_fact : Set \def
229 nf_last : nat \to nat_fact
230 | nf_cons : nat \to nat_fact \to nat_fact.
232 inductive nat_fact_all : Set \def
233 nfa_zero : nat_fact_all
234 | nfa_one : nat_fact_all
235 | nfa_proper : nat_fact \to nat_fact_all.
237 let rec factorize_aux p n acc \def
241 match p_ord n (nth_prime p1) with
242 [ (pair q r) \Rightarrow
243 factorize_aux p1 r (nf_cons q acc)]].
245 definition factorize : nat \to nat_fact_all \def \lambda n:nat.
247 [ O \Rightarrow nfa_zero
250 [ O \Rightarrow nfa_one
252 let p \def (max (S(S n2)) (\lambda p:nat.eqb ((S(S n2)) \mod (nth_prime p)) O)) in
253 match p_ord (S(S n2)) (nth_prime p) with
254 [ (pair q r) \Rightarrow
255 nfa_proper (factorize_aux p r (nf_last (pred q)))]]].
257 let rec defactorize_aux f i \def
259 [ (nf_last n) \Rightarrow (nth_prime i) \sup (S n)
260 | (nf_cons n g) \Rightarrow
261 (nth_prime i) \sup n *(defactorize_aux g (S i))].
263 definition defactorize : nat_fact_all \to nat \def
264 \lambda f : nat_fact_all.
266 [ nfa_zero \Rightarrow O
267 | nfa_one \Rightarrow (S O)
268 | (nfa_proper g) \Rightarrow defactorize_aux g O].
270 theorem lt_O_defactorize_aux:
273 O < defactorize_aux f i.
277 rewrite > times_n_SO;
279 [ change with (O < nth_prime i);
280 apply lt_O_nth_prime_n;
282 change with (O < exp (nth_prime i) n);
284 apply lt_O_nth_prime_n;
285 | change with (O < defactorize_aux n1 (S i));
289 theorem lt_SO_defactorize_aux: \forall f:nat_fact.\forall i:nat.
290 S O < defactorize_aux f i.
291 intro.elim f.simplify.unfold lt.
292 rewrite > times_n_SO.
294 change with (S O < nth_prime i).
295 apply lt_SO_nth_prime_n.
296 change with (O < exp (nth_prime i) n).
298 apply lt_O_nth_prime_n.
300 rewrite > times_n_SO.
303 change with (O < exp (nth_prime i) n).
305 apply lt_O_nth_prime_n.
306 change with (S O < defactorize_aux n1 (S i)).
310 theorem defactorize_aux_factorize_aux :
311 \forall p,n:nat.\forall acc:nat_fact.O < n \to
312 ((n=(S O) \land p=O) \lor max_prime_factor n < p) \to
313 defactorize_aux (factorize_aux p n acc) O = n*(defactorize_aux acc p).
314 intro.elim p.simplify.
315 elim H1.elim H2.rewrite > H3.
316 rewrite > sym_times. apply times_n_SO.
317 apply False_ind.apply (not_le_Sn_O (max_prime_factor n) H2).
319 (* generalizing the goal: I guess there exists a better way *)
320 cut (\forall q,r.(pair nat nat q r) = (p_ord_aux n1 n1 (nth_prime n)) \to
321 defactorize_aux match (p_ord_aux n1 n1 (nth_prime n)) with
322 [(pair q r) \Rightarrow (factorize_aux n r (nf_cons q acc))] O =
323 n1*defactorize_aux acc (S n)).
324 apply (Hcut (fst ? ? (p_ord_aux n1 n1 (nth_prime n)))
325 (snd ? ? (p_ord_aux n1 n1 (nth_prime n)))).
326 apply sym_eq.apply eq_pair_fst_snd.
330 cut (n1 = r * (nth_prime n) \sup q).
332 simplify.rewrite < assoc_times.
333 rewrite < Hcut.reflexivity.
334 cut (O < r \lor O = r).
335 elim Hcut1.assumption.absurd (n1 = O).
336 rewrite > Hcut.rewrite < H4.reflexivity.
337 unfold Not. intro.apply (not_le_Sn_O O).
338 rewrite < H5 in \vdash (? ? %).assumption.
339 apply le_to_or_lt_eq.apply le_O_n.
340 cut ((S O) < r \lor (S O) \nlt r).
343 apply (p_ord_to_lt_max_prime_factor1 n1 ? q r).
347 apply (not_eq_O_S n).apply sym_eq.assumption.
350 assumption.assumption.
353 left.split.assumption.reflexivity.
354 intro.right.rewrite > Hcut2.
355 simplify.unfold lt.apply le_S_S.apply le_O_n.
356 cut (r < (S O) ∨ r=(S O)).
357 elim Hcut2.absurd (O=r).
358 apply le_n_O_to_eq.apply le_S_S_to_le.exact H5.
361 apply (not_le_Sn_O O).
362 rewrite > Hcut3 in ⊢ (? ? %).
363 assumption.rewrite > Hcut.
364 rewrite < H6.reflexivity.
366 apply (le_to_or_lt_eq r (S O)).
367 apply not_lt_to_le.assumption.
368 apply (decidable_lt (S O) r).
370 apply (p_ord_aux_to_exp n1 n1).
371 apply lt_O_nth_prime_n.assumption.
374 theorem defactorize_factorize: \forall n:nat.defactorize (factorize n) = n.
376 apply (nat_case n).reflexivity.
377 intro.apply (nat_case m).reflexivity.
380 (let p \def (max (S(S m1)) (\lambda p:nat.eqb ((S(S m1)) \mod (nth_prime p)) O)) in
381 defactorize (match p_ord (S(S m1)) (nth_prime p) with
382 [ (pair q r) \Rightarrow
383 nfa_proper (factorize_aux p r (nf_last (pred q)))])=(S(S m1))).
385 (* generalizing the goal; find a better way *)
386 cut (\forall q,r.(pair nat nat q r) = (p_ord (S(S m1)) (nth_prime p)) \to
387 defactorize (match p_ord (S(S m1)) (nth_prime p) with
388 [ (pair q r) \Rightarrow
389 nfa_proper (factorize_aux p r (nf_last (pred q)))])=(S(S m1))).
390 apply (Hcut (fst ? ? (p_ord (S(S m1)) (nth_prime p)))
391 (snd ? ? (p_ord (S(S m1)) (nth_prime p)))).
392 apply sym_eq.apply eq_pair_fst_snd.
396 cut ((S(S m1)) = (nth_prime p) \sup q *r).
398 rewrite > defactorize_aux_factorize_aux.
399 change with (r*(nth_prime p) \sup (S (pred q)) = (S(S m1))).
400 cut ((S (pred q)) = q).
404 apply (p_ord_aux_to_exp (S(S m1))).
405 apply lt_O_nth_prime_n.
408 apply sym_eq. apply S_pred.
409 cut (O < q \lor O = q).
410 elim Hcut2.assumption.
411 absurd (nth_prime p \divides S (S m1)).
412 apply (divides_max_prime_factor_n (S (S m1))).
413 unfold lt.apply le_S_S.apply le_S_S. apply le_O_n.
415 rewrite > Hcut3 in \vdash (? (? ? %)).
416 change with (nth_prime p \divides r \to False).
418 apply (p_ord_aux_to_not_mod_O (S(S m1)) (S(S m1)) (nth_prime p) q r).
419 apply lt_SO_nth_prime_n.
420 unfold lt.apply le_S_S.apply le_O_n.apply le_n.
422 apply divides_to_mod_O.apply lt_O_nth_prime_n.assumption.
423 rewrite > times_n_SO in \vdash (? ? ? %).
425 rewrite > (exp_n_O (nth_prime p)).
426 rewrite > H1 in \vdash (? ? ? (? (? ? %) ?)).
428 apply le_to_or_lt_eq.apply le_O_n.assumption.
429 (* e adesso l'ultimo goal. TASSI: che ora non e' piu' l'ultimo :P *)
430 cut ((S O) < r \lor S O \nlt r).
433 apply (p_ord_to_lt_max_prime_factor1 (S(S m1)) ? q r).
434 unfold lt.apply le_S_S. apply le_O_n.
436 assumption.assumption.
439 left.split.assumption.reflexivity.
440 intro.right.rewrite > Hcut3.
441 simplify.unfold lt.apply le_S_S.apply le_O_n.
442 cut (r \lt (S O) \or r=(S O)).
443 elim Hcut3.absurd (O=r).
444 apply le_n_O_to_eq.apply le_S_S_to_le.exact H2.
446 apply (not_le_Sn_O O).
447 rewrite > H3 in \vdash (? ? %).assumption.assumption.
448 apply (le_to_or_lt_eq r (S O)).
449 apply not_lt_to_le.assumption.
450 apply (decidable_lt (S O) r).
452 cut (O < r \lor O = r).
453 elim Hcut1.assumption.
455 apply (not_eq_O_S (S m1)).
456 rewrite > Hcut.rewrite < H1.rewrite < times_n_O.reflexivity.
457 apply le_to_or_lt_eq.apply le_O_n.
459 apply (p_ord_aux_to_exp (S(S m1))).
460 apply lt_O_nth_prime_n.
467 [ (nf_last n) \Rightarrow O
468 | (nf_cons n g) \Rightarrow S (max_p g)].
470 let rec max_p_exponent f \def
472 [ (nf_last n) \Rightarrow n
473 | (nf_cons n g) \Rightarrow max_p_exponent g].
475 theorem divides_max_p_defactorize: \forall f:nat_fact.\forall i:nat.
476 nth_prime ((max_p f)+i) \divides defactorize_aux f i.
478 elim f.simplify.apply (witness ? ? ((nth_prime i) \sup n)).
481 (nth_prime (S(max_p n1)+i) \divides
482 (nth_prime i) \sup n *(defactorize_aux n1 (S i))).
486 rewrite > assoc_times.
488 apply (witness ? ? (n2* (nth_prime i) \sup n)).
492 lemma eq_p_max: \forall n,p,r:nat. O < n \to
494 r = (S O) \lor (max r (\lambda p:nat.eqb (r \mod (nth_prime p)) O)) < p \to
495 p = max_prime_factor (r*(nth_prime p)\sup n).
498 unfold max_prime_factor.
499 apply max_spec_to_max.
502 [rewrite > times_n_SO in \vdash (? % ?).
507 apply (lt_to_le_to_lt ? (nth_prime p))
508 [apply lt_n_nth_prime_n
509 |rewrite > exp_n_SO in \vdash (? % ?).
511 [apply lt_O_nth_prime_n
516 |apply eq_to_eqb_true.
517 apply divides_to_mod_O
518 [apply lt_O_nth_prime_n
519 |apply (lt_O_n_elim ? H).
521 apply (witness ? ? ((r*(nth_prime p) \sup m))).
522 rewrite < assoc_times.
523 rewrite < sym_times in \vdash (? ? ? (? % ?)).
524 rewrite > exp_n_SO in \vdash (? ? ? (? (? ? %) ?)).
525 rewrite > assoc_times.
526 rewrite < exp_plus_times.
531 apply not_eq_to_eqb_false.
533 lapply (mod_O_to_divides ? ? ? H5)
534 [apply lt_O_nth_prime_n
535 |cut (Not (divides (nth_prime i) ((nth_prime p)\sup n)))
537 [rewrite > H6 in Hletin.
539 rewrite < plus_n_O in Hletin.
540 apply Hcut.assumption
541 |elim (divides_times_to_divides ? ? ? ? Hletin)
542 [apply (lt_to_not_le ? ? H3).
544 apply (le_to_lt_to_lt ? ? ? ? H6).
546 [apply (trans_le ? (nth_prime i))
548 apply lt_n_nth_prime_n
549 |apply divides_to_le[assumption|assumption]
551 |apply eq_to_eqb_true.
552 apply divides_to_mod_O
553 [apply lt_O_nth_prime_n|assumption]
555 |apply prime_nth_prime
556 |apply Hcut.assumption
560 apply (lt_to_not_eq ? ? H3).
562 elim (prime_nth_prime p).
563 apply injective_nth_prime.
565 [apply (divides_exp_to_divides ? ? ? ? H6).
566 apply prime_nth_prime.
567 |apply lt_SO_nth_prime_n
574 theorem not_divides_defactorize_aux: \forall f:nat_fact. \forall i,j:nat.
575 i < j \to nth_prime i \ndivides defactorize_aux f j.
578 (nth_prime i \divides (nth_prime j) \sup (S n) \to False).
579 intro.absurd ((nth_prime i) = (nth_prime j)).
580 apply (divides_exp_to_eq ? ? (S n)).
581 apply prime_nth_prime.apply prime_nth_prime.
582 assumption.unfold Not.
584 apply (not_le_Sn_n i).rewrite > Hcut in \vdash (? ? %).assumption.
585 apply (injective_nth_prime ? ? H2).
588 cut (nth_prime i \divides (nth_prime j) \sup n
589 \lor nth_prime i \divides defactorize_aux n1 (S j)).
591 absurd ((nth_prime i) = (nth_prime j)).
592 apply (divides_exp_to_eq ? ? n).
593 apply prime_nth_prime.apply prime_nth_prime.
594 assumption.unfold Not.
597 apply (not_le_Sn_n i).rewrite > Hcut1 in \vdash (? ? %).assumption.
598 apply (injective_nth_prime ? ? H4).
600 apply (trans_lt ? j).assumption.unfold lt.apply le_n.
602 apply divides_times_to_divides.
603 apply prime_nth_prime.assumption.
606 lemma not_eq_nf_last_nf_cons: \forall g:nat_fact.\forall n,m,i:nat.
607 \lnot (defactorize_aux (nf_last n) i= defactorize_aux (nf_cons m g) i).
610 (exp (nth_prime i) (S n) = defactorize_aux (nf_cons m g) i \to False).
612 cut (S(max_p g)+i= i).
613 apply (not_le_Sn_n i).
614 rewrite < Hcut in \vdash (? ? %).
615 simplify.apply le_S_S.
617 apply injective_nth_prime.
618 apply (divides_exp_to_eq ? ? (S n)).
619 apply prime_nth_prime.apply prime_nth_prime.
621 change with (divides (nth_prime ((max_p (nf_cons m g))+i))
622 (defactorize_aux (nf_cons m g) i)).
623 apply divides_max_p_defactorize.
626 lemma not_eq_nf_cons_O_nf_cons: \forall f,g:nat_fact.\forall n,i:nat.
627 \lnot (defactorize_aux (nf_cons O f) i= defactorize_aux (nf_cons (S n) g) i).
629 simplify.unfold Not.rewrite < plus_n_O.
631 apply (not_divides_defactorize_aux f i (S i) ?).
632 unfold lt.apply le_n.
634 rewrite > assoc_times.
635 apply (witness ? ? ((exp (nth_prime i) n)*(defactorize_aux g (S i)))).
639 theorem eq_defactorize_aux_to_eq: \forall f,g:nat_fact.\forall i:nat.
640 defactorize_aux f i = defactorize_aux g i \to f = g.
645 apply inj_S. apply (inj_exp_r (nth_prime i)).
646 apply lt_SO_nth_prime_n.
649 apply (not_eq_nf_last_nf_cons n2 n n1 i H1).
652 apply (not_eq_nf_last_nf_cons n1 n2 n i).
653 apply sym_eq. assumption.
655 generalize in match H2.
656 apply (nat_elim2 (\lambda n,n2.
657 ((nth_prime i) \sup n)*(defactorize_aux n1 (S i)) =
658 ((nth_prime i) \sup n2)*(defactorize_aux n3 (S i)) \to
659 nf_cons n n1 = nf_cons n2 n3)).
665 rewrite > (plus_n_O (defactorize_aux n3 (S i))).assumption.
667 apply (not_eq_nf_cons_O_nf_cons n1 n3 n5 i).assumption.
670 apply (not_eq_nf_cons_O_nf_cons n3 n1 n4 i).
671 apply sym_eq.assumption.
673 cut (nf_cons n4 n1 = nf_cons m n3).
676 rewrite > Hcut1.rewrite > Hcut2.reflexivity.
678 (match nf_cons n4 n1 with
679 [ (nf_last m) \Rightarrow n1
680 | (nf_cons m g) \Rightarrow g ] = n3).
681 rewrite > Hcut.simplify.reflexivity.
683 (match nf_cons n4 n1 with
684 [ (nf_last m) \Rightarrow m
685 | (nf_cons m g) \Rightarrow m ] = m).
686 rewrite > Hcut.simplify.reflexivity.
687 apply H3.simplify in H4.
688 apply (inj_times_r1 (nth_prime i)).
689 apply lt_O_nth_prime_n.
690 rewrite < assoc_times.rewrite < assoc_times.assumption.
693 theorem injective_defactorize_aux: \forall i:nat.
694 injective nat_fact nat (\lambda f.defactorize_aux f i).
697 apply (eq_defactorize_aux_to_eq x y i H).
700 theorem injective_defactorize:
701 injective nat_fact_all nat defactorize.
703 change with (\forall f,g.defactorize f = defactorize g \to f=g).
711 apply (not_eq_O_S O H).
715 apply (not_le_Sn_n O).
716 rewrite > H in \vdash (? ? %).
717 change with (O < defactorize_aux n O).
718 apply lt_O_defactorize_aux.
723 apply (not_eq_O_S O).apply sym_eq. assumption.
729 apply (not_le_Sn_n (S O)).
730 rewrite > H in \vdash (? ? %).
731 change with ((S O) < defactorize_aux n O).
732 apply lt_SO_defactorize_aux.
737 apply (not_le_Sn_n O).
738 rewrite < H in \vdash (? ? %).
739 change with (O < defactorize_aux n O).
740 apply lt_O_defactorize_aux.
744 apply (not_le_Sn_n (S O)).
745 rewrite < H in \vdash (? ? %).
746 change with ((S O) < defactorize_aux n O).
747 apply lt_SO_defactorize_aux.
748 (* proper - proper *)
750 apply (injective_defactorize_aux O).
754 theorem factorize_defactorize:
755 \forall f: nat_fact_all. factorize (defactorize f) = f.
757 apply injective_defactorize.
758 apply defactorize_factorize.