val eac_state_unchanged_snoc
      (#app #n: _)
      (ep: epoch)
      (gk: key app)
      (il: eac_log app n {length il > 0})
    : Lemma
    (ensures
      (let i = length il - 1 in
        let il' = prefix il i in
        let bk = to_base_key gk in
        let es' = eac_state_of_key bk il' in
        let es = eac_state_of_key bk il in
        es' = es ==> (not (is_blum_add_of_key ep gk il i) /\ not (is_blum_evict_of_key ep gk il i)))
    )
val eac_state_unchanged_snoc
      (#app #n: _)
      (ep: epoch)
      (gk: key app)
      (il: eac_log app n {length il > 0})
    : Lemma
    (ensures
      (let i = length il - 1 in
        let il' = prefix il i in
        let bk = to_base_key gk in
        let es' = eac_state_of_key bk il' in
        let es = eac_state_of_key bk il in
        es' = es ==> (not (is_blum_add_of_key ep gk il i) /\ not (is_blum_evict_of_key ep gk il i)))
    )
let eac_state_unchanged_snoc
  (#app #n:_)
  (ep: epoch)
  (gk: key app)
  (il: eac_log app n {length il > 0})
  : Lemma (ensures (let i = length il - 1 in
                    let il' = prefix il i in
                    let bk = to_base_key gk in
                    let es' = eac_state_of_key bk il' in
                    let es = eac_state_of_key bk il in
                    es' = es ==> (not (is_blum_add_of_key ep gk il i) /\
                                  not (is_blum_evict_of_key ep gk il i))))
  = let bk = to_base_key gk in
    eac_state_snoc bk il
module Zeta.High.Blum

open Zeta.High.Verifier
open Zeta.High.Thread
open Zeta.SeqIdx
open FStar.Classical

module V = Zeta.GenericVerifier
module G = Zeta.Generic.Global
module T = Zeta.Generic.Thread
module I = Zeta.Interleave
module MSD = Zeta.MultiSetHashDomain
module HV = Zeta.High.Verifier

let eac_state_transition_snoc
  (#app #n:_)
  (bk: base_key)
  (il: eac_log app n {length il > 0})
  : Lemma (ensures (let i = length il - 1 in
                    let il' = prefix il i in
                    let es' = eac_state_of_key bk il' in
                    let es = eac_state_of_key bk il in
                    let e = index il i in
                    es' <> es ==> (
                    match es', es with
                    | EACInit, EACInStore m gk v ->
                      AddM? e
                    | EACInStore _ gk' _, EACEvictedBlum gk v t tid ->
                      gk' = gk /\ is_blum_evict il i /\
                      to_base_key gk = evict_slot (index il i) /\
                      (let be = blum_evict_elem il i in
                       let gke,ve = be.r in
                       let open Zeta.MultiSetHashDomain in
                       gke = gk /\ ve = v /\ be.t = t /\ be.tid = tid)
                    | EACInStore _ _ _, EACEvictedMerkle _ _ ->
                      EvictM? e
                    | EACEvictedBlum gk v t tid, EACInStore _ gk' _ ->
                      gk = gk' /\ is_blum_add il i /\
                      to_base_key gk = add_slot (index il i) /\
                      (let be = blum_add_elem il i in
                       let open Zeta.MultiSetHashDomain in
                       let gke, ve = be.r in
                       gke = gk /\ ve = v /\ be.t = t /\ be.tid = tid
                      )
                    | EACEvictedMerkle _ _, EACInStore _ _ _ ->
                      AddM? e
                    | EACInStore _ _ _, EACInStore _ _ _ ->
                      RunApp? e
                    | _ -> False)))
  = let i = length il - 1 in
    let il' = prefix il i in
    let es' = eac_state_of_key bk il' in
    let es = eac_state_of_key bk il in
    let ee = mk_vlog_entry_ext il i in
    let e = index il i in
    let tid = src il i in
    let st_pre = thread_store_pre tid il i in
    eac_state_snoc bk il;
    if es = es' then ()
    else
    (
      assert(es <> EACFail);
      assert(es = eac_add ee es');
      match es' with
      | EACInStore _ gk' _ -> (
        match ee with
        | EvictBlum e v_e tid_e ->
          ext_evict_val_is_stored_val il i;
          key_in_unique_store bk il' tid (stored_tid bk il')
        | _ ->  ()
      )
      | EACEvictedBlum _ _ _ _ ->
        // TODO: never seen this; fails with assert commented
        assert(match es', es with EACEvictedBlum gk v t tid, EACInStore _ gk' _ -> True);
        ()
      | _ -> ()
    )
/
Zeta.SeqIdx.fsti.checked Zeta.SeqAux.fsti.checked Zeta.MultiSetHashDomain.fsti.checked Zeta.Interleave.fsti.checked Zeta.High.Verifier.fsti.checked Zeta.High.Thread.fsti.checked Zeta.GenericVerifier.fsti.checked Zeta.Generic.TSLog.fsti.checked Zeta.Generic.Thread.fsti.checked Zeta.Generic.Global.fsti.checked prims.fst.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.Classical.fsti.checked
Zeta.High.Blum.fst

    ep: Zeta.Time.epoch ->
    gk: Zeta.GenKey.key app ->
    il: Zeta.High.Interleave.eac_log app n {Zeta.Generic.Interleave.length il > 0}
  -> FStar.Pervasives.Lemma
    (ensures
      (let i = Zeta.Generic.Interleave.length il - 1 in
        let il' = Zeta.Generic.Interleave.prefix il i in
        let bk = Zeta.GenKey.to_base_key gk in
        let es' = Zeta.High.Interleave.eac_state_of_key bk il' in
        let es = Zeta.High.Interleave.eac_state_of_key bk il in
        es' = es ==>
        Prims.op_Negation (Zeta.Generic.Blum.is_blum_add_of_key ep gk il i) /\
        Prims.op_Negation (Zeta.Generic.Blum.is_blum_evict_of_key ep gk il i)))
Zeta.App.app_params Prims.pos Zeta.Time.epoch Zeta.GenKey.key Zeta.High.Interleave.eac_log Prims.b2t Prims.op_GreaterThan Zeta.Generic.Interleave.length Zeta.High.Verifier.high_verifier_spec Zeta.High.Interleave.eac_state_snoc Zeta.Key.base_key Zeta.GenKey.to_base_key Prims.unit Prims.l_True Prims.squash Prims.l_imp Prims.op_Equality Zeta.EAC.eac_state Prims.l_and Prims.op_Negation Zeta.Generic.Blum.is_blum_add_of_key Zeta.Generic.Blum.is_blum_evict_of_key Zeta.High.Interleave.eac_state_of_key Zeta.Generic.Interleave.verifiable_log Prims.nat Zeta.Generic.Interleave.prefix Prims.int Prims.op_Subtraction Prims.Nil FStar.Pervasives.pattern
let eac_state_unchanged_snoc
      (#app #n: _)
      (ep: epoch)
      (gk: key app)
      (il: eac_log app n {length il > 0})
    : Lemma
    (ensures
      (let i = length il - 1 in
        let il' = prefix il i in
        let bk = to_base_key gk in
        let es' = eac_state_of_key bk il' in
        let es = eac_state_of_key bk il in
        es' = es ==> (not (is_blum_add_of_key ep gk il i) /\ not (is_blum_evict_of_key ep gk il i)))
    ) =
  
let bk = to_base_key gk in
eac_state_snoc bk il