Beginning of comparison functions; ugly soundness proofs