1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/nat/propr_div_mod_lt_le_totient1_aux/".
17 include "nat/iteration2.ma".
19 (*this part of the library contains some properties useful to prove
20 the main theorem in totient1.ma, and some new properties about gcd
21 (see gcd_properties1.ma).
22 These theorems are saved separately from the other part of the library
23 in order to avoid to create circular dependences in it.
26 (* some basic properties of and - or*)
27 theorem andb_sym: \forall A,B:bool.
28 (A \land B) = (B \land A).
36 theorem andb_assoc: \forall A,B,C:bool.
37 (A \land (B \land C)) = ((A \land B) \land C).
46 theorem orb_sym: \forall A,B:bool.
47 (A \lor B) = (B \lor A).
55 theorem andb_t_t_t: \forall A,B,C:bool.
56 A = true \to B = true \to C = true \to (A \land (B \land C)) = true.
64 (*properties about relational operators*)
66 theorem Sa_le_b_to_O_lt_b: \forall a,b:nat.
67 (S a) \le b \to O \lt b.
73 theorem n_gt_Uno_to_O_lt_pred_n: \forall n:nat.
74 (S O) \lt n \to O \lt (pred n).
76 apply (Sa_le_b_to_O_lt_b (pred (S O)) (pred n) ?).
77 apply (lt_pred (S O) n ? ?);
84 theorem NdivM_times_M_to_N: \forall n,m:nat.
85 O \lt m \to m \divides n \to (n / m) * m = n.
93 | apply divides_to_mod_O;
98 theorem lt_to_divides_to_div_le: \forall a,c:nat.
99 O \lt c \to c \divides a \to a/c \le a.
101 apply (le_times_to_le c (a/c) a)
103 | rewrite > (sym_times c (a/c)).
104 rewrite > (NdivM_times_M_to_N a c) in \vdash (? % ?)
105 [ apply (le_times_n c a ?).
114 theorem lt_O_a_lt_O_b_a_divides_b_to_lt_O_aDIVb:
116 O \lt a \to O \lt b \to a \divides b \to O \lt (b/a).
120 rewrite > (sym_times a n2).
121 rewrite > (div_times_ltO n2 a)
122 [ apply (divides_to_lt_O n2 b)
124 | apply (witness n2 b a).
132 (* some properties of div operator between natural numbers *)
134 theorem separazioneFattoriSuDivisione: \forall a,b,c:nat.
135 O \lt b \to c \divides b \to a * (b /c) = (a*b)/c.
139 rewrite > (sym_times c n2).
141 [ rewrite > (div_times_ltO n2 c)
142 [ rewrite < assoc_times.
143 rewrite > (div_times_ltO (a *n2) c)
149 | apply (divides_to_lt_O c b);
155 theorem div_mod_minus:
156 \forall a,b:nat. O \lt b \to
157 (a /b)*b = a - (a \mod b).
159 rewrite > (div_mod a b) in \vdash (? ? ? (? % ?))
160 [ apply (minus_plus_m_m (times (div a b) b) (mod a b))
166 (* A corollary to the division theorem (between natural numbers).
168 * Forall a,b,c: Nat, b > O,
169 * a/b = c iff (b*c <= a && a < b*(c+1)
171 * two parts of the theorem are proved separately
172 * - (=>) th_div_interi_2
173 * - (<=) th_div_interi_1
176 theorem th_div_interi_2: \forall a,b,c:nat.
177 O \lt b \to a/b = c \to (b*c \le a \land a \lt b*(S c)).
182 rewrite > div_mod_minus
183 [ apply (le_minus_m a (a \mod b))
186 | rewrite < (times_n_Sm b c).
189 rewrite > (div_mod a b) in \vdash (? % ?)
190 [ rewrite > (sym_plus b ((a/b)*b)).
200 theorem th_div_interi_1: \forall a,c,b:nat.
201 O \lt b \to (b*c) \le a \to a \lt (b*(S c)) \to a/b = c.
203 apply (le_to_le_to_eq)
204 [ apply (leb_elim (a/b) c);intros
208 apply (lt_to_not_le (a \mod b) O)
209 [ apply (lt_plus_to_lt_l ((a/b)*b)).
213 [ apply (lt_to_le_to_lt ? (b*(S c)) ?)
215 | rewrite > (sym_times (a/b) b).
223 | apply not_le_to_lt.
227 | apply (leb_elim c (a/b));intros
231 apply (lt_to_not_le (a \mod b) b)
232 [ apply (lt_mod_m_m).
234 | apply (le_plus_to_le ((a/b)*b)).
235 rewrite < (div_mod a b)
236 [ apply (trans_le ? (b*c) ?)
237 [ rewrite > (sym_times (a/b) b).
238 rewrite > (times_n_SO b) in \vdash (? (? ? %) ?).
239 rewrite < distr_times_plus.
241 simplify in \vdash (? (? ? %) ?).
249 | apply not_le_to_lt.
257 theorem times_numerator_denominator_aux: \forall a,b,c,d:nat.
258 O \lt c \to O \lt b \to d = (a/b) \to d= (a*c)/(b*c).
261 cut (b*d \le a \land a \lt b*(S d))
263 apply th_div_interi_1
264 [ rewrite > (S_pred b)
265 [ rewrite > (S_pred c)
266 [ apply (lt_O_times_S_S)
271 | rewrite > assoc_times.
272 rewrite > (sym_times c d).
273 rewrite < assoc_times.
274 rewrite > (sym_times (b*d) c).
275 rewrite > (sym_times a c).
276 apply (le_times_r c (b*d) a).
278 | rewrite > (sym_times a c).
279 rewrite > (assoc_times ).
280 rewrite > (sym_times c (S d)).
281 rewrite < (assoc_times).
282 rewrite > (sym_times (b*(S d)) c).
283 apply (lt_times_r1 c a (b*(S d)));
286 | apply (th_div_interi_2)
294 theorem times_numerator_denominator: \forall a,b,c:nat.
295 O \lt c \to O \lt b \to (a/b) = (a*c)/(b*c).
297 apply (times_numerator_denominator_aux a b c (a/b))
304 theorem times_mod: \forall a,b,c:nat.
305 O \lt c \to O \lt b \to ((a*c) \mod (b*c)) = c*(a\mod b).
307 apply (div_mod_spec_to_eq2 (a*c) (b*c) (a/b) ((a*c) \mod (b*c)) (a/b) (c*(a \mod b)))
308 [ apply div_mod_spec_intro
309 [ apply (lt_mod_m_m (a*c) (b*c)).
311 [ rewrite > (S_pred c)
312 [ apply lt_O_times_S_S
317 | rewrite > (times_numerator_denominator a b c)
318 [ apply (div_mod (a*c) (b*c)).
320 [ rewrite > (S_pred c)
321 [ apply (lt_O_times_S_S)
331 [ rewrite > (sym_times b c).
332 apply (lt_times_r1 c)
334 | apply (lt_mod_m_m).
337 | rewrite < (assoc_times (a/b) b c).
338 rewrite > (sym_times a c).
339 rewrite > (sym_times ((a/b)*b) c).
340 rewrite < (distr_times_plus c ? ?).