]> matita.cs.unibo.it Git - helm.git/blob - matita/library/assembly/extra.ma
experimental branch with no set baseuri command and no developments
[helm.git] / 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
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 axiom divides_to_eq_mod_mod_mod: ∀a,n,m. n∣m → a \mod m \mod n = a \mod n.
27 axiom le_to_le_plus_to_le : ∀a,b,c,d.b\leq d\rarr a+b\leq c+d\rarr a\leq c.
28 axiom or_lt_le : ∀n,m. n < m ∨ m ≤ n.
29
30 inductive cartesian_product (A,B: Type) : Type ≝
31  couple: ∀a:A.∀b:B. cartesian_product A B.
32
33 lemma le_to_lt: ∀n,m. n ≤ m → n < S m.
34  intros;
35  autobatch.
36 qed.
37
38 alias num (instance 0) = "natural number".
39 definition nat_of_bool ≝
40  λb. match b with [ true ⇒ 1 | false ⇒ 0 ].
41
42 theorem lt_trans: ∀x,y,z. x < y → y < z → x < z.
43  unfold lt;
44  intros;
45  autobatch.
46 qed.
47
48 lemma leq_m_n_to_eq_div_n_m_S: ∀n,m:nat. 0 < m → m ≤ n → ∃z. n/m = S z.
49  intros;
50  unfold div;
51  apply (ex_intro ? ? (div_aux (pred n) (n-m) (pred m)));
52  cut (∃w.m = S w);
53   [ elim Hcut;
54     rewrite > H2;
55     rewrite > H2 in H1;
56     clear Hcut; clear H2; clear H; (*clear m;*)
57     simplify;
58     unfold in ⊢ (? ? % ?);
59     cut (∃z.n = S z);
60      [ elim Hcut; clear Hcut;
61        rewrite > H in H1;
62        rewrite > H; clear m;
63        change in ⊢ (? ? % ?)  with
64         (match leb (S a1) a with
65          [ true ⇒ O
66          | false ⇒ S (div_aux a1 ((S a1) - S a) a)]);
67        cut (S a1 ≰ a);
68         [ apply (leb_elim (S a1) a);
69            [ intro;
70              elim (Hcut H2)
71            | intro;
72              simplify;
73              reflexivity
74            ]
75         | intro;
76           autobatch
77         ]
78      | elim H1; autobatch
79      ]
80   | autobatch
81   ].
82 qed.
83
84 axiom daemon: False.