Section sec_modal_op_lemmas.
Variable T : Type.
Proof using.
now destruct ex.
Qed.
(* always facts *)
Proof using.
intros P invP.
cofix c.
intros [x s] Pxs; apply Always; trivial.
apply c; apply invP in Pxs.
assumption.
Qed.
Proof using.
intros x s P al. change (P (Cons x s) /\ always P (tl (Cons x s))).
destruct al. split; assumption.
Qed.
Proof using.
intros x s P al. case (always_Cons x s P al); trivial.
Qed.
Proof using.
destruct ex.
apply always_now.
Qed.
Proof using.
intros x s P al. case (always_Cons x s P al); trivial.
Qed.
Proof using.
intros (x, s). simpl. apply always_invar.
Qed.
Proof using.
cofix c.
intros [x s].
apply Always.
- unfold not_tl, False_tl; auto.
- apply c.
Qed.
Proof using.
cofix c.
intros [x s].
apply Always.
- unfold True_tl; trivial.
- apply c.
Qed.
Proof using.
intros P Q.
cofix c.
intros s alP alQ.
destruct alP.
destruct alQ.
apply Always.
- split; assumption.
- apply c; assumption.
Qed.
Proof using.
intro P.
cofix c.
constructor.
- auto.
- do 2 destruct s.
constructor; eauto using always_invar.
Qed.
Proof using.
intros P.
cofix alwn.
intros s a; case a; clear a s. intros (x, s); simpl. constructor.
- assumption.
- apply alwn; assumption.
Qed.
Proof using.
intros P.
cofix alwn. destruct 1. constructor; simpl.
- assumption.
- apply alwn; assumption.
Qed.
Proof using.
intros J P.
cofix c.
intros [x s] alJ.
apply W_tl.
- apply always_now in alJ.
assumption.
- apply c.
apply always_invar in alJ.
assumption.
Qed.
Proof using.
intros J P.
cofix c.
intros [x s] al.
apply R_tl.
- apply always_now in al.
assumption.
- simpl.
apply c.
apply always_invar in al.
assumption.
Qed.
Proof using.
intros P. cofix f. intros s a. destruct a. constructor.
- constructor 1. assumption.
- apply f. assumption.
Qed.
Proof using.
intros P s alP.
apply E0.
assumption.
Qed.
(* weak_until and eventually facts *)
Proof using.
intros x s J P un.
change (P (Cons x s) \/ (J (Cons x s) /\ weak_until J P (tl (Cons x s)))).
destruct un; intuition.
Qed.
Proof using.
cofix cf.
intros J J' P s Hweak Halways.
destruct s.
inversion Hweak.
- now eauto using W0.
- inversion Halways.
eapply W_tl.
+ now unfold and_tl.
+ simpl. now eauto.
Qed.
Proof using.
intros J P s un.
induction un.
- apply W0. assumption.
- apply W_tl; trivial.
Qed.
Proof using.
intros x s P al. change (P (Cons x s) \/ eventually P (tl (Cons x s))). case al; auto.
Qed.
Proof using.
intros P Q inv is_inv PeQ s invs ev. induction ev as [s Ps | x s ev IHev].
- apply PeQ; assumption.
- constructor 2. apply IHev. apply is_inv with x; assumption.
Qed.
Proof using.
intros P x s evCP evP.
contradict evCP.
apply E_next.
assumption.
Qed.
Proof using.
intros e P ev. induction ev as [(x, s) Ps | x s ev induc_hyp].
- constructor 2; constructor 1; exact Ps.
- constructor 2. apply induc_hyp.
Qed.
Proof using.
induction 1 as [s Ps | x s evPs induc_hyp]; intro al.
- constructor 1. split; assumption.
- constructor 2. apply induc_hyp. eapply always_invar; eauto.
Qed.
Proof using.
intros s P J ev. induction ev as [s Ps | x s evPs induc_hyp].
- intro un. constructor 1. split; assumption.
- intro unxs. case (weak_until_Cons _ _ _ _ unxs).
* intro Pxs. constructor 1; split; assumption.
* intros (_, uns). constructor 2. apply induc_hyp. exact uns.
Qed.

Lemma weak_until_eventually :
forall (P Q J: infseq T -> Prop),
(forall s, J s -> P s -> Q s) ->
forall s, J s -> weak_until J Q s -> eventually P s -> eventually Q s.