]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/arith/nat_plus.ma
2df064a0189c3085ed0707a78532215d5e6bd79c
[helm.git] / matita / matita / contribs / lambdadelta / ground / arith / nat_plus.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 include "ground/arith/nat_succ_iter.ma".
16
17 (* ADDITION FOR NON-NEGATIVE INTEGERS ***************************************)
18
19 (*** plus *)
20 definition nplus: nat โ†’ nat โ†’ nat โ‰
21            ฮปm,n. nsucc^n m.
22
23 interpretation
24   "plus (positive integers)"
25   'plus m n = (nplus m n).
26
27 (* Basic constructions ******************************************************)
28
29 (*** plus_n_O *)
30 lemma nplus_zero_dx (m): m = m + ๐ŸŽ.
31 // qed.
32
33 (*** plus_SO_dx *)
34 lemma nplus_one_dx (n): โ†‘n = n + ๐Ÿ.
35 // qed.
36
37 (*** plus_n_Sm *)
38 lemma nplus_succ_dx (m) (n): โ†‘(m+n) = m + โ†‘n.
39 #m #n @(niter_succ โ€ฆ nsucc)
40 qed.
41
42 (* Constructions with niter *************************************************)
43
44 (*** iter_plus *)
45 lemma niter_plus (A) (f) (a) (n1) (n2):
46       f^n1 (f^n2 a) = f^{A}(n1+n2) a.
47 #A #f #a #n1 #n2 @(nat_ind_succ โ€ฆ n2) -n2 //
48 #n2 #IH <nplus_succ_dx <niter_succ <niter_succ <niter_appl //
49 qed.
50
51 (* Advanved constructions (semigroup properties) ****************************)
52
53 (*** plus_S1 *)
54 lemma nplus_succ_sn (m) (n): โ†‘(m+n) = โ†‘m + n.
55 #m #n @(niter_appl โ€ฆ nsucc)
56 qed.
57
58 (*** plus_O_n.con *)
59 lemma nplus_zero_sn (m): m = ๐ŸŽ + m.
60 #m @(nat_ind_succ โ€ฆ m) -m //
61 qed.
62
63 (*** commutative_plus *)
64 lemma nplus_comm: commutative โ€ฆ nplus.
65 #m @(nat_ind_succ โ€ฆ m) -m //
66 qed-. (**) (* gets in the way with auto *)
67
68 (*** associative_plus *)
69 lemma nplus_assoc: associative โ€ฆ nplus.
70 #m #n #o @(nat_ind_succ โ€ฆ o) -o //
71 #o #IH <nplus_succ_dx <nplus_succ_dx <nplus_succ_dx <IH -IH //
72 qed.
73
74 (* Helper constructions *****************************************************)
75
76 (*** plus_SO_sn *)
77 lemma nplus_one_sn (n): โ†‘n = ๐Ÿ + n.
78 #n <nplus_comm // qed.
79
80 lemma nplus_succ_shift (m) (n): โ†‘m + n = m + โ†‘n.
81 // qed-.
82
83 (*** assoc_plus1 *)
84 lemma nplus_plus_comm_12 (o) (m) (n): m + n + o = n + (m + o).
85 #o #m #n <nplus_comm in โŠข (??(?%?)?); // qed.
86
87 (*** plus_plus_comm_23 *)
88 lemma nplus_plus_comm_23 (o) (m) (n): o + m + n = o + n + m.
89 #o #m #n >nplus_assoc >nplus_assoc <nplus_comm in โŠข (??(??%)?); //
90 qed-.
91
92 (* Basic inversions *********************************************************)
93
94 (*** plus_inv_O3 zero_eq_plus *) 
95 lemma eq_inv_zero_nplus (m) (n): ๐ŸŽ = m + n โ†’ โˆงโˆง ๐ŸŽ = m & ๐ŸŽ = n.
96 #m #n @(nat_ind_succ โ€ฆ n) -n
97 [ /2 width=1 by conj/
98 | #n #_ <nplus_succ_dx #H
99   elim (eq_inv_zero_nsucc โ€ฆ H)
100 ]
101 qed-.
102
103 (*** injective_plus_l *)
104 lemma eq_inv_nplus_bi_dx (o) (m) (n): m + o = n + o โ†’ m = n.
105 #o @(nat_ind_succ โ€ฆ o) -o /3 width=1 by eq_inv_nsucc_bi/
106 qed-.
107
108 (*** injective_plus_r *)
109 lemma eq_inv_nplus_bi_sn (o) (m) (n): o + m = o + n โ†’ m = n.
110 #o #m #n <nplus_comm <nplus_comm in โŠข (???%โ†’?);
111 /2 width=2 by eq_inv_nplus_bi_dx/
112 qed-.
113
114 (*** plus_xSy_x_false *)
115 lemma succ_nplus_refl_sn (m) (n): m = โ†‘(m + n) โ†’ โŠฅ.
116 #m @(nat_ind_succ โ€ฆ m) -m
117 [ /2 width=2 by eq_inv_zero_nsucc/
118 | #m #IH #n #H
119   @(IH n) /2 width=1 by eq_inv_nsucc_bi/
120 ]
121 qed-.
122
123 (*** discr_plus_xy_y *)
124 lemma nplus_refl_dx (m) (n): n = m + n โ†’ ๐ŸŽ = m.
125 #m #n @(nat_ind_succ โ€ฆ n) -n //
126 #n #IH /3 width=1 by eq_inv_nsucc_bi/
127 qed-.
128
129 (*** discr_plus_x_xy *)
130 lemma nplus_refl_sn (m) (n): m = m + n โ†’ ๐ŸŽ = n.
131 #m #n <nplus_comm
132 /2 width=2 by nplus_refl_dx/
133 qed-.
134
135 (* Advanced eliminations ****************************************************)
136
137 (*** nat_ind_plus *)
138 lemma nat_ind_plus (Q:predicate โ€ฆ):
139       Q (๐ŸŽ) โ†’ (โˆ€n. Q n โ†’ Q (๐Ÿ+n)) โ†’ โˆ€n. Q n.
140 #Q #IH1 #IH2 #n @(nat_ind_succ โ€ฆ n) -n /2 width=1 by/
141 qed-.