]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/dama/excedence.ma
...
[helm.git] / helm / software / matita / dama / excedence.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 set "baseuri" "cic:/matita/excedence/".
16
17 include "higher_order_defs/relations.ma".
18 include "nat/plus.ma".
19 include "constructive_connectives.ma".
20 include "constructive_higher_order_relations.ma".
21
22 record excedence : Type ≝ {
23   exc_carr:> Type;
24   exc_relation: exc_carr → exc_carr → Type;
25   exc_coreflexive: coreflexive ? exc_relation;
26   exc_cotransitive: cotransitive ? exc_relation 
27 }.
28
29 interpretation "excedence" 'nleq a b =
30  (cic:/matita/excedence/exc_relation.con _ a b). 
31
32 definition le ≝ λE:excedence.λa,b:E. ¬ (a ≰ b).
33
34 interpretation "ordered sets less or equal than" 'leq a b = 
35  (cic:/matita/excedence/le.con _ a b).
36
37 lemma le_reflexive: ∀E.reflexive ? (le E).
38 intros (E); unfold; cases E; simplify; intros (x); apply (H x);
39 qed.
40
41 lemma le_transitive: ∀E.transitive ? (le E).
42 intros (E); unfold; cases E; simplify; unfold Not; intros (x y z Rxy Ryz H2); 
43 cases (c x z y H2) (H4 H5); clear H2; [exact (Rxy H4)|exact (Ryz H5)] 
44 qed.
45
46 record apartness : Type ≝ {
47   ap_carr:> Type;
48   ap_apart: ap_carr → ap_carr → Type;
49   ap_coreflexive: coreflexive ? ap_apart;
50   ap_symmetric: symmetric ? ap_apart;
51   ap_cotransitive: cotransitive ? ap_apart
52 }.
53
54 notation "a break # b" non associative with precedence 50 for @{ 'apart $a $b}.
55 interpretation "axiomatic apartness" 'apart x y = 
56   (cic:/matita/excedence/ap_apart.con _ x y).
57
58 definition strong_ext ≝ λA:apartness.λop:A→A.∀x,y. op x # op y → x # y.
59
60 definition apart ≝ λE:excedence.λa,b:E. a ≰ b ∨ b ≰ a.
61
62 definition apart_of_excedence: excedence → apartness.
63 intros (E); apply (mk_apartness E (apart E));  
64 [1: unfold; cases E; simplify; clear E; intros (x); unfold;
65     intros (H1); apply (H x); cases H1; assumption;
66 |2: unfold; intros(x y H); cases H; clear H; [right|left] assumption;
67 |3: intros (E); unfold; cases E (T f _ cTf); simplify; intros (x y z Axy);
68     cases Axy (H H); lapply (cTf ? ? z H) as H1; cases H1; clear Axy H1;
69     [left; left|right; left|right; right|left; right] assumption]
70 qed.
71
72 coercion cic:/matita/excedence/apart_of_excedence.con.
73
74 definition eq ≝ λA:apartness.λa,b:A. ¬ (a # b).
75
76 notation "a break ≈ b" non associative with precedence 50 for @{ 'napart $a $b}.    
77 interpretation "alikeness" 'napart a b =
78   (cic:/matita/excedence/eq.con _ a b). 
79
80 lemma eq_reflexive:∀E. reflexive ? (eq E).
81 intros (E); unfold; intros (x); apply ap_coreflexive; 
82 qed.
83
84 lemma eq_sym_:∀E.symmetric ? (eq E).
85 intros (E); unfold; intros (x y Exy); unfold; unfold; intros (Ayx); apply Exy;
86 apply ap_symmetric; assumption; 
87 qed.
88
89 lemma eq_sym:∀E:apartness.∀x,y:E.x ≈ y → y ≈ x := eq_sym_.
90
91 coercion cic:/matita/excedence/eq_sym.con.
92
93 lemma eq_trans_: ∀E.transitive ? (eq E).
94 (* bug. intros k deve fare whd quanto basta *)
95 intros 6 (E x y z Exy Eyz); intro Axy; cases (ap_cotransitive ???y Axy); 
96 [apply Exy|apply Eyz] assumption.
97 qed.
98
99 lemma eq_trans:∀E:apartness.∀x,y,z:E.x ≈ y → y ≈ z → x ≈ z ≝ eq_trans_.
100
101 (* BUG: vedere se ricapita *)
102 alias id "antisymmetric" = "cic:/matita/constructive_higher_order_relations/antisymmetric.con".
103 lemma le_antisymmetric: ∀E.antisymmetric ? (le E) (eq ?).
104 intros 5 (E x y Lxy Lyx); intro H;
105 cases H; [apply Lxy;|apply Lyx] assumption;
106 qed.
107
108 definition lt ≝ λE:excedence.λa,b:E. a ≤ b ∧ a # b.
109
110 interpretation "ordered sets less than" 'lt a b =
111  (cic:/matita/excedence/lt.con _ a b).
112
113 lemma lt_coreflexive: ∀E.coreflexive ? (lt E).
114 intros 2 (E x); intro H; cases H (_ ABS); 
115 apply (ap_coreflexive ? x ABS);
116 qed.
117  
118 lemma lt_transitive: ∀E.transitive ? (lt E).
119 intros (E); unfold; intros (x y z H1 H2); cases H1 (Lxy Axy); cases H2 (Lyz Ayz); 
120 split; [apply (le_transitive ???? Lxy Lyz)] clear H1 H2;
121 cases Axy (H1 H1); cases Ayz (H2 H2); [1:cases (Lxy H1)|3:cases (Lyz H2)]
122 clear Axy Ayz;lapply (exc_cotransitive E) as c; unfold cotransitive in c;
123 lapply (exc_coreflexive E) as r; unfold coreflexive in r;
124 [1: lapply (c ?? y H1) as H3; cases H3 (H4 H4); [cases (Lxy H4)|cases (r ? H4)]
125 |2: lapply (c ?? x H2) as H3; cases H3 (H4 H4); [right; assumption|cases (Lxy H4)]]
126 qed.
127
128 theorem lt_to_excede: ∀E:excedence.∀a,b:E. (a < b) → (b ≰ a).
129 intros (E a b Lab); cases Lab (LEab Aab);
130 cases Aab (H H); [cases (LEab H)] fold normalize (b ≰ a); assumption; (* BUG *)  
131 qed.
132
133 lemma unfold_apart: ∀E:excedence. ∀x,y:E. x ≰ y ∨ y ≰ x → x # y.
134 intros; assumption;
135 qed.
136
137 lemma le_rewl: ∀E:excedence.∀z,y,x:E. x ≈ y → x ≤ z → y ≤ z.
138 intros (E z y x Exy Lxz); apply (le_transitive ???? ? Lxz);
139 intro Xyz; apply Exy; apply unfold_apart; right; assumption;
140 qed.
141
142 lemma le_rewr: ∀E:excedence.∀z,y,x:E. x ≈ y → z ≤ x → z ≤ y.
143 intros (E z y x Exy Lxz); apply (le_transitive ???? Lxz);
144 intro Xyz; apply Exy; apply unfold_apart; left; assumption;
145 qed.
146  
147 lemma ap_rewl: ∀A:apartness.∀x,z,y:A. x ≈ y → y # z → x # z.
148 intros (A x z y Exy Ayz); cases (ap_cotransitive ???x Ayz); [2:assumption]
149 cases (Exy (ap_symmetric ??? a));
150 qed.
151   
152 lemma ap_rewr: ∀A:apartness.∀x,z,y:A. x ≈ y → z # y → z # x.
153 intros (A x z y Exy Azy); apply ap_symmetric; apply (ap_rewl ???? Exy);
154 apply ap_symmetric; assumption;
155 qed.
156
157 lemma exc_rewl: ∀A:excedence.∀x,z,y:A. x ≈ y → y ≰ z → x ≰ z.
158 intros (A x z y Exy Ayz); elim (exc_cotransitive ???x Ayz); [2:assumption]
159 cases Exy; right; assumption;
160 qed.
161   
162 lemma exc_rewr: ∀A:excedence.∀x,z,y:A. x ≈ y → z ≰ y → z ≰ x.
163 intros (A x z y Exy Azy); elim (exc_cotransitive ???x Azy); [assumption]
164 elim (Exy); left; assumption;
165 qed.
166
167 lemma lt_rewr: ∀A:excedence.∀x,z,y:A. x ≈ y → z < y → z < x.
168 intros (A x y z E H); split; elim H; 
169 [apply (le_rewr ???? (eq_sym ??? E));|apply (ap_rewr ???? E)] assumption;
170 qed.
171
172 lemma lt_rewl: ∀A:excedence.∀x,z,y:A. x ≈ y → y < z → x < z.
173 intros (A x y z E H); split; elim H; 
174 [apply (le_rewl ???? (eq_sym ??? E));| apply (ap_rewl ???? E);] assumption;
175 qed.
176
177 lemma lt_le_transitive: ∀A:excedence.∀x,y,z:A.x < y → y ≤ z → x < z.
178 intros (A x y z LT LE); cases LT (LEx APx); split; [apply (le_transitive ???? LEx LE)]
179 whd in LE LEx APx; cases APx (EXx EXx); [cases (LEx EXx)]
180 cases (exc_cotransitive ??? z EXx) (EXz EXz); [cases (LE EXz)]
181 right; assumption;
182 qed.
183     
184 lemma le_le_eq: ∀E:excedence.∀a,b:E. a ≤ b → b ≤ a → a ≈ b.
185 intros (E x y L1 L2); intro H; cases H; [apply L1|apply L2] assumption;
186 qed.