X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Flibrary%2Fnat%2Fdiv_and_mod.ma;h=cbab87206ee5457cf967e25505b3772ed9180b15;hb=e880d6eab5e1700f4a625ddcd7d0fa8f0cce2dcc;hp=0323b18fb17849949b5ce4a49e3b33476f14fcec;hpb=6db38e3d8e4083765f2fce40c7845c9827b9afd0;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 0323b18fb..cbab87206 100644 --- a/helm/software/matita/library/nat/div_and_mod.ma +++ b/helm/software/matita/library/nat/div_and_mod.ma @@ -12,12 +12,9 @@ (* *) (**************************************************************************) -set "baseuri" "cic:/matita/nat/div_and_mod". - include "datatypes/constructors.ma". include "nat/minus.ma". - let rec mod_aux p m n: nat \def match (leb m n) with [ true \Rightarrow m @@ -32,8 +29,7 @@ match m with [O \Rightarrow n | (S p) \Rightarrow mod_aux n n p]. -interpretation "natural remainder" 'module x y = - (cic:/matita/nat/div_and_mod/mod.con x y). +interpretation "natural remainder" 'module x y = (mod x y). let rec div_aux p m n : nat \def match (leb m n) with @@ -49,8 +45,7 @@ match m with [O \Rightarrow S n | (S p) \Rightarrow div_aux n n p]. -interpretation "natural divide" 'divide x y = - (cic:/matita/nat/div_and_mod/div.con x y). +interpretation "natural divide" 'divide x y = (div x y). theorem le_mod_aux_m_m: \forall p,n,m. n \leq p \to (mod_aux p n m) \leq m. @@ -152,11 +147,14 @@ apply le_plus_n. rewrite < sym_times. rewrite > distr_times_minus. rewrite > plus_minus. +lapply(plus_to_minus ??? H3); demodulate all. +(* rewrite > sym_times. rewrite < H5. rewrite < sym_times. apply plus_to_minus. apply H3. +*) apply le_times_r. apply lt_to_le. apply H6. @@ -200,8 +198,8 @@ qed. theorem div_mod_spec_times : \forall n,m:nat.div_mod_spec ((S n)*m) (S n) m O. intros.constructor 1. -unfold lt.apply le_S_S.apply le_O_n. -rewrite < plus_n_O.rewrite < sym_times.reflexivity. +unfold lt.apply le_S_S.apply le_O_n. demodulate. reflexivity. +(*rewrite < plus_n_O.rewrite < sym_times.reflexivity.*) qed. lemma div_plus_times: \forall m,q,r:nat. r < m \to (q*m+r)/ m = q. @@ -223,6 +221,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. @@ -247,8 +246,8 @@ theorem div_n_n: \forall n:nat. O < n \to n / n = S O. intros. apply (div_mod_spec_to_eq n n (n / n) (n \mod n) (S O) O). apply div_mod_spec_div_mod.assumption. -constructor 1.assumption. -rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity. +constructor 1.assumption. demodulate. reflexivity. (* +rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.*) qed. theorem eq_div_O: \forall n,m. n < m \to n / m = O. @@ -264,8 +263,8 @@ theorem mod_n_n: \forall n:nat. O < n \to n \mod n = O. intros. apply (div_mod_spec_to_eq2 n n (n / n) (n \mod n) (S O) O). apply div_mod_spec_div_mod.assumption. -constructor 1.assumption. -rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity. +constructor 1.assumption. demodulate. reflexivity.(* +rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.*) qed. theorem mod_S: \forall n,m:nat. O < m \to S (n \mod m) < m \to @@ -312,19 +311,6 @@ rewrite > (div_mod ? (S O)) in \vdash (? ? ? %) ] qed. -theorem le_div: \forall n,m. O < n \to m/n \le m. -intros. -rewrite > (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 - ] - |assumption - ] -qed. - 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)