]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/arith/nat_plus.ma
f1dffc51db7350cba1caaa9c66113607bd0ae695
[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 (non-negative 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) (n1) (n2):
46       f^n2 โˆ˜ f^n1 โ‰ f^{A}(n1+n2).
47 #A #f #n1 #n2 @(nat_ind_succ โ€ฆ n2) -n2 //
48 #n2 #IH <nplus_succ_dx
49 @exteq_repl
50 /3 width=5 by compose_repl_fwd_sn, compose_repl_fwd_dx/
51 qed.
52
53 (* Advanced constructions (semigroup properties) ****************************)
54
55 (*** plus_S1 *)
56 lemma nplus_succ_sn (m) (n): โ†‘(m+n) = โ†‘m + n.
57 #m #n @(niter_appl โ€ฆ nsucc)
58 qed.
59
60 (*** plus_O_n *)
61 lemma nplus_zero_sn (m): m = ๐ŸŽ + m.
62 #m @(nat_ind_succ โ€ฆ m) -m //
63 qed.
64
65 (*** commutative_plus *)
66 lemma nplus_comm: commutative โ€ฆ nplus.
67 #m @(nat_ind_succ โ€ฆ m) -m //
68 qed-. (* * gets in the way with auto *)
69
70 (*** associative_plus *)
71 lemma nplus_assoc: associative โ€ฆ nplus.
72 #m #n #o @(nat_ind_succ โ€ฆ o) -o //
73 #o #IH <nplus_succ_dx <nplus_succ_dx <nplus_succ_dx <IH -IH //
74 qed.
75
76 (* Helper constructions *****************************************************)
77
78 (*** plus_SO_sn *)
79 lemma nplus_one_sn (n): โ†‘n = ๐Ÿ + n.
80 #n <nplus_comm // qed.
81
82 lemma nplus_succ_shift (m) (n): โ†‘m + n = m + โ†‘n.
83 // qed.
84
85 (*** assoc_plus1 *)
86 lemma nplus_plus_comm_12 (o) (m) (n): m + n + o = n + (m + o).
87 #o #m #n <nplus_comm in โŠข (??(?%?)?); // qed.
88
89 (*** plus_plus_comm_23 *)
90 lemma nplus_plus_comm_23 (o) (m) (n): o + m + n = o + n + m.
91 #o #m #n >nplus_assoc >nplus_assoc <nplus_comm in โŠข (??(??%)?); //
92 qed.
93
94 (* Basic inversions *********************************************************)
95
96 (*** zero_eq_plus *)
97 lemma eq_inv_zero_nplus (m) (n): ๐ŸŽ = m + n โ†’ โˆงโˆง ๐ŸŽ = m & ๐ŸŽ = n.
98 #m #n @(nat_ind_succ โ€ฆ n) -n
99 [ /2 width=1 by conj/
100 | #n #_ <nplus_succ_dx #H
101   elim (eq_inv_zero_nsucc โ€ฆ H)
102 ]
103 qed-.
104
105 (*** plus_inv_O3 *)
106 lemma eq_inv_nplus_zero (m) (n):
107       m + n = ๐ŸŽ โ†’ โˆงโˆง ๐ŸŽ = m & ๐ŸŽ = n.
108 /2 width=1 by eq_inv_zero_nplus/ qed-.
109
110 (*** injective_plus_l *)
111 lemma eq_inv_nplus_bi_dx (o) (m) (n): m + o = n + o โ†’ m = n.
112 #o @(nat_ind_succ โ€ฆ o) -o /3 width=1 by eq_inv_nsucc_bi/
113 qed-.
114
115 (*** injective_plus_r *)
116 lemma eq_inv_nplus_bi_sn (o) (m) (n): o + m = o + n โ†’ m = n.
117 #o #m #n <nplus_comm <nplus_comm in โŠข (???%โ†’?);
118 /2 width=2 by eq_inv_nplus_bi_dx/
119 qed-.
120
121 (*** plus_xSy_x_false *)
122 lemma succ_nplus_refl_sn (m) (n): m = โ†‘(m + n) โ†’ โŠฅ.
123 #m @(nat_ind_succ โ€ฆ m) -m
124 [ /2 width=2 by eq_inv_zero_nsucc/
125 | #m #IH #n #H
126   @(IH n) /2 width=1 by eq_inv_nsucc_bi/
127 ]
128 qed-.
129
130 (*** discr_plus_xy_y *)
131 lemma nplus_refl_dx (m) (n): n = m + n โ†’ ๐ŸŽ = m.
132 #m #n @(nat_ind_succ โ€ฆ n) -n //
133 #n #IH /3 width=1 by eq_inv_nsucc_bi/
134 qed-.
135
136 (*** discr_plus_x_xy *)
137 lemma nplus_refl_sn (m) (n): m = m + n โ†’ ๐ŸŽ = n.
138 #m #n <nplus_comm
139 /2 width=2 by nplus_refl_dx/
140 qed-.
141
142 (* Advanced eliminations ****************************************************)
143
144 (*** nat_ind_plus *)
145 lemma nat_ind_plus (Q:predicate โ€ฆ):
146       Q (๐ŸŽ) โ†’ (โˆ€n. Q n โ†’ Q (๐Ÿ+n)) โ†’ โˆ€n. Q n.
147 #Q #IH1 #IH2 #n @(nat_ind_succ โ€ฆ n) -n /2 width=1 by/
148 qed-.