1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 set "baseuri" "cic:/matita/excedence/".
17 include "higher_order_defs/relations.ma".
18 include "nat/plus.ma".
19 include "constructive_connectives.ma".
20 include "constructive_higher_order_relations.ma".
22 record excedence : Type ≝ {
24 exc_relation: exc_carr → exc_carr → Type;
25 exc_coreflexive: coreflexive ? exc_relation;
26 exc_cotransitive: cotransitive ? exc_relation
29 interpretation "excedence" 'nleq a b =
30 (cic:/matita/excedence/exc_relation.con _ a b).
32 definition le ≝ λE:excedence.λa,b:E. ¬ (a ≰ b).
34 interpretation "ordered sets less or equal than" 'leq a b =
35 (cic:/matita/excedence/le.con _ a b).
37 lemma le_reflexive: ∀E.reflexive ? (le E).
38 intros (E); unfold; cases E; simplify; intros (x); apply (H x);
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)]
46 record apartness : 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
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).
58 definition strong_ext ≝ λA:apartness.λop:A→A.∀x,y. op x # op y → x # y.
60 definition apart ≝ λE:excedence.λa,b:E. a ≰ b ∨ b ≰ a.
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]
72 coercion cic:/matita/excedence/apart_of_excedence.con.
74 definition eq ≝ λA:apartness.λa,b:A. ¬ (a # b).
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).
80 lemma eq_reflexive:∀E. reflexive ? (eq E).
81 intros (E); unfold; intros (x); apply ap_coreflexive;
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;
89 lemma eq_sym:∀E:apartness.∀x,y:E.x ≈ y → y ≈ x := eq_sym_.
91 coercion cic:/matita/excedence/eq_sym.con.
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.
99 lemma eq_trans:∀E:apartness.∀x,z,y:E.x ≈ y → y ≈ z → x ≈ z ≝
100 λE,x,y,z.eq_trans_ E x z y.
102 notation > "'Eq'≈" non associative with precedence 50 for
105 interpretation "eq_rew" 'eqrewrite =
106 (cic:/matita/excedence/eq_trans.con _ _ _).
108 (* BUG: vedere se ricapita *)
109 alias id "antisymmetric" = "cic:/matita/constructive_higher_order_relations/antisymmetric.con".
110 lemma le_antisymmetric: ∀E.antisymmetric ? (le E) (eq ?).
111 intros 5 (E x y Lxy Lyx); intro H;
112 cases H; [apply Lxy;|apply Lyx] assumption;
115 definition lt ≝ λE:excedence.λa,b:E. a ≤ b ∧ a # b.
117 interpretation "ordered sets less than" 'lt a b =
118 (cic:/matita/excedence/lt.con _ a b).
120 lemma lt_coreflexive: ∀E.coreflexive ? (lt E).
121 intros 2 (E x); intro H; cases H (_ ABS);
122 apply (ap_coreflexive ? x ABS);
125 lemma lt_transitive: ∀E.transitive ? (lt E).
126 intros (E); unfold; intros (x y z H1 H2); cases H1 (Lxy Axy); cases H2 (Lyz Ayz);
127 split; [apply (le_transitive ???? Lxy Lyz)] clear H1 H2;
128 cases Axy (H1 H1); cases Ayz (H2 H2); [1:cases (Lxy H1)|3:cases (Lyz H2)]
129 clear Axy Ayz;lapply (exc_cotransitive E) as c; unfold cotransitive in c;
130 lapply (exc_coreflexive E) as r; unfold coreflexive in r;
131 [1: lapply (c ?? y H1) as H3; cases H3 (H4 H4); [cases (Lxy H4)|cases (r ? H4)]
132 |2: lapply (c ?? x H2) as H3; cases H3 (H4 H4); [right; assumption|cases (Lxy H4)]]
135 theorem lt_to_excede: ∀E:excedence.∀a,b:E. (a < b) → (b ≰ a).
136 intros (E a b Lab); cases Lab (LEab Aab);
137 cases Aab (H H); [cases (LEab H)] fold normalize (b ≰ a); assumption; (* BUG *)
140 lemma unfold_apart: ∀E:excedence. ∀x,y:E. x ≰ y ∨ y ≰ x → x # y.
144 lemma le_rewl: ∀E:excedence.∀z,y,x:E. x ≈ y → x ≤ z → y ≤ z.
145 intros (E z y x Exy Lxz); apply (le_transitive ???? ? Lxz);
146 intro Xyz; apply Exy; apply unfold_apart; right; assumption;
149 notation > "'Ex'≪" non associative with precedence 50 for
150 @{'excedencerewritel}.
152 interpretation "exc_rewl" 'excedencerewritel =
153 (cic:/matita/excedence/exc_rewl.con _ _ _).
155 lemma le_rewr: ∀E:excedence.∀z,y,x:E. x ≈ y → z ≤ x → z ≤ y.
156 intros (E z y x Exy Lxz); apply (le_transitive ???? Lxz);
157 intro Xyz; apply Exy; apply unfold_apart; left; assumption;
160 notation > "'Ex'≫" non associative with precedence 50 for
161 @{'excedencerewriter}.
163 interpretation "exc_rewr" 'excedencerewriter =
164 (cic:/matita/excedence/exc_rewr.con _ _ _).
166 lemma ap_rewl: ∀A:apartness.∀x,z,y:A. x ≈ y → y # z → x # z.
167 intros (A x z y Exy Ayz); cases (ap_cotransitive ???x Ayz); [2:assumption]
168 cases (Exy (ap_symmetric ??? a));
171 lemma ap_rewr: ∀A:apartness.∀x,z,y:A. x ≈ y → z # y → z # x.
172 intros (A x z y Exy Azy); apply ap_symmetric; apply (ap_rewl ???? Exy);
173 apply ap_symmetric; assumption;
176 lemma exc_rewl: ∀A:excedence.∀x,z,y:A. x ≈ y → y ≰ z → x ≰ z.
177 intros (A x z y Exy Ayz); elim (exc_cotransitive ???x Ayz); [2:assumption]
178 cases Exy; right; assumption;
181 lemma exc_rewr: ∀A:excedence.∀x,z,y:A. x ≈ y → z ≰ y → z ≰ x.
182 intros (A x z y Exy Azy); elim (exc_cotransitive ???x Azy); [assumption]
183 elim (Exy); left; assumption;
186 lemma lt_rewr: ∀A:excedence.∀x,z,y:A. x ≈ y → z < y → z < x.
187 intros (A x y z E H); split; elim H;
188 [apply (le_rewr ???? (eq_sym ??? E));|apply (ap_rewr ???? E)] assumption;
191 lemma lt_rewl: ∀A:excedence.∀x,z,y:A. x ≈ y → y < z → x < z.
192 intros (A x y z E H); split; elim H;
193 [apply (le_rewl ???? (eq_sym ??? E));| apply (ap_rewl ???? E);] assumption;
196 lemma lt_le_transitive: ∀A:excedence.∀x,y,z:A.x < y → y ≤ z → x < z.
197 intros (A x y z LT LE); cases LT (LEx APx); split; [apply (le_transitive ???? LEx LE)]
198 whd in LE LEx APx; cases APx (EXx EXx); [cases (LEx EXx)]
199 cases (exc_cotransitive ??? z EXx) (EXz EXz); [cases (LE EXz)]
203 lemma le_lt_transitive: ∀A:excedence.∀x,y,z:A.x ≤ y → y < z → x < z.
204 intros (A x y z LE LT); cases LT (LEx APx); split; [apply (le_transitive ???? LE LEx)]
205 whd in LE LEx APx; cases APx (EXx EXx); [cases (LEx EXx)]
206 cases (exc_cotransitive ??? x EXx) (EXz EXz); [right; assumption]
207 cases LE; assumption;
211 lemma le_le_eq: ∀E:excedence.∀a,b:E. a ≤ b → b ≤ a → a ≈ b.
212 intros (E x y L1 L2); intro H; cases H; [apply L1|apply L2] assumption;
215 lemma ap_le_to_lt: ∀E:excedence.∀a,c:E.c # a → c ≤ a → c < a.
216 intros; split; assumption;