]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/library/Z/orders.ma
ocaml 3.09 transition
[helm.git] / helm / matita / library / Z / orders.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/Z/orders".
16
17 include "Z/z.ma".
18 include "nat/orders.ma".
19
20 definition Zle : Z \to Z \to Prop \def
21 \lambda x,y:Z.
22   match x with
23   [ OZ \Rightarrow 
24     match y with 
25     [ OZ \Rightarrow True
26     | (pos m) \Rightarrow True
27     | (neg m) \Rightarrow False ]
28   | (pos n) \Rightarrow 
29     match y with 
30     [ OZ \Rightarrow False
31     | (pos m) \Rightarrow n \leq m
32     | (neg m) \Rightarrow False ]
33   | (neg n) \Rightarrow 
34     match y with 
35     [ OZ \Rightarrow True
36     | (pos m) \Rightarrow True
37     | (neg m) \Rightarrow m \leq n ]].
38
39 (*CSC: the URI must disappear: there is a bug now *)
40 interpretation "integer 'less or equal to'" 'leq x y = (cic:/matita/Z/orders/Zle.con x y).
41 (*CSC: the URI must disappear: there is a bug now *)
42 interpretation "integer 'neither less nor equal to'" 'nleq x y =
43   (cic:/matita/logic/connectives/Not.con (cic:/matita/Z/orders/Zle.con x y)).
44
45 definition Zlt : Z \to Z \to Prop \def
46 \lambda x,y:Z.
47   match x with
48   [ OZ \Rightarrow 
49     match y with 
50     [ OZ \Rightarrow False
51     | (pos m) \Rightarrow True
52     | (neg m) \Rightarrow False ]
53   | (pos n) \Rightarrow 
54     match y with 
55     [ OZ \Rightarrow False
56     | (pos m) \Rightarrow n<m
57     | (neg m) \Rightarrow False ]
58   | (neg n) \Rightarrow 
59     match y with 
60     [ OZ \Rightarrow True
61     | (pos m) \Rightarrow True
62     | (neg m) \Rightarrow m<n ]].
63     
64 (*CSC: the URI must disappear: there is a bug now *)
65 interpretation "integer 'less than'" 'lt x y = (cic:/matita/Z/orders/Zlt.con x y).
66 (*CSC: the URI must disappear: there is a bug now *)
67 interpretation "integer 'not less than'" 'nless x y =
68   (cic:/matita/logic/connectives/Not.con (cic:/matita/Z/orders/Zlt.con x y)).
69
70 theorem irreflexive_Zlt: irreflexive Z Zlt.
71 change with (\forall x:Z. x < x \to False).
72 intro.elim x.exact H.
73 cut (neg n < neg n \to False).
74 apply Hcut.apply H.simplify.unfold lt.apply not_le_Sn_n.
75 cut (pos n < pos n \to False).
76 apply Hcut.apply H.simplify.unfold lt.apply not_le_Sn_n.
77 qed.
78
79 theorem irrefl_Zlt: irreflexive Z Zlt
80 \def irreflexive_Zlt.
81
82 theorem Zlt_neg_neg_to_lt: 
83 \forall n,m:nat. neg n < neg m \to m < n.
84 intros.apply H.
85 qed.
86
87 theorem lt_to_Zlt_neg_neg: \forall n,m:nat.m < n \to neg n < neg m. 
88 intros.
89 simplify.apply H.
90 qed.
91
92 theorem Zlt_pos_pos_to_lt: 
93 \forall n,m:nat. pos n < pos m \to n < m.
94 intros.apply H.
95 qed.
96
97 theorem lt_to_Zlt_pos_pos: \forall n,m:nat.n < m \to pos n < pos m. 
98 intros.
99 simplify.apply H.
100 qed.
101
102 theorem Zlt_to_Zle: \forall x,y:Z. x < y \to Zsucc x \leq y.
103 intros 2.
104 elim x.
105 (* goal: x=OZ *)
106   cut (OZ < y \to Zsucc OZ \leq y).
107     apply Hcut. assumption.
108     simplify.elim y. 
109       simplify.exact H1.
110       simplify.apply le_O_n.
111       simplify.exact H1.
112 (* goal: x=pos *)      
113   exact H.
114 (* goal: x=neg *)      
115   cut (neg n < y \to Zsucc (neg n) \leq y).
116     apply Hcut. assumption.
117     elim n.
118       cut (neg O < y \to Zsucc (neg O) \leq y).
119         apply Hcut. assumption.
120         simplify.elim y.
121           simplify.exact I.
122           simplify.exact I.
123           simplify.apply (not_le_Sn_O n1 H2).
124       cut (neg (S n1) < y \to (Zsucc (neg (S n1))) \leq y).
125         apply Hcut. assumption.simplify.
126         elim y.
127           simplify.exact I.
128           simplify.exact I.
129           simplify.apply (le_S_S_to_le n2 n1 H3).
130 qed.