Library mcertikos.ticketlog.QTicketLockGenLink

Require Import LinkTemplate.
Require Import MQTicketLock.
Require Import QTicketLockGen.
Require Import QTicketLockGenLinkSource.
Require Import MHTicketLockOp.
Require Import QTicketLockGenAsmSource.
Require Import QTicketLockGenAsm.

Section WITHCOMPCERTIKOS.
  Context `{compcertikos_prf: CompCertiKOS} `{real_params_prf: RealParams}.
  Context `{multi_oracle_prop: MultiOracleProp}.

  Lemma init_correct:
    init_correct_type MQTicketLock_module mhticketlockop mqticketlock.
  Proof.
    init_correct.
  Qed.

  Lemma link_correct_aux:
    link_correct_aux_type MQTicketLock_module mhticketlockop mqticketlock.
  Proof.
    unfold link_correct_aux_type. intros M HM.
    inv_link_impl HM. subst.
    eapply conseq_le_assoc_comm.
    hcomp_tac; [| link_correct_aux_passthrough].
    LinkTactic.transfer_variables.
    unfold_layer mqticketlock_fresh.
    apply LayerLogicImpl.vdash_oplus_empty_left.
    layer_link_split_tac.
    - link_asmfunction release_lock_spec_ref release_lock_code_correct.
    - link_asmfunction acquire_lock_spec_ref acquire_lock_code_correct.
    - apply passthrough_correct.
  Qed.

  Theorem cl_backward_simulation:
    cl_backward_simulation_type MQTicketLock_module mhticketlockop mqticketlock.
  Proof.
    cl_backward_simulation init_correct link_correct_aux.
  Qed.

  Theorem make_program_exists:
    make_program_exist_type MQTicketLock_module mhticketlockop mqticketlock.
  Proof.
    make_program_exists link_correct_aux.
  Qed.

End WITHCOMPCERTIKOS.