Skip to content

Commit ef0452c

Browse files
committed
util -> weak_until, introduce standard until operator and some lemmas
1 parent 328b351 commit ef0452c

3 files changed

Lines changed: 131 additions & 56 deletions

File tree

exteq.v

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,6 @@ Proof.
122122
intros P s1 s2 e. do 2 destruct e; simpl. trivial.
123123
Qed.
124124

125-
Lemma extensional_eventually :
126-
forall (P: infseq T -> Prop),
127-
extensional P -> extensional (eventually P).
128-
Proof.
129-
intros P eP s1 s2 e ev1. genclear e; genclear s2.
130-
induction ev1 as [s1 ev1 | x1 s1 ev1 induc_hyp].
131-
intros s2 e. constructor 1. apply eP with s1; assumption.
132-
intros (x2, s2) e. constructor 2. apply induc_hyp.
133-
case (exteq_inversion e). trivial.
134-
Qed.
135-
136125
Lemma extensional_always :
137126
forall (P: infseq T -> Prop),
138127
extensional P -> extensional (always P).
@@ -143,18 +132,43 @@ intros (x1, s1) (x2, s2) e al1. case (always_Cons al1); intros Px1s1 als1. const
143132
simpl. apply cf with s1; try assumption. case (exteq_inversion e); trivial.
144133
Qed.
145134

146-
Lemma extensional_until :
135+
Lemma extensional_weak_until :
147136
forall (P Q: infseq T -> Prop),
148-
extensional P -> extensional Q -> extensional (until P Q).
137+
extensional P -> extensional Q -> extensional (weak_until P Q).
149138
Proof.
150139
intros P Q eP eQ. cofix cf.
151-
intros (x1, s1) (x2, s2) e un1. case (until_Cons un1).
140+
intros (x1, s1) (x2, s2) e un1. case (weak_until_Cons un1).
152141
intro Q1. constructor 1. eapply eQ; eassumption.
153142
intros (Px1s1, uns1). constructor 2.
154143
eapply eP; eassumption.
155144
simpl. apply cf with s1; try assumption. case (exteq_inversion e); trivial.
156145
Qed.
157146

147+
Lemma extensional_until :
148+
forall (P Q: infseq T -> Prop),
149+
extensional P -> extensional Q -> extensional (until P Q).
150+
Proof.
151+
intros P Q eP eQ s1 s2 e un1; genclear e; genclear s2.
152+
induction un1.
153+
intros s2 e; apply U0; apply eQ with s; assumption.
154+
intros (x2, s2) e.
155+
apply U_next.
156+
apply eP with (Cons x s); assumption.
157+
apply IHun1.
158+
case (exteq_inversion e). trivial.
159+
Qed.
160+
161+
Lemma extensional_eventually :
162+
forall (P: infseq T -> Prop),
163+
extensional P -> extensional (eventually P).
164+
Proof.
165+
intros P eP s1 s2 e ev1. genclear e; genclear s2.
166+
induction ev1 as [s1 ev1 | x1 s1 ev1 induc_hyp].
167+
intros s2 e. constructor 1. apply eP with s1; assumption.
168+
intros (x2, s2) e. constructor 2. apply induc_hyp.
169+
case (exteq_inversion e). trivial.
170+
Qed.
171+
158172
Lemma extensional_inf_often :
159173
forall (P: infseq T -> Prop),
160174
extensional P -> extensional (inf_often P).

infseq.v

Lines changed: 79 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ CoInductive always1 (P: T->Prop) : infseq T -> Prop :=
5757
CoInductive always (P: infseq T->Prop) : infseq T -> Prop :=
5858
| Always : forall s, P s -> always P (tl s) -> always P s.
5959

60-
CoInductive until (J P: infseq T->Prop) : infseq T -> Prop :=
61-
| Until0 : forall s, P s -> until J P s
62-
| Until_tl : forall s, J s -> until J P (tl s) -> until J P s.
60+
CoInductive weak_until (J P: infseq T->Prop) : infseq T -> Prop :=
61+
| W0 : forall s, P s -> weak_until J P s
62+
| W_tl : forall s, J s -> weak_until J P (tl s) -> weak_until J P s.
63+
64+
Inductive until (J P: infseq T->Prop) : infseq T -> Prop :=
65+
| U0 : forall s, P s -> until J P s
66+
| U_next : forall x s, J (Cons x s) -> until J P s -> until J P (Cons x s).
6367

6468
Inductive eventually (P: infseq T->Prop) : infseq T -> Prop :=
6569
| E0 : forall s, P s -> eventually P s
@@ -89,6 +93,7 @@ Implicit Arguments consecutive [T].
8993
Implicit Arguments always [T].
9094
Implicit Arguments always1 [T].
9195
Implicit Arguments eventually [T].
96+
Implicit Arguments weak_until [T].
9297
Implicit Arguments until [T].
9398
Implicit Arguments inf_often [T].
9499
Implicit Arguments continuously [T].
@@ -190,14 +195,14 @@ apply E0.
190195
assumption.
191196
Qed.
192197

193-
(* until and eventually facts *)
198+
(* weak_until and eventually facts *)
194199

195-
Lemma until_Cons :
200+
Lemma weak_until_Cons :
196201
forall (x: T) (s: infseq T) J P,
197-
until J P (Cons x s) -> P (Cons x s) \/ (J (Cons x s) /\ until J P s).
202+
weak_until J P (Cons x s) -> P (Cons x s) \/ (J (Cons x s) /\ weak_until J P s).
198203
Proof.
199204
intros x s J P un.
200-
change (P (Cons x s) \/ (J (Cons x s) /\ until J P (tl (Cons x s)))).
205+
change (P (Cons x s) \/ (J (Cons x s) /\ weak_until J P (tl (Cons x s)))).
201206
destruct un; intuition.
202207
Qed.
203208

@@ -246,37 +251,57 @@ induction 1 as [s Ps | x s evPs induc_hyp].
246251
intro al. constructor 2. apply induc_hyp. apply (always_invar _ _ _ al).
247252
Qed.
248253

249-
Lemma eventually_until_cumul :
254+
Lemma eventually_weak_until_cumul :
250255
forall (s: infseq T) P J,
251-
eventually P s -> until J P s -> eventually (P /\_ until J P) s.
256+
eventually P s -> weak_until J P s -> eventually (P /\_ weak_until J P) s.
252257
Proof.
253258
intros s P J ev. induction ev as [s Ps | x s evPs induc_hyp].
254259
intro un. constructor 1. split; assumption.
255-
intro unxs. case (until_Cons _ _ _ _ unxs).
256-
intro Pxs. constructor 1; split; assumption.
257-
intros (_, uns). constructor 2. apply induc_hyp. exact uns.
260+
intro unxs. case (weak_until_Cons _ _ _ _ unxs).
261+
intro Pxs. constructor 1; split; assumption.
262+
intros (_, uns). constructor 2. apply induc_hyp. exact uns.
258263
Qed.
259264

260-
Lemma until_eventually :
265+
Lemma weak_until_eventually :
261266
forall (P Q J: infseq T -> Prop),
262267
(forall s, J s -> P s -> Q s) ->
263-
forall s, J s -> until J Q s -> eventually P s -> eventually Q s.
268+
forall s, J s -> weak_until J Q s -> eventually P s -> eventually Q s.
264269
Proof.
265-
intros P Q J impl s Js J_until_Q ev.
266-
genclear J_until_Q; genclear Js.
270+
intros P Q J impl s Js J_weak_until_Q ev.
271+
genclear J_weak_until_Q; genclear Js.
267272
induction ev as [s Ps | x s ev induc_hyp].
268-
intros Js J_until_Q. constructor 1. apply impl; assumption.
269-
intros _ J_until_Q. cut (s = tl (Cons x s)); [idtac | reflexivity].
270-
case J_until_Q; clear J_until_Q x.
273+
intros Js J_weak_until_Q. constructor 1. apply impl; assumption.
274+
intros _ J_weak_until_Q. cut (s = tl (Cons x s)); [idtac | reflexivity].
275+
case J_weak_until_Q; clear J_weak_until_Q x.
271276
constructor 1; assumption.
272-
intros (x, s1) _ J_until_Q e; simpl in *.
273-
constructor 2. generalize e J_until_Q; clear e x. (* trick: keep J_until_Q!! *)
274-
case J_until_Q; clear J_until_Q s1.
277+
intros (x, s1) _ J_weak_until_Q e; simpl in *.
278+
constructor 2. generalize e J_weak_until_Q; clear e x. (* trick: keep J_weak_until_Q!! *)
279+
case J_weak_until_Q; clear J_weak_until_Q s1.
275280
clearall. constructor 1; assumption.
276-
intros s2 Js2 _ e J_until_Q2. rewrite e in induc_hyp; clear e.
281+
intros s2 Js2 _ e J_weak_until_Q2. rewrite e in induc_hyp; clear e.
277282
apply induc_hyp; assumption.
278283
Qed.
279284

285+
(* until facts *)
286+
287+
Lemma until_Cons :
288+
forall (x: T) (s: infseq T) J P,
289+
until J P (Cons x s) -> P (Cons x s) \/ (J (Cons x s) /\ until J P s).
290+
Proof.
291+
intros x s J P ul.
292+
change (P (Cons x s) \/ (J (Cons x s) /\ until J P (tl (Cons x s)))). case ul; auto.
293+
Qed.
294+
295+
Lemma until_eventually :
296+
forall (P J: infseq T -> Prop),
297+
forall s, until J P s -> eventually P s.
298+
Proof.
299+
intros P J s unP.
300+
induction unP.
301+
apply E0; assumption.
302+
apply E_next; assumption.
303+
Qed.
304+
280305
(* inf_often and continuously facts *)
281306

282307
Lemma inf_often_invar :
@@ -348,15 +373,28 @@ generalize (always_Cons x s P a); simpl; intros (a1, a2). constructor; simpl.
348373
apply cf. assumption.
349374
Qed.
350375

376+
Lemma weak_until_monotonic :
377+
forall (P Q J K: infseq T -> Prop),
378+
(forall s, P s -> Q s) -> (forall s, J s -> K s) ->
379+
forall s, weak_until J P s -> weak_until K Q s.
380+
Proof.
381+
intros P Q J K PQ JK. cofix cf. intros(x, s) un.
382+
generalize (weak_until_Cons x s J P un); simpl. intros [Pxs | (Jxs, uns)].
383+
constructor 1; simpl; auto.
384+
constructor 2; simpl; auto.
385+
Qed.
386+
351387
Lemma until_monotonic :
352388
forall (P Q J K: infseq T -> Prop),
353-
(forall s, P s -> Q s) -> (forall s, J s -> K s) ->
389+
(forall s, P s -> Q s) -> (forall s, J s -> K s) ->
354390
forall s, until J P s -> until K Q s.
355391
Proof.
356-
intros P Q J K PQ JK. cofix cf. intros(x, s) un.
357-
generalize (until_Cons x s J P un); simpl. intros [Pxs | (Jxs, uns)].
358-
constructor 1; simpl; auto.
359-
constructor 2; simpl; auto.
392+
intros P Q J K PQ JK s unJP.
393+
induction unJP.
394+
apply U0, PQ; assumption.
395+
apply U_next.
396+
apply JK; assumption.
397+
assumption.
360398
Qed.
361399

362400
Lemma eventually_monotonic :
@@ -452,15 +490,15 @@ contradict IHeP.
452490
assumption.
453491
Qed.
454492

455-
Lemma until_always_not_always :
493+
Lemma weak_until_always_not_always :
456494
forall (J P : infseq T -> Prop) (s : infseq T),
457-
until J P s -> always (~_ P) s -> always J s.
495+
weak_until J P s -> always (~_ P) s -> always J s.
458496
Proof.
459497
intros J P.
460498
cofix c.
461499
intros s unJP alP.
462500
destruct s as [e s].
463-
apply until_Cons in unJP.
501+
apply weak_until_Cons in unJP.
464502
case unJP.
465503
intro PC.
466504
apply always_Cons in alP.
@@ -596,14 +634,17 @@ Implicit Arguments always_always1 [T s P].
596634
Implicit Arguments always_inf_often [T s P].
597635
Implicit Arguments always_continuously [T s P].
598636

599-
Implicit Arguments until_Cons [T x s J P].
637+
Implicit Arguments weak_until_Cons [T x s J P].
600638
Implicit Arguments eventually_Cons [T x s P].
601639
Implicit Arguments eventually_trans [T P Q inv s].
602640
Implicit Arguments not_eventually [T P x s].
603641
Implicit Arguments eventually_next [T P s].
604642
Implicit Arguments eventually_always_cumul [T s P Q].
605-
Implicit Arguments eventually_until_cumul [T s P J].
606-
Implicit Arguments until_eventually [T P Q s J].
643+
Implicit Arguments eventually_weak_until_cumul [T s P J].
644+
Implicit Arguments weak_until_eventually [T P Q s J].
645+
646+
Implicit Arguments until_Cons [T x s J P].
647+
Implicit Arguments until_eventually [T s J P].
607648

608649
Implicit Arguments inf_often_invar [T x s P].
609650
Implicit Arguments continuously_invar [T x s P].
@@ -613,6 +654,7 @@ Implicit Arguments now_monotonic [T P Q s].
613654
Implicit Arguments next_monotonic [T P Q s].
614655
Implicit Arguments consecutive_monotonic [T P Q s].
615656
Implicit Arguments always_monotonic [T P Q s].
657+
Implicit Arguments weak_until_monotonic [T P Q J K s].
616658
Implicit Arguments until_monotonic [T P Q J K s].
617659
Implicit Arguments eventually_monotonic [T P Q s].
618660
Implicit Arguments eventually_monotonic_simple [T P Q s].
@@ -621,7 +663,7 @@ Implicit Arguments continuously_monotonic [T P Q s].
621663

622664
Implicit Arguments not_eventually_always_not [T P s].
623665
Implicit Arguments eventually_not_always [T P s].
624-
Implicit Arguments until_always_not_always [T J P s].
666+
Implicit Arguments weak_until_always_not_always [T J P s].
625667
Implicit Arguments always_not_eventually_not [T P s].
626668
Implicit Arguments continuously_not_inf_often [T P s].
627669
Implicit Arguments inf_often_not_continuously [T P s].
@@ -640,9 +682,10 @@ Ltac monotony :=
640682
| [ |- consecutive ?P ?s -> consecutive ?Q ?s ] =>
641683
apply consecutive_monotonic
642684
| [ |- always ?P ?s -> always ?Q ?s ] => apply always_monotonic
685+
| [ |- weak_until ?J ?P ?s -> weak_until ?K ?Q ?s ] => apply weak_until_monotonic
686+
| [ |- until ?J ?P ?s -> until ?K ?Q ?s ] => apply until_monotonic
643687
| [ |- ?J ?s -> eventually ?P ?s -> eventually ?Q ?s ] =>
644688
apply eventually_monotonic
645-
| [ |- until ?J ?P ?s -> until ?K ?Q ?s ] => apply until_monotonic
646689
| [ |- continuously ?P ?s -> continuously ?Q ?s ] =>
647690
apply continuously_monotonic
648691
| [ |- inf_often ?P ?s -> inf_often ?Q ?s ] =>

map.v

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,35 +191,53 @@ intros (x, s) a. rewrite map_Cons in a. case (always_Cons a); intros a1 a2. cons
191191
simpl. apply cf; assumption.
192192
Qed.
193193

194-
Lemma until_map :
194+
Lemma weak_until_map :
195195
forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop),
196196
(forall s, J s -> K (map f s)) ->
197197
(forall s, P s -> Q (map f s)) ->
198198
forall (s: infseq A),
199-
(until J P) s -> (until K Q) (map f s).
199+
weak_until J P s -> weak_until K Q (map f s).
200200
Proof.
201201
intros f J P K Q JK PQ. cofix cf.
202-
intros (x, s) un. case (until_Cons un); clear un.
202+
intros (x, s) un. case (weak_until_Cons un); clear un.
203203
intro Pxs; constructor 1. apply PQ. assumption.
204204
intros (Jxs, un). rewrite map_Cons. constructor 2.
205205
rewrite <- map_Cons. auto.
206206
simpl. auto.
207207
Qed.
208208

209-
Lemma until_map_conv :
209+
Lemma weak_until_map_conv :
210210
forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop),
211211
(forall s, K (map f s) -> J s) ->
212212
(forall s, Q (map f s) -> P s) ->
213213
forall (s: infseq A),
214-
(until K Q) (map f s) -> (until J P) s.
214+
weak_until K Q (map f s) -> weak_until J P s.
215215
Proof.
216216
intros f J P K Q KJ QP. cofix cf.
217217
intros (x, s) un.
218-
rewrite map_Cons in un; case (until_Cons un); clear un; rewrite <- map_Cons.
218+
rewrite map_Cons in un; case (weak_until_Cons un); clear un; rewrite <- map_Cons.
219219
intro Qxs; constructor 1. apply QP. assumption.
220220
intros (Kxs, un). constructor 2; simpl; auto.
221221
Qed.
222222

223+
Lemma until_map :
224+
forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop),
225+
(forall s, J s -> K (map f s)) ->
226+
(forall s, P s -> Q (map f s)) ->
227+
forall (s: infseq A),
228+
until J P s -> until K Q (map f s).
229+
Proof.
230+
intros f J P K Q JK PQ s un.
231+
induction un.
232+
apply U0, PQ. assumption.
233+
rewrite map_Cons.
234+
apply U_next.
235+
rewrite <- map_Cons.
236+
apply JK.
237+
assumption.
238+
assumption.
239+
Qed.
240+
223241
Lemma eventually_map :
224242
forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop),
225243
(forall s, P s -> Q (map f s)) ->

0 commit comments

Comments
 (0)