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

(** Permission decrease: A thread can decrease its data permissions by: - Freeing memory. - Spawning a thread - A makelock operation, turning data into lock - Releasing a lock *)
Lemma data_permission_decrease_step:
forall U tr tp m U' tp' m' tr' tidn b ofs
(cnt: containsThread tp tidn)
(cnt': containsThread tp' tidn)
(Hstep: MachStep (U, tr, tp) m (U', tr ++ tr', tp') m')
(Hperm: Mem.perm_order'' ((getThreadR cnt).1 !! b ofs) (Some Readable))
(Hperm': ~ Mem.perm_order'' ((getThreadR cnt').1 !! b ofs) (Some Readable)),
exists ev,
(List.In ev tr' /\ action ev = Free /\ deadLocation tp' m' b ofs) \/
(tr' = [:: ev] /\ action ev = Spawn) \/
(tr' = [:: ev] /\ action ev = Mklock /\
thread_id ev = tidn /\
match location ev with
| Some (addr, sz) =>
b = addr.1 /\
Intv.In ofs (addr.2, addr.2 + (Z.of_nat sz))%Z
| None =>
False
end) \/
(tr' = [:: ev] /\ action ev = Release /\ thread_id ev = tidn /\
exists rmap, match location ev with
| Some (laddr, sz) =>
sz = lksize.LKSIZE_nat /\
lockRes tp' laddr = Some rmap /\
Mem.perm_order'' (rmap.1 !! b ofs) (Some Readable)
| None => False
end).