Definition serialize_input (i : VarD.input) :=
match i with
| Put k v => serialize x00 +$+ serialize k +$+ serialize v
| Get k => serialize x01 +$+ serialize k
| Del k => serialize x02 +$+ serialize k
| CAS k opt v => serialize x03 +$+ serialize k +$+ serialize opt +$+ serialize v
| CAD k v => serialize x04 +$+ serialize k +$+ serialize v
end.
Definition deserialize_input : ByteListReader.t VarD.input :=
tag <- deserialize;;
match tag with
| x00 =>
k <- deserialize;;
v <- deserialize;;
ByteListReader.ret (Put k v)
| x01 => Get <$> deserialize
| x02 => Del <$> deserialize
| x03 =>
k <- deserialize;;
opt <- deserialize;;
v <- deserialize;;
ByteListReader.ret (CAS k opt v)
| x04 =>
k <- deserialize;;
v <- deserialize;;
ByteListReader.ret (CAD k v)
| _ => ByteListReader.error
end.

(* Specifications: *)
Lemma input_serialize_deserialize_id :
serialize_deserialize_id_spec serialize_input deserialize_input.