]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/assembly/extra.ma
70b43bb1e4371f342ec15e39b766f79b202d9d2a
[helm.git] / helm / software / matita / library / assembly / extra.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 set "baseuri" "cic:/matita/assembly/extra".
16
17 include "nat/div_and_mod.ma".
18 include "nat/primes.ma".
19 include "list/list.ma".
20
21 axiom mod_plus: ∀a,b,m. (a + b) \mod m = (a \mod m + b \mod m) \mod m.
22 axiom mod_mod: ∀a,n,m. n∣m → a \mod n = a \mod n \mod m.
23 axiom eq_mod_times_n_m_m_O: ∀n,m. O < m → n * m \mod m = O.
24 axiom eq_mod_to_eq_plus_mod: ∀a,b,c,m. a \mod m = b \mod m → (a+c) \mod m = (b+c) \mod m.
25 axiom eq_mod_times_times_mod: ∀a,b,n,m. m = a*n → (a*b) \mod m = a * (b \mod n).
26
27 inductive cartesian_product (A,B: Type) : Type ≝
28  couple: ∀a:A.∀b:B. cartesian_product A B.
29
30 lemma le_to_lt: ∀n,m. n ≤ m → n < S m.
31  intros;
32  autobatch.
33 qed.
34
35 alias num (instance 0) = "natural number".
36 definition nat_of_bool ≝
37  λb. match b with [ true ⇒ 1 | false ⇒ 0 ].
38
39 theorem lt_trans: ∀x,y,z. x < y → y < z → x < z.
40  unfold lt;
41  intros;
42  autobatch.
43 qed.
44
45 lemma leq_m_n_to_eq_div_n_m_S: ∀n,m:nat. 0 < m → m ≤ n → ∃z. n/m = S z.
46  intros;
47  unfold div;
48  apply (ex_intro ? ? (div_aux (pred n) (n-m) (pred m)));
49  cut (∃w.m = S w);
50   [ elim Hcut;
51     rewrite > H2;
52     rewrite > H2 in H1;
53     clear Hcut; clear H2; clear H; (*clear m;*)
54     simplify;
55     unfold in ⊢ (? ? % ?);
56     cut (∃z.n = S z);
57      [ elim Hcut; clear Hcut;
58        rewrite > H in H1;
59        rewrite > H; clear m;
60        change in ⊢ (? ? % ?)  with
61         (match leb (S a1) a with
62          [ true ⇒ O
63          | false ⇒ S (div_aux a1 ((S a1) - S a) a)]);
64        cut (S a1 ≰ a);
65         [ apply (leb_elim (S a1) a);
66            [ intro;
67              elim (Hcut H2)
68            | intro;
69              simplify;
70              reflexivity
71            ]
72         | intro;
73           autobatch
74         ]
75      | elim H1; autobatch
76      ]
77   | autobatch
78   ].
79 qed.
80
81 axiom daemon: False.