Definition hists_mono (h1 h2 : list (hist * hist)) := Forall2 (fun a b =>
(exists l, fst b = fst a ++ l) /\ (exists l, snd b = snd a ++ l)) h1 h2.
Instance hists_mono_refl : RelationClasses.Reflexive hists_mono.
Hint Resolve hists_mono_refl.
Instance hists_mono_trans : RelationClasses.Transitive hists_mono.

Lemma only_one_add_succeeds : forall lr keys th1 th2 k v1 v2 i1 i2
(Hadd : Forall (fun '(la, h) => add_items_trace empty_hists la h) lr)
(Hfullk : Forall2 full_hist' (map fst (fold_right join_hists empty_hists (map snd lr))) (map (fun x => vint x) keys))
(Hkeys : Forall2 (fun h v => forall t e, In (t, e) h -> value_of e <> vint 0 -> vint v = value_of e)
(map fst (fold_right join_hists empty_hists (map snd lr))) keys)
(Hrepk : Forall repable_signed keys)
(Hnzk : Forall (fun x => Forall (fun x => let '(k, _, _, _) := x in k <> 0 /\ repable_signed k) (fst x)) lr)
(Hsucc1 : In (k, v1, i1, true) (fst (Znth th1 lr ([], []))))
(Hsucc2 : In (k, v2, i2, true) (fst (Znth th2 lr ([], [])))),
th1 = th2 /\ i1 = i2.