(** Actions that require a [Readable] permission*)
Inductive raction ev : Prop :=
| read: action ev = Read ->
raction ev
| acq: action ev = Acquire ->
raction ev
| rel: action ev = Release ->
raction ev
| facq: action ev = Failacq ->
raction ev.
(** Actions that require a [Writable] permission*)
Inductive waction ev : Prop:=
| write: action ev = Write ->
waction ev
| mk: action ev = Mklock ->
waction ev
| fl: action ev = Freelock ->
waction ev.

Lemma fstep_ev_perm:
forall U tr tp m U' tr_pre tr_post tp' m' ev
(Hstep: fstep (U, tr, tp) m (U', tr ++ tr_pre ++ [:: ev] ++ tr_post , tp') m'),
(waction ev ->
forall (cnt: containsThread tp (thread_id ev)) (cnt': containsThread tp' (thread_id ev)),
match location ev with
| Some (b, ofs, sz) =>
forall ofs', Intv.In ofs' (ofs, ofs + Z.of_nat sz)%Z ->
(Mem.valid_block m b ->
Mem.perm_order'' ((getThreadR cnt).1 !! b ofs') (Some Writable) \/
Mem.perm_order'' ((getThreadR cnt).2 !! b ofs') (Some Writable)) /\
((Mem.perm_order'' ((getThreadR cnt').1 !! b ofs') (Some Writable) \/
Mem.perm_order'' ((getThreadR cnt').2 !! b ofs') (Some Writable)) \/
deadLocation tp' m' b ofs')
| None => False
end) /\
(caction ev ->
forall (cnt: containsThread tp (thread_id ev)) (cnt': containsThread tp' (thread_id ev)),
match location ev with
| Some (b, ofs, sz) =>
forall ofs', Intv.In ofs' (ofs, ofs + Z.of_nat sz)%Z ->
(Mem.valid_block m b ->
Mem.perm_order'' ((getThreadR cnt).1 !! b ofs') (Some Readable) \/
Mem.perm_order'' ((getThreadR cnt).2 !! b ofs') (Some Readable)) /\
((Mem.perm_order'' ((getThreadR cnt').1 !! b ofs') (Some Readable) \/
Mem.perm_order'' ((getThreadR cnt').2 !! b ofs') (Some Readable)) \/
(tr_pre = [::] /\ tr_post = [::] /\ action ev = Release /\
(exists rmap, sz = lksize.LKSIZE_nat /\
lockRes tp' (b, ofs) = Some rmap /\
(Mem.perm_order'' (rmap.1 !! b ofs') (Some Readable) \/
Mem.perm_order'' (rmap.2 !! b ofs') (Some Readable)))) \/
deadLocation tp' m' b ofs')
| None => False
end).