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