Module ZOrder <: Orders.TotalLeBool.
Definition t := Z.
Definition leb x y := Z.leb x y.
Notation sorted := (StronglySorted Z.le).
Inductive set_op := Add (e : Z) | Remove (e : Z).
Fixpoint apply_hist S h :=
match h with
| [] => S
| Add e :: h' => if in_dec Z_eq_dec e S then apply_hist S h' else apply_hist (sort (e :: S)) h'
| Remove e :: h' => apply_hist (remove Z_eq_dec e S) h'
end.

Lemma remove_sorted : forall a l, sorted l -> sorted (remove Z_eq_dec a l).