(** 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 lock permissions by: - Spawning a thread - A freelock operation, turning a lock into data - Releasing a lock *)
Lemma lock_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).2 !! b ofs) (Some Readable))
(Hperm': ~ Mem.perm_order'' ((getThreadR cnt').2 !! 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 = Freelock /\
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.2 !! b ofs) (Some Readable)
| None => False
end).