(** or it wasn't and the operation denoted by the event implies the permission*)
(** *** Properties about permission decay and events *)

(** Lifting [data_permission_decrease_step] to multiple steps using [multi_step] *)
Lemma data_permission_decrease_execution:
forall U tr tpi mi U' tr' tpj mj
b ofs tidn
(cnti: containsThread tpi tidn)
(cntj: containsThread tpj tidn)
(Hexec: multi_step (U, tr, tpi) mi (U', tr ++ tr', tpj) mj)
(Hperm: Mem.perm_order'' ((getThreadR cnti).1 !! b ofs) (Some Readable))
(Hperm: ~ Mem.perm_order'' ((getThreadR cntj).1 !! b ofs) (Some Readable)),
exists tr_pre tru U'' U''' tp_pre m_pre tp_dec m_dec,
multi_step (U, tr, tpi) mi (U'', tr ++ tr_pre, tp_pre) m_pre /\
MachStep (U'', tr ++ tr_pre, tp_pre) m_pre
(U''', tr ++ tr_pre ++ tru, tp_dec) m_dec /\
multi_step (U''', tr ++ tr_pre ++ tru, tp_dec) m_dec
(U', tr ++ tr',tpj) mj /\
(exists evu,
(List.In evu tru /\ action evu = Free /\ deadLocation tpj mj b ofs) \/
(tru = [:: evu] /\ action evu = Spawn) \/
(tru = [:: evu] /\ action evu = Mklock /\ thread_id evu = tidn /\
match location evu with
| Some (addr, sz) =>
b = addr.1 /\
Intv.In ofs (addr.2, addr.2 + (Z.of_nat sz))%Z
| None => False
end) \/
(tru = [:: evu] /\ action evu = Release /\ thread_id evu = tidn /\
(exists rmap, match location evu with
| Some (laddr, sz) =>
sz = lksize.LKSIZE_nat /\
lockRes tp_dec laddr = Some rmap /\
Mem.perm_order'' (rmap.1 !! b ofs) (Some Readable)
| None => False
end))).