2
Require Import Relations.
6
Lemma Bool_elim_bool : forall (b:bool),b=true \/ b=false.
10
Module OrderedPair (X:OrderedType) (Y:OrderedType) <: OrderedType with
11
Definition t := (X.t * Y.t)%type.
12
Definition t := (X.t * Y.t)%type.
14
Definition eq (xy1:t) (xy2:t) :=
17
(X.eq x1 x2) /\ (Y.eq y1 y2).
19
Definition lt (xy1:t) (xy2:t) :=
22
(X.lt x1 x2) \/ ((X.eq x1 x2) /\ (Y.lt y1 y2)).
24
Lemma eq_refl : forall (x:t),(eq x x).
27
split;[apply X.eq_refl | apply Y.eq_refl].
30
Lemma eq_sym : forall (x y:t),(eq x y)->(eq y x).
31
destruct x;destruct y;unfold eq;intro.
32
elim H;clear H;intros.
33
split;[apply X.eq_sym | apply Y.eq_sym];trivial.
36
Lemma eq_trans : forall (x y z:t),(eq x y)->(eq y z)->(eq x z).
37
unfold eq;destruct x;destruct y;destruct z;intros.
38
elim H;clear H;intros.
39
elim H0;clear H0;intros.
40
split;[eapply X.eq_trans | eapply Y.eq_trans];eauto.
43
Lemma lt_trans : forall (x y z:t),(lt x y)->(lt y z)->(lt x z).
44
unfold lt;destruct x;destruct y;destruct z;intros.
46
case H0;clear H0;intro.
48
eapply X.lt_trans;eauto.
49
elim H0;clear H0;intros.
51
case (X.compare t0 t4);trivial;intros.
52
generalize (X.eq_sym H0);intro.
53
generalize (X.eq_trans e H2);intro.
54
elim (X.lt_not_eq H H3).
55
generalize (X.lt_trans l H);intro.
56
generalize (X.eq_sym H0);intro.
57
elim (X.lt_not_eq H2 H3).
58
elim H;clear H;intros.
59
case H0;clear H0;intro.
61
case (X.compare t0 t4);trivial;intros.
62
generalize (X.eq_sym H);intro.
63
generalize (X.eq_trans H2 e);intro.
64
elim (X.lt_not_eq H0 H3).
65
generalize (X.lt_trans H0 l);intro.
66
generalize (X.eq_sym H);intro.
67
elim (X.lt_not_eq H2 H3).
68
elim H0;clear H0;intros.
75
Lemma lt_not_eq : forall (x y:t),(lt x y)->~(eq x y).
76
unfold lt, eq;destruct x;destruct y;intro;intro.
77
elim H0;clear H0;intros.
80
apply (X.lt_not_eq H2 H0).
82
elim H2;clear H2;intros.
83
apply (Y.lt_not_eq H3 H1).
86
Definition compare : forall (x y:t),(Compare lt eq x y).
87
destruct x;destruct y.
88
case (X.compare t0 t2);intro.
91
case (Y.compare t1 t3);intro.
103
Hint Immediate eq_sym.
104
Hint Resolve eq_refl eq_trans lt_not_eq lt_trans.
108
Inductive message : Set :=
109
| MNam : nat -> message.
111
Definition t := message.
113
Fixpoint message_lt (m n:message) {struct m} : Prop :=
115
| (MNam n1,MNam n2) => n1 < n2
118
Module Ord <: OrderedType with Definition t := message with Definition eq :=
120
Definition t := message.
121
Definition eq := @eq message.
122
Definition lt := message_lt.
124
Lemma eq_refl : forall (x:t),eq x x.
128
Lemma eq_sym : forall (x y:t),(eq x y )->(eq y x).
132
Lemma eq_trans : forall (x y z:t),(eq x y)->(eq y z)->(eq x z).
133
unfold eq;auto;intros;congruence.
136
Lemma lt_trans : forall (x y z:t),(lt x y)->(lt y z)->(lt x z).
138
induction x;destruct y;simpl;try tauto;destruct z;try tauto;intros.
142
Lemma lt_not_eq : forall (x y:t),(lt x y)->~(eq x y).
144
induction x;destruct y;simpl;try tauto;intro;red;intro;try (discriminate
145
H0);injection H0;intros.
146
elim (lt_irrefl n);try omega.
149
Definition compare : forall (x y:t),(Compare lt eq x y).
151
induction x;destruct y;intros;try (apply LT;simpl;trivial;fail);try
153
GT;simpl;trivial;fail).
154
case (lt_eq_lt_dec n n0);intros;try (case s;clear s;intros).
161
Hint Immediate eq_sym.
162
Hint Resolve eq_refl eq_trans lt_not_eq lt_trans.
165
Theorem eq_dec : forall (m n:message),{m=n}+{~(m=n)}.
167
case (Ord.compare m n);intro;[right | left | right];try (red;intro).
168
elim (Ord.lt_not_eq m n);auto.
170
elim (Ord.lt_not_eq n m);auto.
174
Module MessagePair := OrderedPair MessageSpi.Ord MessageSpi.Ord.
176
Module Type Hedge := FSetInterface.S with Module E := MessagePair.
179
Definition hedge := H.t.
181
Definition message_relation := relation MessageSpi.message.
183
Definition relation_of_hedge (h:hedge) (m n:MessageSpi.message) := H.In (m,n)
186
Inductive hedge_synthesis_relation (h:message_relation) : message_relation :=
187
| SynInc : forall (m n:MessageSpi.message),(h m
188
n)->(hedge_synthesis_relation h m n).
190
Fixpoint hedge_in_synthesis (h:hedge) (m:MessageSpi.message)
191
(n:MessageSpi.message) {struct m} : bool :=
196
Definition hedge_synthesis_spec (h:hedge) := hedge_synthesis_relation
197
(relation_of_hedge h).
199
Lemma hedge_in_synthesis_impl_hedge_synthesis_spec : forall (h:hedge),forall
200
(m n:MessageSpi.message),(hedge_in_synthesis h m n)=true->(hedge_synthesis_spec
202
unfold hedge_synthesis_spec;unfold relation_of_hedge.
203
induction m;simpl;intro.
204
elim (Bool_elim_bool (H.mem (MessageSpi.MNam n,n0) h));intros.
205
apply SynInc;apply H.mem_2;trivial.
206
rewrite H in H0. (* !! possible here !! *)
212
Definition hedge := H.t.
214
Definition message_relation := relation MessageSpi.t.
216
Definition relation_of_hedge (h:hedge) (m n:MessageSpi.t) := H.In (m,n) h.
218
Inductive hedge_synthesis_relation (h:message_relation) : message_relation :=
219
| SynInc : forall (m n:MessageSpi.t),(h m n)->(hedge_synthesis_relation h m
222
Fixpoint hedge_in_synthesis (h:hedge) (m:MessageSpi.t) (n:MessageSpi.t)
228
Definition hedge_synthesis_spec (h:hedge) := hedge_synthesis_relation
229
(relation_of_hedge h).
231
Lemma hedge_in_synthesis_impl_hedge_synthesis_spec : forall (h:hedge),forall
232
(m n:MessageSpi.t),(hedge_in_synthesis h m n)=true->(hedge_synthesis_spec h m
234
unfold hedge_synthesis_spec;unfold relation_of_hedge.
235
induction m;simpl;intro.
236
elim (Bool_elim_bool (H.mem (MessageSpi.MNam n,n0) h));intros.
237
apply SynInc;apply H.mem_2;trivial.
239
rewrite H in H0. (* !! impossible here !! *)
b'\\ No newline at end of file'