X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Flibrary%2Fnat%2Fdiv_and_mod.ma;h=523f7431403a14071e2154d661eb9f22ef552332;hb=018a168b0ca16c5951106162e515d7949366d754;hp=f7f2883d590a8118ae6a39a8c348a75dcb2ff565;hpb=db9c252cc8adb9243892203805b203bafe486bfc;p=helm.git diff --git a/helm/software/matita/library/nat/div_and_mod.ma b/helm/software/matita/library/nat/div_and_mod.ma index f7f2883d5..523f74314 100644 --- a/helm/software/matita/library/nat/div_and_mod.ma +++ b/helm/software/matita/library/nat/div_and_mod.ma @@ -223,6 +223,7 @@ apply (div_mod_spec_to_eq2 (q*m+r) m ((q*m+r)/ m) ((q*m+r) \mod m) q r) |apply div_mod_spec_intro[assumption|reflexivity] ] qed. + (* some properties of div and mod *) theorem div_times: \forall n,m:nat. ((S n)*m) / (S n) = m. intros. @@ -312,16 +313,28 @@ rewrite > (div_mod ? (S O)) in \vdash (? ? ? %) ] qed. -theorem le_div: \forall n,m. O < n \to m/n \le m. +theorem or_div_mod: \forall n,q. O < q \to +((S (n \mod q)=q) \land S n = (S (div n q)) * q \lor +((S (n \mod q) (div_mod m n) in \vdash (? ? %) - [apply (trans_le ? (m/n*n)) - [rewrite > times_n_SO in \vdash (? % ?). - apply le_times - [apply le_n|assumption] - |apply le_plus_n_r +elim (le_to_or_lt_eq ? ? (lt_mod_m_m n q H)) + [right.split + [assumption + |rewrite < plus_n_Sm. + apply eq_f. + apply div_mod. + assumption + ] + |left.split + [assumption + |simplify. + rewrite > sym_plus. + rewrite < H1 in ⊢ (? ? ? (? ? %)). + rewrite < plus_n_Sm. + apply eq_f. + apply div_mod. + assumption ] - |assumption ] qed. @@ -370,6 +383,7 @@ qed. variant inj_times_l1:\forall n. O < n \to \forall p,q:nat.p*n = q*n \to p=q \def lt_O_to_injective_times_l. + (* n_divides computes the pair (div,mod) *) (* p is just an upper bound, acc is an accumulator *)