Hilbert's binary Hotel In this challenge you will be asked to implement any function (or full program) that fulfills two properties.  Those properties are:


Your function must be an injective (reversible) function from the polynomials with non-negative integer coeffecients to the non-negative integers.  This means no two unequal inputs can map to an equal output.
Your function must preserve the total number of "on bits" from its input to its output.  This means if you count the 1 bits of each coefficient of the polynomial, their sum should be the same as the number of 1 bits in the binary representation of the output.  For example 9 is 1001 in binary so it has 2 1 bits.




IO

A non-negative integer polynomial is the same as a infinite list of non-negative integers such that after a certain point all the integers are zero.  Thus, polynomials may be represented either by infinite lists (although this is probably undesirable) or by finite lists with implicit zeros after the end of the list.

The key distinction between polynomials and finite lists is that adding a zero to the end of a list will change the list:



While adding a zero to the end of a polynomial does not change its value:



Thus if your function takes a finite list representing a polynomial as input, adding a zero must not change its result.

When representing polynomials as lists, you may represent them either with the first or last entry representing the constant term.  For example you could have either of the following possibilities:



In the first case, adding zeros to the end of the list should not change the result; in the second case, adding zeros to the front of the list should not change the result.

Of course if your language supports polynomials you may take those as inputs.

Output should be a non-negative integer output via any standard methods.



This is code-golf so answers will be scored in bytes, with fewer bytes being better.
Jelly, 8 bytes

BFṢḄæ«ÆẸ


Try it online!

Left inverse, 5 bytes

Bċ0ÆE


Try it online!

How it works

BFṢḄæ«ÆẸ  Main link. Argument: A (array)

B         Binary; convert each integer in A to base 2.
 F        Flatten; concatenate the resulting binary arrays.
  Ṣ       Sort the resulting bit array.
   Ḅ      Convert from base 2 to integer, yielding an integer x with as much set
          bits as there are set bits in A.
      ÆẸ  Unexponents; convert A = [a1, a2, ...] to y = (p1**a1 + p2**a2 + ...),
          where pn is the n-th prime number.
          By the fundamental theorem of arithmetic, the resulting integer is unique
          for each array A without trailing zeroes.
    æ«    Bitshift left; compute x * 2**y.