A tricky P=NP problem
You are asked to prove: There is a language X which is in P, such that the language π(X) is NP complete. Because in this case, since P is closed under the operation π, π(X) is also in P, which means P = NP. The idea is: Define a language X, which consists of strings that are YES-instances of an NP-complete problem, followed by an oracle that proves the instance is a YES-instance. The details are a bit tricky.

Define an encoding of instances of the travelling salesman problem: The encoding starts with the number n of cities in decimal notation, a comma, the number K which is the maximum length of a tour, an opening bracket, n * (n-1) / 2 distances in decimal notation, separated by commas if there is more than one distance, and a closing bracket. It is easy to determine that a string is such an encoding of a TSP instance. 

We define the language L as follows: Each string in L consists of the encoding of a TSP instance with answer "YES", followed by hyphen characters "-" to exactly double the length of the string so far, followed by a permutation of the numbers 1 to n in decimal notation, separated by commas, such that starting at town 1, then visiting towns in the given order, produces a cyclic tour with length at most K. 

The language L is clearly in P. The language π(L) consists of strings that are the encoding of a YES-instance of TSP, followed by some number of hyphens, and if there are enough hyphens, part or whole of an oracle. Because the oracle is much shorter than the encoded instance, π(L) contains some strings that are just encoded TSP instances, followed by hyphens. But for these strings, deciding that they are in π(L) is hard, as hard as deciding that an ordinary instance of TSP is a YES-instance. So π(L) is NP-complete.

And if π(L) is also in P as assumed, then P = NP.