Rewrite exists-d metafunction and add some tests.
Define leq in terms of lub.