]> matita.cs.unibo.it Git - helm.git/blob - matita/library/nat/le_arith.ma
A few extensions for the moebius inversion theorem
[helm.git] / matita / library / nat / le_arith.ma
1 (**************************************************************************)
2 (*       ___                                                                *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
8 (*      ||A||       E.Tassi, S.Zacchiroli                                 *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU Lesser General Public License Version 2.1         *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 set "baseuri" "cic:/matita/nat/le_arith".
16
17 include "nat/times.ma".
18 include "nat/orders.ma".
19
20 (* plus *)
21 theorem monotonic_le_plus_r: 
22 \forall n:nat.monotonic nat le (\lambda m.n + m).
23 simplify.intros.elim n.
24 simplify.assumption.
25 simplify.apply le_S_S.assumption.
26 qed.
27
28 theorem le_plus_r: \forall p,n,m:nat. n \le m \to p + n \le p + m
29 \def monotonic_le_plus_r.
30
31 theorem monotonic_le_plus_l: 
32 \forall m:nat.monotonic nat le (\lambda n.n + m).
33 simplify.intros.
34 rewrite < sym_plus.rewrite < (sym_plus m).
35 apply le_plus_r.assumption.
36 qed.
37
38 theorem le_plus_l: \forall p,n,m:nat. n \le m \to n + p \le m + p
39 \def monotonic_le_plus_l.
40
41 theorem le_plus: \forall n1,n2,m1,m2:nat. n1 \le n2  \to m1 \le m2 
42 \to n1 + m1 \le n2 + m2.
43 intros.
44 apply (trans_le ? (n2 + m1)).
45 apply le_plus_l.assumption.
46 apply le_plus_r.assumption.
47 qed.
48
49 theorem le_plus_n :\forall n,m:nat. m \le n + m.
50 intros.change with (O+m \le n+m).
51 apply le_plus_l.apply le_O_n.
52 qed.
53
54 theorem le_plus_n_r :\forall n,m:nat. m \le m + n.
55 intros.rewrite > sym_plus.
56 apply le_plus_n.
57 qed.
58
59 theorem eq_plus_to_le: \forall n,m,p:nat.n=m+p \to m \le n.
60 intros.rewrite > H.
61 rewrite < sym_plus.
62 apply le_plus_n.
63 qed.
64
65 theorem le_plus_to_le: 
66 \forall a,n,m. a + n \le a + m \to n \le m.
67 intro.
68 elim a
69   [assumption
70   |apply H.
71    apply le_S_S_to_le.assumption
72   ]
73 qed.
74
75 (* times *)
76 theorem monotonic_le_times_r: 
77 \forall n:nat.monotonic nat le (\lambda m. n * m).
78 simplify.intros.elim n.
79 simplify.apply le_O_n.
80 simplify.apply le_plus.
81 assumption.
82 assumption.
83 qed.
84
85 theorem le_times_r: \forall p,n,m:nat. n \le m \to p*n \le p*m
86 \def monotonic_le_times_r.
87
88 theorem monotonic_le_times_l: 
89 \forall m:nat.monotonic nat le (\lambda n.n*m).
90 simplify.intros.
91 rewrite < sym_times.rewrite < (sym_times m).
92 apply le_times_r.assumption.
93 qed.
94
95 theorem le_times_l: \forall p,n,m:nat. n \le m \to n*p \le m*p
96 \def monotonic_le_times_l.
97
98 theorem le_times: \forall n1,n2,m1,m2:nat. n1 \le n2  \to m1 \le m2 
99 \to n1*m1 \le n2*m2.
100 intros.
101 apply (trans_le ? (n2*m1)).
102 apply le_times_l.assumption.
103 apply le_times_r.assumption.
104 qed.
105
106 theorem le_times_n: \forall n,m:nat.(S O) \le n \to m \le n*m.
107 intros.elim H.simplify.
108 elim (plus_n_O ?).apply le_n.
109 simplify.rewrite < sym_plus.apply le_plus_n.
110 qed.
111
112 theorem le_times_to_le: 
113 \forall a,n,m. S O \le a \to a * n \le a * m \to n \le m.
114 intro.
115 apply nat_elim2;intros
116   [apply le_O_n
117   |apply False_ind.
118    rewrite < times_n_O in H1.
119    generalize in match H1.
120    apply (lt_O_n_elim ? H).
121    intros.
122    simplify in H2.
123    apply (le_to_not_lt ? ? H2).
124    apply lt_O_S
125   |apply le_S_S.
126    apply H
127     [assumption
128     |rewrite < times_n_Sm in H2.
129      rewrite < times_n_Sm in H2.
130      apply (le_plus_to_le a).
131      assumption
132     ]
133   ]
134 qed.