Golf a bijection within the natural numbers which map the primes to a proper subset of the primes Definitions


A bijection from a set S to a set T is a function from S to T such that one element in T is mapped by exactly one element in S.
A bijection within a set S is a bijection from S to S.
The natural numbers are the integers which are greater than or equal to 0.
A subset of a set S is a set such that every element in the set is also in S.
A proper subset of a set S is a set that is a subset of S which is not equal to S.


Task

Write a program/function that takes a natural number as input and outputs a natural number. It must be a bijection, and the image of the primes under the program/function, {f(p) : p ∈ ℙ}, must be a proper subset of ℙ, where ℙ is the prime numbers.

Scoring

This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.
Mathematica, 54 48 bytes

±(t=x_?PrimeQ)=NextPrime@x
±n_:=Abs[n-1]/.t:&gt;x-1


Defines the following bijection:

 n  0, 1, 2, 3, 4, 5, 6,  7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ...
±n  1, 0, 3, 5, 2, 7, 4, 11, 6, 8,  9, 13, 10, 17, 12, 14, 15, 19, ...


The basic idea is to map each prime to the next, to ensure that they are mapped to a proper subset. This results in a "gap" at 2. To fill that gap, we want to map 4 to 2 and then each other composite number to the previous composite number, to "bubble up" the gap. Since 2 and 3 are the only two adjacent primes, we can express both of those mappings as "n-1 or if that's a prime then n-2". Finally, this mapping ends up sending 1 to 0 and we make it send 0 back to 1 by taking the absolute value of n-1.