Show that P and NP are closed under Kleene star. I found possible solutions to these problems, more specifically:
- P - finding all subwords from a giving word and looking if there is a connection between them (idea: https://louis.jachiet.com/lfcc/final_solutions.pdf)
- NP - non-deterministically dividing word for m subwords and looking if all of them will be accepted (idea: https://homes.cs.aau.dk/~srba/courses/tutorials-CC-10/t13-sol.pdf)
but i still miss why it works. I mean, the idea of P seems clear to me, but things get complicated with NP. Suppose one of the subswords was rejected by TM M1, so the entire program will return rejection. But it is fully dependent on our nondeterministic choice of m (and nondeterministic division!). Why can't we try to select a different m and try to restart it? Probably because if we try to change m too many times, our algorithm to check if our input word w is in L* will cease to be verifiable in polynomial time. At the same time, it seems very incomprehensible to me that we will reject a word that is, maybe, in L*, because m was not the good one. Also, I'm not sure why we can't use the same idea of checking P in NP. Is it because in the proof P we run TM M1 on the subword and check if it is rejected or accepted (so we run a program that decides in polynomial time), but in the proof NP we run TM M2 which checks only, does the word belong to L?