Set Bullet Behavior "Strict Subproofs".
Opaque upto.

(* The relationship between the last_taken array and the shares held by the writer is preserved by the action of the loop body. *)
Lemma upd_write_shares : forall bufs b b0 lgood lasts shs sh0 (Hb : 0 <= b < B) (Hb0 : 0 <= b0 < B)
(Hlasts : Forall (fun x : Z => 0 <= x < B) lasts) (Hshs : Zlength shs = N)
(Hread : Forall readable_share shs) (Hsh0 : sepalg_list.list_join sh0 shs Tsh)
(Hdiff : b <> b0) (Hout : ~ In b lasts) (Hout0 : ~ In b0 lasts) (Hlasts : Zlength lasts = N)
(Hlgood : Zlength lgood = N) i (Hh' : 0 <= i < N) good (Hgood : good = Znth i lgood false)
b' (Hb' : good = true -> -1 <= b' < B) sh (Hsh : sh = Znth i shs Tsh)
shi (Hshi : sepalg_list.list_join sh0
(map snd (filter fst (sublist (i + 1) N (combine lgood shs)))) shi)
bsh (Hbsh : sepalg_list.list_join shi
(map snd (if good then [(good, sh)] else [])) bsh)
h' (Hh' : Zlength h' = i) lasts' (Hlasts' : lasts' = map (fun i =>
if eq_dec (Znth i h' Vundef) Empty then b0 else Znth i lasts 0) (upto 3))
lasts'' (Hlasts'' : lasts'' = map (fun i =>
if eq_dec (Znth i (h' ++ [vint b']) Vundef) Empty then b0 else Znth i lasts 0) (upto 3)) vb,
(if good then EX v : _, data_at sh tbuffer (Vint v)
(Znth (if eq_dec b' (-1) then Znth i lasts 0 else b0) bufs Vundef)
else emp) *
(data_at shi tbuffer (Vint vb) (Znth b bufs Vundef) *
fold_right sepcon emp (upd_Znth b (map (fun a => EX sh2 : share,
!! (if eq_dec a b0 then sepalg_list.list_join sh0
(make_shares shs (combine lgood (sublist 0 i lasts')) a) sh2
else if eq_dec a b then sepalg_list.list_join sh0
(map snd (filter fst (sublist i N (combine lgood shs)))) sh2
else sepalg_list.list_join sh0
(make_shares shs (combine lgood lasts') a) sh2) &&
(EX v : _, data_at sh2 tbuffer (Vint v) (Znth a bufs Vundef))) (upto 5)) emp))
|-- fold_right sepcon emp (map (fun a => EX sh2 : share,
!! (if eq_dec a b0 then sepalg_list.list_join sh0
(make_shares shs (combine lgood (sublist 0 (i + 1) lasts'')) a) sh2
else if eq_dec a b then sepalg_list.list_join sh0
(map snd (filter fst (sublist (i + 1) N (combine lgood shs)))) sh2
else sepalg_list.list_join sh0
(make_shares shs (combine lgood lasts'') a) sh2) &&
(EX v : _, data_at sh2 tbuffer (Vint v) (Znth a bufs Vundef))) (upto 5)).