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

(** Permission increase: A thread can increase its lock permissions on a valid block by: - If it is spawned - A freelock operation, turning a lock into data. - Acquiring a lock *)
Lemma lock_permission_increase_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))
(Hvalid: Mem.valid_block m b),
exists ev,
(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 = Acquire /\ 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).