]> matita.cs.unibo.it Git - helm.git/blob - matita/library/nat/le_arith.ma
6ad389346a8b9e2347493f1b0b3299866feb7869
[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   ]
27 qed.
28
29 theorem le_plus_r: \forall p,n,m:nat. n \le m \to p + n \le p + m
30 \def monotonic_le_plus_r.
31
32 theorem monotonic_le_plus_l: 
33 \forall m:nat.monotonic nat le (\lambda n.n + m).
34 simplify.intros.
35 rewrite < sym_plus.rewrite < (sym_plus m).
36 apply le_plus_r.assumption.
37 qed.
38
39 theorem le_plus_l: \forall p,n,m:nat. n \le m \to n + p \le m + p
40 \def monotonic_le_plus_l.
41
42 theorem le_plus: \forall n1,n2,m1,m2:nat. n1 \le n2  \to m1 \le m2 
43 \to n1 + m1 \le n2 + m2.
44 intros.
45 (**
46 auto.
47 *)
48 apply (transitive_le (plus n1 m1) (plus n1 m2) (plus n2 m2) ? ?);
49   [apply (monotonic_le_plus_r n1 m1 m2 ?).
50    apply (H1).
51   |apply (monotonic_le_plus_l m2 n1 n2 ?).
52    apply (H).
53   ]
54 (* end auto($Revision$) proof: TIME=0.61 SIZE=100 DEPTH=100 *)
55 (*
56 apply (trans_le ? (n2 + m1)).
57 apply le_plus_l.assumption.
58 apply le_plus_r.assumption.
59 *)
60 qed.
61
62 theorem le_plus_n :\forall n,m:nat. m \le n + m.
63 intros.change with (O+m \le n+m).
64 apply le_plus_l.apply le_O_n.
65 qed.
66
67 theorem le_plus_n_r :\forall n,m:nat. m \le m + n.
68 intros.rewrite > sym_plus.
69 apply le_plus_n.
70 qed.
71
72 theorem eq_plus_to_le: \forall n,m,p:nat.n=m+p \to m \le n.
73 intros.rewrite > H.
74 rewrite < sym_plus.
75 apply le_plus_n.
76 qed.
77
78 theorem le_plus_to_le: 
79 \forall a,n,m. a + n \le a + m \to n \le m.
80 intro.
81 elim a
82   [assumption
83   |apply H.
84    apply le_S_S_to_le.assumption
85   ]
86 qed.
87
88 (* times *)
89 theorem monotonic_le_times_r: 
90 \forall n:nat.monotonic nat le (\lambda m. n * m).
91 simplify.intros.elim n.
92 simplify.apply le_O_n.
93 simplify.apply le_plus.
94 assumption.
95 assumption.
96 qed.
97
98 theorem le_times_r: \forall p,n,m:nat. n \le m \to p*n \le p*m
99 \def monotonic_le_times_r.
100
101 theorem monotonic_le_times_l: 
102 \forall m:nat.monotonic nat le (\lambda n.n*m).
103 simplify.intros.
104 rewrite < sym_times.rewrite < (sym_times m).
105 apply le_times_r.assumption.
106 qed.
107
108 theorem le_times_l: \forall p,n,m:nat. n \le m \to n*p \le m*p
109 \def monotonic_le_times_l.
110
111 theorem le_times: \forall n1,n2,m1,m2:nat. n1 \le n2  \to m1 \le m2 
112 \to n1*m1 \le n2*m2.
113 intros.
114 apply (trans_le ? (n2*m1)).
115 apply le_times_l.assumption.
116 apply le_times_r.assumption.
117 qed.
118
119 theorem le_times_n: \forall n,m:nat.(S O) \le n \to m \le n*m.
120 intros.elim H.simplify.
121 elim (plus_n_O ?).apply le_n.
122 simplify.rewrite < sym_plus.apply le_plus_n.
123 qed.
124
125 theorem le_times_to_le: 
126 \forall a,n,m. S O \le a \to a * n \le a * m \to n \le m.
127 intro.
128 apply nat_elim2;intros
129   [apply le_O_n
130   |apply False_ind.
131    rewrite < times_n_O in H1.
132    generalize in match H1.
133    apply (lt_O_n_elim ? H).
134    intros.
135    simplify in H2.
136    apply (le_to_not_lt ? ? H2).
137    apply lt_O_S
138   |apply le_S_S.
139    apply H
140     [assumption
141     |rewrite < times_n_Sm in H2.
142      rewrite < times_n_Sm in H2.
143      apply (le_plus_to_le a).
144      assumption
145     ]
146   ]
147 qed.
148
149 (*0 and times *)
150 theorem O_lt_const_to_le_times_const:  \forall a,c:nat.
151 O \lt c \to a \le a*c.
152 intros.
153 rewrite > (times_n_SO a) in \vdash (? % ?).
154 apply le_times
155 [ apply le_n
156 | assumption
157 ]
158 qed.