Add external definitions inside the environment.
Fix pretty printing issue on sorts inside terms.