-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLatticeProperties.v
197 lines (154 loc) · 5.39 KB
/
LatticeProperties.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
From Top Require Import Lattice.
Require Import Coq.Classes.RelationClasses.
Generalizable All Variables.
(*-------------------------------------------------------*)
(*
Useful lemmas about meet and join.
In particular,
meet will always lower bound each thing it meets
join will always upper bound each thing it meets
*)
(*-------------------------------------------------------*)
Section LatticeProperties.
Lemma meet_is_lb `{Lattice A}: forall a b : A, a ⊓ b ≤ a /\ a ⊓ b ≤ b.
Proof.
intros.
apply meet_is_inf.
reflexivity.
Qed.
Lemma join_is_ub `{Lattice A}: forall a b : A, a ≤ a ⊔ b /\ b ≤ a ⊔ b.
Proof.
intros.
apply join_is_sup.
reflexivity.
Qed.
(*-------------------------------------------------------*)
(*
Properties of meet
*)
(*-------------------------------------------------------*)
Theorem meet_associative `{Lattice A}: forall a b c:A, (a ⊓ b) ⊓ c = a ⊓ (b ⊓ c).
Proof.
intros.
apply antisymmetric.
(* Prove (a ⊓ b) ⊓ c ≤ a ⊓ (b ⊓ c) *)
apply meet_is_inf. split.
apply transitivity with (y := a ⊓ b). apply meet_is_lb. apply meet_is_lb.
apply meet_is_inf. split.
apply transitivity with (y := a ⊓ b). apply meet_is_lb. apply meet_is_lb.
apply meet_is_lb.
(* Prove a ⊓ (b ⊓ c) ≤ (a ⊓ b) ⊓ c *)
apply meet_is_inf. split. apply meet_is_inf. split.
apply meet_is_lb.
apply transitivity with (y := b ⊓ c). apply meet_is_lb. apply meet_is_lb.
apply transitivity with (y := b ⊓ c). apply meet_is_lb. apply meet_is_lb.
Qed.
Theorem meet_commutative `{Lattice A}: forall a b:A, a ⊓ b = b ⊓ a.
Proof.
intros.
apply antisymmetric. (* split equality into two inequalities *)
rewrite <- meet_is_inf.
split.
apply meet_is_lb. apply meet_is_lb.
rewrite <- meet_is_inf.
split.
apply meet_is_lb. apply meet_is_lb.
Qed.
Theorem meet_idempotent `{Lattice A}: forall a : A, a ⊓ a = a.
Proof.
intros.
apply antisymmetric.
(* Prove a ⊓ a ≤ a. *)
apply meet_is_lb.
(* Prove a ≤ a ⊓ a. *)
apply meet_is_inf. split. reflexivity. reflexivity.
Qed.
Theorem meet_absorptive `{Lattice A}: forall a b : A, a ⊓ (a ⊔ b) = a.
Proof.
intros.
apply antisymmetric.
(* Prove a ⊓ (a ⊔ b) ≤ a. Bad case -- but obvious!*)
apply meet_is_lb.
(* Prove a ≤ a ⊓ (a ⊔ b). Good case! *)
apply meet_is_inf. split. reflexivity. apply join_is_ub.
Qed.
(*-------------------------------------------------------*)
(*
Properties of join
*)
(*-------------------------------------------------------*)
Theorem join_associative `{Lattice A}: forall a b c : A, (a ⊔ b) ⊔ c = a ⊔ (b ⊔ c).
intros.
apply antisymmetric.
(* Prove (a ⊔ b) ⊔ c ≤ a ⊔ (b ⊔ c) *)
apply join_is_sup. split.
apply join_is_sup. split. apply join_is_ub.
apply transitivity with (y := b ⊔ c). apply join_is_ub. apply join_is_ub.
apply transitivity with (y := b ⊔ c). apply join_is_ub. apply join_is_ub.
(* Prove a ⊔ (b ⊔ c) ≤ (a ⊔ b) ⊔ c *)
apply join_is_sup. split.
apply transitivity with (y := a ⊔ b). apply join_is_ub. apply join_is_ub.
apply join_is_sup. split.
apply transitivity with (y := a ⊔ b). apply join_is_ub. apply join_is_ub.
apply join_is_ub.
Qed.
Theorem join_commutative `{Lattice A}: forall a b : A, a ⊔ b = b ⊔ a.
Proof.
intros.
apply antisymmetric. (* split equality into two inequalities *)
rewrite <- join_is_sup.
split.
apply join_is_ub. apply join_is_ub.
rewrite <- join_is_sup.
split.
apply join_is_ub. apply join_is_ub.
Qed.
Theorem join_idempotent `{Lattice A}: forall a : A, a ⊔ a = a.
Proof.
intros.
apply antisymmetric.
(* Prove a ⊔ a ≤ a. *)
apply join_is_sup. split. reflexivity. reflexivity.
(* Prove a ≤ a ⊔ a. *)
apply join_is_ub.
Qed.
Theorem join_absorptive `{Lattice A}: forall a b : A, a ⊔ (a ⊓ b) = a.
Proof.
intros.
apply antisymmetric.
(* Prove a ⊔ (a ⊓ b) ≤ a. Good case!*)
apply join_is_sup. split. reflexivity. apply meet_is_lb.
(* Prove a ≤ a ⊔ (a ⊓ b). Bad case -- but obvious! *)
apply join_is_ub.
Qed.
(*-------------------------------------------------------*)
(*
Relating join, meet, and order with the connecting lemma
*)
(*-------------------------------------------------------*)
Lemma connecting_lemma_join `{Lattice A}: forall a b : A, a ≤ b <-> a ⊔ b = b.
Proof.
intros. split.
intros. apply antisymmetric. apply join_is_sup. split. assumption. reflexivity. apply join_is_ub.
intros. rewrite <- H0. apply join_is_ub.
Qed.
Lemma connecting_lemma_meet `{Lattice A}: forall a b : A, a ≤ b <-> a ⊓ b = a.
Proof.
intros. split.
intros. apply antisymmetric. apply meet_is_lb. apply meet_is_inf. split. reflexivity. assumption.
intros. rewrite <- H0. apply meet_is_lb.
Qed.
Lemma connecting_lemma_joinmeet `{Lattice A}: forall a b : A, a ⊔ b = b <-> a ⊓ b = a.
Proof.
intros. split.
intros. apply connecting_lemma_meet. apply connecting_lemma_join. assumption.
intros. apply connecting_lemma_join. apply connecting_lemma_meet. assumption.
Qed.
Theorem connecting_lemma `{Lattice A}: forall a b : A, (a ≤ b <-> a ⊔ b = b) /\ (a ⊔ b = b <-> a ⊓ b = a) /\ (a ⊓ b = a <-> a ≤ b).
Proof.
intros.
split. apply connecting_lemma_join.
split. apply connecting_lemma_joinmeet.
symmetry. apply connecting_lemma_meet.
Qed.
End LatticeProperties.