]> matita.cs.unibo.it Git - helm.git/blob - matita/dama/ordered_sets.ma
removed dust
[helm.git] / matita / dama / ordered_sets.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/ordered_sets/".
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/ordered_sets/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/ordered_sets/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 definition apart ≝ λE:excedence.λa,b:E. a ≰ b ∨ b ≰ a.
47
48 notation "a # b" non associative with precedence 50 for @{ 'apart $a $b}.
49 interpretation "apartness" 'apart a b = (cic:/matita/ordered_sets/apart.con _ a b). 
50
51 lemma apart_coreflexive: ∀E.coreflexive ? (apart E).
52 intros (E); unfold; cases E; simplify; clear E; intros (x); unfold;
53 intros (H1); apply (H x); cases H1; assumption;
54 qed.
55
56 lemma apart_symmetric: ∀E.symmetric ? (apart E).
57 intros (E); unfold; intros(x y H); cases H; clear H; [right|left] assumption; 
58 qed.
59
60 lemma apart_cotrans: ∀E. cotransitive ? (apart E).
61 intros (E); unfold; cases E (T f _ cTf); simplify; intros (x y z Axy);
62 cases Axy (H); lapply (cTf ? ? z H) as H1; cases H1; clear Axy H1;
63 [left; left|right; left|right; right|left; right] assumption.
64 qed.
65
66 definition eq ≝ λE:excedence.λa,b:E. ¬ (a # b).
67
68 notation "a ≈ b" non associative with precedence 50 for @{ 'napart $a $b}.    
69 interpretation "alikeness" 'napart a b =
70   (cic:/matita/ordered_sets/eq.con _ a b). 
71
72 lemma eq_reflexive:∀E. reflexive ? (eq E).
73 intros (E); unfold; cases E (T f cRf _); simplify; unfold Not; intros (x H);
74 apply (cRf x); cases H; assumption;
75 qed.
76
77 lemma eq_symmetric:∀E.symmetric ? (eq E).
78 intros (E); unfold; unfold eq; unfold Not;
79 intros (x y H1 H2); apply H1; cases H2; [right|left] assumption; 
80 qed.
81
82 lemma eq_transitive: ∀E.transitive ? (eq E).
83 intros (E); unfold; cases E (T f _ cTf); simplify; unfold Not; 
84 intros (x y z H1 H2 H3); cases H3 (H4 H4); clear E H3; lapply (cTf ? ? y H4) as H5;
85 cases H5; clear H5 H4 cTf; [1,4: apply H1|*:apply H2] clear H1 H2;
86 [1,3:left|*:right] assumption;
87 qed.
88
89 lemma le_antisymmetric: ∀E.antisymmetric ? (le E) (eq E).
90 intros (E); unfold; intros (x y Lxy Lyx); unfold; unfold; intros (H);
91 cases H; [apply Lxy;|apply Lyx] assumption;
92 qed.
93
94 definition lt ≝ λE:excedence.λa,b:E. a ≤ b ∧ a # b.
95
96 interpretation "ordered sets less than" 'lt a b =
97  (cic:/matita/ordered_sets/lt.con _ a b).
98
99 lemma lt_coreflexive: ∀E.coreflexive ? (lt E).
100 intros (E); unfold; unfold Not; intros (x H); cases H (_ ABS); 
101 apply (apart_coreflexive ? x ABS);
102 qed.
103
104 lemma lt_transitive: ∀E.transitive ? (lt E).
105 intros (E); unfold; intros (x y z H1 H2); cases H1 (Lxy Axy); cases H2 (Lyz Ayz); 
106 split; [apply (le_transitive ???? Lxy Lyz)] clear H1 H2;
107 cases Axy (H1 H1); cases Ayz (H2 H2); [1:cases (Lxy H1)|3:cases (Lyz H2)]
108 clear Axy Ayz;lapply (exc_cotransitive E) as c; unfold cotransitive in c;
109 lapply (exc_coreflexive E) as r; unfold coreflexive in r;
110 [1: lapply (c ?? y H1) as H3; cases H3 (H4 H4); [cases (Lxy H4)|cases (r ? H4)]
111 |2: lapply (c ?? x H2) as H3; cases H3 (H4 H4); [right; assumption|cases (Lxy H4)]]
112 qed.
113
114 theorem lt_to_excede: ∀E:excedence.∀a,b:E. (a < b) → (b ≰ a).
115 intros (E a b Lab); cases Lab (LEab Aab);
116 cases Aab (H H); [cases (LEab H)] fold normalize (b ≰ a); assumption; (* BUG *)  
117 qed.