]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/arith/pnat.ma
propagating the arithmetics library, partial commit
[helm.git] / matita / matita / contribs / lambdadelta / ground / arith / pnat.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/notation/functions/one_0.ma".
16 include "ground/notation/functions/uparrow_1.ma".
17 include "ground/lib/relations.ma".
18
19 (* POSITIVE INTEGERS ********************************************************)
20
21 inductive pnat: Type[0] ≝
22 | punit: pnat
23 | psucc: pnat → pnat
24 .
25
26 interpretation
27   "unit (positive integers)"
28   'One = (punit).
29
30 interpretation
31   "successor (positive integers)"
32   'UpArrow p = (psucc p).
33
34 (* Basic inversions *********************************************************)
35
36 (* Note: destruct *)
37 lemma eq_inv_psucc_bi: injective … psucc.
38 #p #q #H destruct //
39 qed.
40
41 lemma psucc_inv_refl (p): p = ↑p → ⊥.
42 #p elim p -p
43 [ #H destruct
44 | #p #IH #H /3 width=1 by eq_inv_psucc_bi/
45 ]
46 qed-.
47
48 (* Basic constructions ******************************************************)
49
50 lemma eq_pnat_dec (p1,p2:pnat): Decidable (p1 = p2).
51 #p1 elim p1 -p1 [| #p1 #IH ] * [2,4: #p2 ]
52 [1,4: @or_intror #H destruct
53 | elim (IH p2) -IH #H destruct
54   /4 width=1 by eq_inv_psucc_bi, or_intror, or_introl/
55 | /2 width=1 by or_introl/
56 ]
57 qed-.
58
59 (* Basic eliminations *******************************************************)
60
61 lemma pnat_ind_2 (Q:relation2 …):
62       (∀q. Q (𝟏) q) →
63       (∀p. Q p (𝟏) → Q (↑p) (𝟏)) →
64       (∀p,q. Q p q → Q (↑p) (↑q)) →
65       ∀p,q. Q p q.
66 #Q #IH1 #IH2 #IH3 #p elim p -p [ // ]
67 #p #IH #q elim q -q /2 width=1 by/
68 qed-.