Instance CompSpecs : compspecs.Definition Vprog : varspecs.Definition makelock_spec := DECLARE _makelock (makelock_spec _).Definition freelock2_spec := DECLARE _freelock2 (freelock2_spec _).Definition acquire_spec := DECLARE _acquire acquire_spec.Definition release2_spec := DECLARE _release2 release2_spec.Definition spawn_spec := DECLARE _spawn spawn_spec.Definition load_acq_spec := DECLARE _load_acq load_acq_spec.(*Definition store_rel_spec := DECLARE _store_rel store_rel_spec'.*)
Definition CAS_RA_spec := DECLARE _CAS_RA CAS_RA_spec.(* One might think it should just return an unknown number, but in fact it needs to follow a known hash
   function at the logic level to be useful. *)

Definition tentry := Tstruct _entry noattr.(* Having size as a large known constant tends to make everything slow, so here's a hack. *)
Definition has_size : {x : Z | x = 16384}.Instance hf1 : hash_fun := { size := proj1_sig has_size; hash i := (i * 654435761) mod (proj1_sig has_size) }.(* The top-level structure we get with release-acquire is a hashtable mapping each key to a history of values
   stored there, where a get_item may get any value at least as late as the last one it saw (or fail if it has never
   succeeded before). However, we can't enforce this with the protocol because of the write-write race on the value;
   each write must move the protocol to a final state, so there can be no history in the transition system. *)

(*(* In order to be able to write to the value, we need to have every non-zero value be a final state. *)
Instance nonzero_PCM : PCM Z := { join a b c := c = 0 -> a = 0 /\ b = 0 }.
Proof.
  - intros; tauto.
  - intros.
    exists e; tauto.
Defined.

Definition nonzero_ord a b := b = 0 -> a = 0.

Instance nonzero_order : PCM_order nonzero_ord.
Proof.
  unfold nonzero_ord; constructor; simpl; intros.
  - intro; auto.
  - intros; auto.
  - exists c; auto.
  - tauto.
  - tauto.
Defined.*)

Definition value_of (m : Z -> option Z) v := exists j, log_latest m j v.

Lemma value_of_0 : value_of (singleton 0 0) 0.