(** * Lemmas about the Dry Machine*)
From mathcomp.ssreflect Require Import ssreflect ssrbool ssrnat seq ssrfun eqtype fintype finfun.
Set Implicit Arguments.
(*NOTE: because of redefinition of [val], these imports must appear after Ssreflect eqtype.*)
(* Require Import compcert.common.Events. *)
Global Notation "a # b" := (Maps.PMap.get b a) (at level 1).
(** This file holds various results about the dry machine*)
(* Find other lemmas in dry_machine_step_lemmas.v        *)
Module ThreadPoolWF.
Section ThreadPoolWF.
Context {Sem : Semantics}.
Existing Instance DryHybridMachine.dryResources.
Existing Instance OrdinalPool.OrdinalThreadPool.
(** Take an instance of the Dry Machine *)
Existing Instance DryHybridMachine.DryHybridMachineSig.

Lemma updThread_inv: forall ds i (cnt: containsThread ds i) c pmap,
invariant ds ->
(forall j (cnt: containsThread ds j),
i<>j -> permMapsDisjoint pmap.1 (getThreadR cnt).1 /\
permMapsDisjoint pmap.2 (getThreadR cnt).2) ->
(forall j (cnt: containsThread ds j),
i<>j ->
permMapCoherence (getThreadR cnt).1 pmap.2)->
(forall j (cnt: containsThread ds j),
i<>j ->
permMapCoherence pmap.1 (getThreadR cnt).2)->
(forall l pmap0, lockRes ds l = Some pmap0 ->
permMapsDisjoint pmap0.1 pmap.1 /\
permMapsDisjoint pmap0.2 pmap.2  ) ->
(forall l pmap0, lockRes ds l = Some pmap0 ->
permMapCoherence pmap0.1 pmap.2 /\
permMapCoherence pmap.1 pmap0.2) ->
(permMapCoherence pmap#1 pmap#2) ->
invariant (updThread cnt c pmap).