Ltac get_invariant_pre inv :=
    match goal with
      | H : raft_intermediate_reachable _ |- _=>
        match (type of H) with
          | context [mkNetwork] =>
            fail 2
        end || copy_apply inv H
    end.Ltac get_invariant_post inv :=
    match goal with
      | H : raft_intermediate_reachable _ |- _=>
        match (type of H) with
          | context [mkNetwork] =>
            copy_apply inv H            
        end
    end.Definition clientCache_to_ks (c : list (clientId * (nat * output))) :=
    map (fun e => (fst e, fst (snd e))) c.

Lemma handleClientRequest_preserves_lastApplied_entries: forall h (net : network) (d : raft_data) client id c out l, raft_intermediate_reachable net -> handleClientRequest h (nwState net h) client id c = (out, d, l) -> removeAfterIndex (log d) (lastApplied d) = removeAfterIndex (log (nwState net h)) (lastApplied (nwState net h)).