Skip to content
Snippets Groups Projects
Commit 93de71b2 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Clean up ars.v.

parent 7df27997
No related branches found
No related tags found
No related merge requests found
...@@ -37,28 +37,35 @@ Section definitions. ...@@ -37,28 +37,35 @@ Section definitions.
| tc_once x y : R x y tc x y | tc_once x y : R x y tc x y
| tc_l x y z : R x y tc y z tc x z. | tc_l x y z : R x y tc y z tc x z.
(** An element [x] is looping if all paths starting at [x] are infinite. *) (** An element [x] is universally looping if all paths starting at [x]
CoInductive looping : A Prop := are infinite. *)
| looping_do_step x : red x ( y, R x y looping y) looping x. CoInductive all_loop : A Prop :=
| all_loop_do_step x : red x ( y, R x y all_loop y) all_loop x.
(** An element [x] is existentally looping if some path starting at [x]
is infinite. *)
CoInductive ex_loop : A Prop :=
| ex_loop_do_step x y : R x y ex_loop y ex_loop x.
End definitions. End definitions.
Hint Constructors rtc nsteps bsteps tc : ars.
(** * General theorems *) (** * General theorems *)
Section rtc. Section rtc.
Context `{R : relation A}. Context `{R : relation A}.
Hint Constructors rtc nsteps bsteps tc.
Global Instance rtc_reflexive: Reflexive (rtc R). Global Instance rtc_reflexive: Reflexive (rtc R).
Proof. red. apply rtc_refl. Qed. Proof. exact (@rtc_refl A R). Qed.
Global Instance rtc_transitive: Transitive (rtc R). Lemma rtc_transitive x y z : rtc R x y rtc R y z rtc R x z.
Proof. red. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Global Instance: Transitive (rtc R).
Proof. exact rtc_transitive. Qed.
Lemma rtc_once x y : R x y rtc R x y. Lemma rtc_once x y : R x y rtc R x y.
Proof. eauto with ars. Qed. Proof. eauto. Qed.
Instance rtc_once_subrel: subrelation R (rtc R). Instance rtc_once_subrel: subrelation R (rtc R).
Proof. exact @rtc_once. Qed. Proof. exact @rtc_once. Qed.
Lemma rtc_r x y z : rtc R x y R y z rtc R x z. Lemma rtc_r x y z : rtc R x y R y z rtc R x z.
Proof. intros. etransitivity; eauto with ars. Qed. Proof. intros. etransitivity; eauto. Qed.
Lemma rtc_inv x z : rtc R x z x = z y, R x y rtc R y z. Lemma rtc_inv x z : rtc R x z x = z y, R x y rtc R y z.
Proof. inversion_clear 1; eauto. Qed. Proof. inversion_clear 1; eauto. Qed.
Lemma rtc_ind_r_weak (P : A A Prop) Lemma rtc_ind_r_weak (P : A A Prop)
...@@ -79,22 +86,22 @@ Section rtc. ...@@ -79,22 +86,22 @@ Section rtc.
Proof. revert z. apply rtc_ind_r; eauto. Qed. Proof. revert z. apply rtc_ind_r; eauto. Qed.
Lemma nsteps_once x y : R x y nsteps R 1 x y. Lemma nsteps_once x y : R x y nsteps R 1 x y.
Proof. eauto with ars. Qed. Proof. eauto. Qed.
Lemma nsteps_trans n m x y z : Lemma nsteps_trans n m x y z :
nsteps R n x y nsteps R m y z nsteps R (n + m) x z. nsteps R n x y nsteps R m y z nsteps R (n + m) x z.
Proof. induction 1; simpl; eauto with ars. Qed. Proof. induction 1; simpl; eauto. Qed.
Lemma nsteps_r n x y z : nsteps R n x y R y z nsteps R (S n) x z. Lemma nsteps_r n x y z : nsteps R n x y R y z nsteps R (S n) x z.
Proof. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Lemma nsteps_rtc n x y : nsteps R n x y rtc R x y. Lemma nsteps_rtc n x y : nsteps R n x y rtc R x y.
Proof. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Lemma rtc_nsteps x y : rtc R x y n, nsteps R n x y. Lemma rtc_nsteps x y : rtc R x y n, nsteps R n x y.
Proof. induction 1; firstorder eauto with ars. Qed. Proof. induction 1; firstorder eauto. Qed.
Lemma bsteps_once n x y : R x y bsteps R (S n) x y. Lemma bsteps_once n x y : R x y bsteps R (S n) x y.
Proof. eauto with ars. Qed. Proof. eauto. Qed.
Lemma bsteps_plus_r n m x y : Lemma bsteps_plus_r n m x y :
bsteps R n x y bsteps R (n + m) x y. bsteps R n x y bsteps R (n + m) x y.
Proof. induction 1; simpl; eauto with ars. Qed. Proof. induction 1; simpl; eauto. Qed.
Lemma bsteps_weaken n m x y : Lemma bsteps_weaken n m x y :
n m bsteps R n x y bsteps R m x y. n m bsteps R n x y bsteps R m x y.
Proof. Proof.
...@@ -107,62 +114,57 @@ Section rtc. ...@@ -107,62 +114,57 @@ Section rtc.
Proof. apply bsteps_weaken. lia. Qed. Proof. apply bsteps_weaken. lia. Qed.
Lemma bsteps_trans n m x y z : Lemma bsteps_trans n m x y z :
bsteps R n x y bsteps R m y z bsteps R (n + m) x z. bsteps R n x y bsteps R m y z bsteps R (n + m) x z.
Proof. induction 1; simpl; eauto using bsteps_plus_l with ars. Qed. Proof. induction 1; simpl; eauto using bsteps_plus_l. Qed.
Lemma bsteps_r n x y z : bsteps R n x y R y z bsteps R (S n) x z. Lemma bsteps_r n x y z : bsteps R n x y R y z bsteps R (S n) x z.
Proof. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Lemma bsteps_rtc n x y : bsteps R n x y rtc R x y. Lemma bsteps_rtc n x y : bsteps R n x y rtc R x y.
Proof. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Lemma rtc_bsteps x y : rtc R x y n, bsteps R n x y. Lemma rtc_bsteps x y : rtc R x y n, bsteps R n x y.
Proof. Proof. induction 1; [exists 0; constructor|]. naive_solver eauto. Qed.
induction 1.
* exists 0. constructor.
* naive_solver eauto with ars.
Qed.
Lemma bsteps_ind_r (P : nat A Prop) (x : A) Lemma bsteps_ind_r (P : nat A Prop) (x : A)
(Prefl : n, P n x) (Prefl : n, P n x)
(Pstep : n y z, bsteps R n x y R y z P n y P (S n) z) : (Pstep : n y z, bsteps R n x y R y z P n y P (S n) z) :
n z, bsteps R n x z P n z. n z, bsteps R n x z P n z.
Proof. Proof.
cut ( m y z, bsteps R m y z n, cut ( m y z, bsteps R m y z n,
bsteps R n x y bsteps R n x y ( m', n m' m' n + m P m' y) P (n + m) z).
( m', n m' m' n + m P m' y) { intros help ?. change n with (0 + n). eauto. }
P (n + m) z).
{ intros help ?. change n with (0 + n). eauto with ars. }
induction 1 as [|m x' y z p2 p3 IH]; [by eauto with arith|]. induction 1 as [|m x' y z p2 p3 IH]; [by eauto with arith|].
intros n p1 H. rewrite <-plus_n_Sm. intros n p1 H. rewrite <-plus_n_Sm.
apply (IH (S n)); [by eauto using bsteps_r |]. apply (IH (S n)); [by eauto using bsteps_r |].
intros [|m'] [??]; [lia |]. intros [|m'] [??]; [lia |]. apply Pstep with x'.
apply Pstep with x'.
* apply bsteps_weaken with n; intuition lia. * apply bsteps_weaken with n; intuition lia.
* done. * done.
* apply H; intuition lia. * apply H; intuition lia.
Qed. Qed.
Global Instance tc_trans: Transitive (tc R). Lemma tc_transitive x y z : tc R x y tc R y z tc R x z.
Proof. red; induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Global Instance: Transitive (tc R).
Proof. exact tc_transitive. Qed.
Lemma tc_r x y z : tc R x y R y z tc R x z. Lemma tc_r x y z : tc R x y R y z tc R x z.
Proof. intros. etransitivity; eauto with ars. Qed. Proof. intros. etransitivity; eauto. Qed.
Lemma tc_rtc_l x y z : rtc R x y tc R y z tc R x z.
Proof. induction 1; eauto. Qed.
Lemma tc_rtc_r x y z : tc R x y rtc R y z tc R x z.
Proof. intros Hxy Hyz. revert x Hxy. induction Hyz; eauto using tc_r. Qed.
Lemma tc_rtc x y : tc R x y rtc R x y. Lemma tc_rtc x y : tc R x y rtc R x y.
Proof. induction 1; eauto with ars. Qed. Proof. induction 1; eauto. Qed.
Instance tc_once_subrel: subrelation (tc R) (rtc R). Instance tc_once_subrel: subrelation (tc R) (rtc R).
Proof. exact @tc_rtc. Qed. Proof. exact @tc_rtc. Qed.
Lemma looping_red x : looping R x red R x. Lemma all_loop_red x : all_loop R x red R x.
Proof. destruct 1; auto. Qed. Proof. destruct 1; auto. Qed.
Lemma looping_step x y : looping R x R x y looping R y. Lemma all_loop_step x y : all_loop R x R x y all_loop R y.
Proof. destruct 1; auto. Qed. Proof. destruct 1; auto. Qed.
Lemma looping_rtc x y : looping R x rtc R x y looping R y. Lemma all_loop_rtc x y : all_loop R x rtc R x y all_loop R y.
Proof. induction 2; eauto using looping_step. Qed. Proof. induction 2; eauto using all_loop_step. Qed.
Lemma all_loop_alt x :
Lemma looping_alt x : all_loop R x y, rtc R x y red R y.
looping R x y, rtc R x y red R y.
Proof. Proof.
split. split; [eauto using all_loop_red, all_loop_rtc|].
* eauto using looping_red, looping_rtc. intros H. cut ( z, rtc R x z all_loop R z); [eauto|].
* intros H. cut ( z, rtc R x z looping R z). cofix FIX. constructor; eauto using rtc_r.
{ eauto with ars. }
cofix FIX. constructor; eauto using rtc_r with ars.
Qed. Qed.
End rtc. End rtc.
...@@ -172,9 +174,9 @@ Hint Extern 5 (subrelation _ (rtc _)) => ...@@ -172,9 +174,9 @@ Hint Extern 5 (subrelation _ (rtc _)) =>
Hint Extern 5 (subrelation _ (tc _)) => Hint Extern 5 (subrelation _ (tc _)) =>
eapply @tc_once_subrel : typeclass_instances. eapply @tc_once_subrel : typeclass_instances.
Hint Resolve Hint Constructors rtc nsteps bsteps tc : ars.
rtc_once rtc_r tc_r Hint Resolve rtc_once rtc_r tc_r rtc_transitive tc_rtc_l tc_rtc_r
bsteps_once bsteps_r bsteps_refl bsteps_trans : ars. tc_rtc bsteps_once bsteps_r bsteps_refl bsteps_trans : ars.
(** * Theorems on sub relations *) (** * Theorems on sub relations *)
Section subrel. Section subrel.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment