Theory of melting in two dimensions