Design a commutative injective function between any (restricted) infinite set and unordered pairs thereof
Haskell, 65 + 30 = 95 bytes



a#b=length.fst$span(&lt;(max a b,min a b))[(a,b)|a&lt;-[1..],b&lt;-[1..a]]


Try it online!

([(a,b)|a&lt;-[1..],b&lt;-[1..a]]!!)


Try it online!



Note: When the two functions may share code, this is only 75 bytes:



(l!!)
a#b=length.fst$span(&lt;(max a b,min a b))l
l=[(a,b)|a&lt;-[1..],b&lt;-[1..a]]


Try it online! The domain is the positive integers. The function (#) performs the pairing, the function (l!!) its inverse. Usage example: Both (#) 5 3 and (#) 3 5 yield 12, and (l!!) 12 yields (5,3).

This works by explicitly listing all sorted pairs in an infinite list l:

l = [(1,1),(2,1),(2,2),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3),(4,4),(5,1),(5,2),(5,3),(5,4),(5,5),(6,1), ...`


The encoding is then just the index in this list.