Skip to content

Commit a7f4827

Browse files
committed
feat: prepare for RA consistency
1 parent caeb845 commit a7f4827

5 files changed

Lines changed: 76 additions & 41 deletions

File tree

eventstructure.v

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
From Coq Require Import Relations Relation_Operators.
2-
From RelationAlgebra Require Import lattice rel kat_tac.
2+
From RelationAlgebra Require Import lattice monoid rel kat_tac rel.
33
From mathcomp Require Import ssreflect ssrfun ssrbool ssrnat seq path.
44
From mathcomp Require Import eqtype choice order finmap fintype.
55
From event_struct Require Import utilities relations wftype ident.
@@ -38,6 +38,7 @@ From event_struct Require Import utilities relations wftype ident.
3838

3939
Import Order.LTheory.
4040
Open Scope order_scope.
41+
Local Open Scope ra_terms.
4142
Import WfClosure.
4243

4344
Set Implicit Arguments.
@@ -567,26 +568,70 @@ Qed.
567568
(* Writes-Before relation *)
568569
(* ************************************************************************* *)
569570

570-
Definition sca_suffix : E -> seq E := suffix (fica_lt).
571-
572-
Definition contr_loc f : E -> seq E :=
573-
fun e => (f ∘ (same_loc (lab e) \o lab)ᶠ) e.
574-
575-
Definition contr_wrire f : E -> seq E :=
576-
(is_write \o lab)ᶠ ∘ f ∘ (is_write \o lab)ᶠ.
577-
578-
Definition frf_inv : E -> seq E :=
579-
fun e => [seq x <- dom | frf x == e].
580-
581-
(* wb := [W] ; (po ∪ rf)⁺ |loc ; [W] ∪ [W]; (po ∪ rf)⁺ ; rf⁻ ; [W] \ id *)
582-
583-
Definition fwb : {fsfun E -> seq E with [::]} :=
584-
[fsfun x in (seq_fset tt dom) =>
585-
(
586-
contr_wrire (contr_loc sca_suffix)
587-
588-
strictify (contr_wrire (frf_inv ∘ (contr_loc sca_suffix)))
589-
) x].
571+
Definition sca : hrel E E := (ca : hrel E E) ∩ (fun x y => x <> y).
572+
573+
Definition rf_inv : hrel E E := fun x y => frf x = y.
574+
575+
Definition wb1 : hrel E E := fun e1 e2 =>
576+
(
577+
((same_loc (lab e1) (lab e2)) *
578+
(is_write (lab e1))) *
579+
((is_write (lab e2)) *
580+
((sca e1 e2)))
581+
)%type.
582+
583+
Definition wb2 : hrel E E := fun e1 e2 =>
584+
(
585+
((same_loc (lab e1) (lab e2)) *
586+
(is_write (lab e1))) *
587+
((is_write (lab e2)) *
588+
(((hrel_dot _ _ _ sca rf_inv) e1 e2) * (e1 <> e2)))
589+
)%type.
590+
591+
(* wb := [W] ; (po ∪ rf)⁺ |loc ; [W] ∪ [W]; (po ∪ rf)⁺ |loc ; rf⁻ ; [W] \ id *)
592+
593+
Definition wb := wb1 ⊔ wb2.
594+
595+
Definition rwb1 e1 e2 :=
596+
(
597+
((same_loc (lab e1) (lab e2)) *
598+
(is_read (lab e1))) *
599+
((is_read (lab e2)) *
600+
((frf e1) <> (frf e2))) *
601+
(sca (frf e1) e2)
602+
)%type.
603+
604+
Definition rwb2 e1 e2 :=
605+
(
606+
((same_loc (lab e1) (lab e2)) *
607+
(is_read (lab e1))) *
608+
((is_read (lab e2)) *
609+
((wb1 ⋅ sca) (frf e1) e2))
610+
)%type.
611+
612+
Definition rwb : hrel E E := rwb1 ⊔ rwb2.
613+
614+
Lemma wb_rbw :
615+
(exists x, wb^* x x) <->
616+
exists x, rwb^* x x.
617+
Proof. Admitted.
618+
619+
Definition frwb : {fsfun E -> seq E with [::]}. Admitted.
620+
621+
Lemma frwbP e1 e2:
622+
reflect (rwb e1 e2) (e2 \in frwb e1).
623+
Proof. Admitted.
624+
625+
Definition seq_contr (f : E -> seq E) (xs : seq E): {fsfun E -> seq E with [::]} :=
626+
[fsfun x in seq_fset tt dom => [seq y <- f x | y \in xs]] .
627+
628+
Export FinClosure.
629+
630+
Definition fwb_cf (rs : seq E) :=
631+
if rs is r :: _ then
632+
(t_closure (seq_contr frwb rs) r r) ||
633+
(~~ allrel (fun e1 e2 => ~~ e1 # e2) rs rs)
634+
else false.
590635

591636

592637
End ExecEventStructure.

memory_model.v

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,4 @@ End GeneralDef.
3939

4040
Export FinClosure.
4141

42-
Definition ra_consist (es : cexec_event_struct):=
43-
all (fun x => x \notin t_closure (fwb es) x) (dom es).
44-
4542
End MMConsist.

regmachine.v

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,9 @@ Definition eval_step (c : config) pr : seq config :=
238238
let: tid := if pr \in dom ces then tid else fresh_tid c in
239239
let: (l, cont_st) := thrd_sem (nth empty_prog prog tid) conf in
240240
if l is Some l then do
241-
<<<<<<< HEAD
242-
(e, v) <- add_hole ces l pr;
243-
[:: Config e [fsfun c with (fresh_seq (dom ces)) |-> (cont_st v, tid)]]
244-
=======
245-
ev <- add_hole l pr : M _;
241+
ev <- add_hole ces l pr : M _;
246242
let '(e, v) := ev in
247-
[:: Config e [fsfun c with fresh_id |-> (cont_st v, tid)]]
248-
>>>>>>> 01e861d77835d84e8e68fa729a27cee3c3d06ebb
243+
[:: Config e [fsfun c with (fresh_seq (dom ces)) |-> (cont_st v, tid)]]
249244
else
250245
[:: Config ces [fsfun c with pr |-> (cont_st inh, tid)]].
251246

relations.v

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ From Coq Require Import Relations Relation_Operators.
22
From RelationAlgebra Require Import lattice monoid rel kat_tac.
33
From mathcomp Require Import ssreflect ssrbool ssrfun eqtype seq order choice.
44
From mathcomp Require Import finmap fingraph fintype finfun ssrnat path.
5+
From monae Require Import hierarchy monad_model.
56
From Equations Require Import Equations.
67
From event_struct Require Import utilities wftype monad.
78

@@ -38,6 +39,9 @@ Set Equations Transparent.
3839
Import Order.LTheory.
3940
Local Open Scope order_scope.
4041
Local Open Scope ra_terms.
42+
Open Scope monae.
43+
44+
Local Notation M := ModelMonad.ListMonad.t.
4145

4246
Definition sfrel {T : eqType} (f : T -> seq T) : rel T :=
4347
[rel a b | a \in f b].
@@ -362,10 +366,9 @@ End FinClosure.
362366
Section Operations.
363367

364368
Context {T : Type}.
365-
Variables (f g : T -> seq T) (p : pred T).
369+
Variables (f g : T -> M T) (p : pred T).
366370

367-
Definition composition :=
368-
fun x => do y <- g x; f y.
371+
Definition composition := g >=> f.
369372

370373
Definition fun_of_pred :=
371374
fun x => if p x then [:: x] else [::].
@@ -375,9 +378,9 @@ Definition funion :=
375378

376379
End Operations.
377380

378-
Notation "p 'ᶠ'" := (fun_of_pred p) (at level 10).
381+
(*Notation "p 'ᶠ'" := (fun_of_pred p) (at level 10).
379382
Notation "f ∘ g" := (composition f g) (at level 100, right associativity).
380-
Notation "f ∪ g" := (funion f g) (at level 100).
383+
Notation "f ∪ g" := (funion f g) (at level 100).*)
381384

382385

383386

utilities.v

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,6 @@ Qed.
381381

382382
End ReflectConnectives.
383383

384-
<<<<<<< HEAD
385-
Notation "'do' i <- s ; E" := (flatten (map (fun i => E) s)) (at level 100, i pattern).
386-
387-
=======
388-
>>>>>>> 01e861d77835d84e8e68fa729a27cee3c3d06ebb
389384
Section RelationOnSeq.
390385

391386
Lemma rfoldl {A B C D} (r : A -> C -> bool) (r' : B -> D -> bool)

0 commit comments

Comments
 (0)