]> matita.cs.unibo.it Git - helm.git/blob - matita/dama/excedence.ma
snapshot
[helm.git] / 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 → Prop;
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 # 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 apart ≝ λE:excedence.λa,b:E. a ≰ b ∨ b ≰ a.
59
60 definition apart_of_excedence: excedence → apartness.
61 intros (E); apply (mk_apartness E (apart E));  
62 [1: unfold; cases E; simplify; clear E; intros (x); unfold;
63     intros (H1); apply (H x); cases H1; assumption;
64 |2: unfold; intros(x y H); cases H; clear H; [right|left] assumption;
65 |3: intros (E); unfold; cases E (T f _ cTf); simplify; intros (x y z Axy);
66     cases Axy (H); lapply (cTf ? ? z H) as H1; cases H1; clear Axy H1;
67     [left; left|right; left|right; right|left; right] assumption]
68 qed.
69
70 coercion cic:/matita/excedence/apart_of_excedence.con.
71
72 definition eq ≝ λA:apartness.λa,b:A. ¬ (a # b).
73
74 notation "a ≈ b" non associative with precedence 50 for @{ 'napart $a $b}.    
75 interpretation "alikeness" 'napart a b =
76   (cic:/matita/excedence/eq.con _ a b). 
77
78 lemma eq_reflexive:∀E. reflexive ? (eq E).
79 intros (E); unfold; intros (x); apply ap_coreflexive; 
80 qed.
81
82 lemma eq_symmetric:∀E.symmetric ? (eq E).
83 intros (E); unfold; intros (x y Exy); unfold; unfold; intros (Ayx); apply Exy;
84 apply ap_symmetric; assumption; 
85 qed.
86
87 lemma eq_transitive: ∀E.transitive ? (eq E).
88 (* bug. intros k deve fare whd quanto basta *)
89 intros 6 (E x y z Exy Eyz); intro Axy; cases (ap_cotransitive ???y Axy); 
90 [apply Exy|apply Eyz] assumption.
91 qed.
92 (* BUG: vedere se ricapita *)
93 lemma le_antisymmetric: ∀E.antisymmetric ? (le E) (eq ?).
94 intros 5 (E x y Lxy Lyx); intro H;
95 cases H; [apply Lxy;|apply Lyx] assumption;
96 qed.
97
98 definition lt ≝ λE:excedence.λa,b:E. a ≤ b ∧ a # b.
99
100 interpretation "ordered sets less than" 'lt a b =
101  (cic:/matita/excedence/lt.con _ a b).
102
103 lemma lt_coreflexive: ∀E.coreflexive ? (lt E).
104 intros 2 (E x); intro H; cases H (_ ABS); 
105 apply (ap_coreflexive ? x ABS);
106 qed.
107  
108 lemma lt_transitive: ∀E.transitive ? (lt E).
109 intros (E); unfold; intros (x y z H1 H2); cases H1 (Lxy Axy); cases H2 (Lyz Ayz); 
110 split; [apply (le_transitive ???? Lxy Lyz)] clear H1 H2;
111 cases Axy (H1 H1); cases Ayz (H2 H2); [1:cases (Lxy H1)|3:cases (Lyz H2)]
112 clear Axy Ayz;lapply (exc_cotransitive E) as c; unfold cotransitive in c;
113 lapply (exc_coreflexive E) as r; unfold coreflexive in r;
114 [1: lapply (c ?? y H1) as H3; cases H3 (H4 H4); [cases (Lxy H4)|cases (r ? H4)]
115 |2: lapply (c ?? x H2) as H3; cases H3 (H4 H4); [right; assumption|cases (Lxy H4)]]
116 qed.
117
118 theorem lt_to_excede: ∀E:excedence.∀a,b:E. (a < b) → (b ≰ a).
119 intros (E a b Lab); cases Lab (LEab Aab);
120 cases Aab (H H); [cases (LEab H)] fold normalize (b ≰ a); assumption; (* BUG *)  
121 qed.