complexity theory – What is wrong with this argument that if A is NP Complete, but B is in P, then AB is NP Complete and BA is NP Complete as well?

The following seems to me to be relevant to this question, but to me is an interesting exercise, especially since I have not formally worked with complexity before, but I want to learn more:

Suppose that A is NP Complete, but B is in P. I claim that AB is NP Complete and BA is NP Complete as well. To see this, assume first that AB is in P, and let X and Y be polynomial time algorithms for B and for AB, respectively. “Concatenating” X and Y as follows yields an algorithm Z for A:

Given L, test L using X;
if X outputs “yes”, test using Y;
if Y yields “yes”, output “no” and stop;
if X yields “no”, output “no” and stop; output “yes” otherwise and stop.

This algorithm Z runs in polynomial time, because if the (polynomial time) complexity exponent of X is k and the (polynomial time) complexity exponent of Y is n, then this algorithm clearly has (polynomial time) complexity exponent m=max(k,n). This would provide a proof that P=NP, so AB is NP Complete.

Now suppose that BA is in P. This time, let Y’ be a polynomial time algorithm for BA and let X be as above. We construct an algorithm Z’ for A, as follows:

Given L, test L using X;
if X outputs “yes”, test using Y’;
if Y yields “no”, output “yes” and stop;
if X yields “no”, test using Y’; if Y yields “no”, output “yes” and stop;
output “no” otherwise and stop.

This yields a polynomial time algorithm for A, and so again, this would entail that P=NP, so BA also is NP Complete.

+++++++++End of Example++++++++++++

While I don’t see anything wrong with the above at the moment, perhaps I have a mistake or complexity miscalculation? …because for a while as I was writing the second algorithm, I began to think it was odd and perhaps impossible that I can be right about BA also being NP Complete…

Like I said, I’m somewhat new to this area, so feedback would be appreciated.

how to play again if there is wrong input/error

I’m working on my project called Tictactoe. It is working great. So to play the game there is a function call play which takes pair of ints and decide where to play, while there’s another function playO or playX which plays the game using those pair of ints returned by the play function. But if user input on the same move which is already filled, it play that move again. But I want something else, I want that if user move on already filled spot, it should throw error saying “Already filled, input again” and again it take inputs. I can’t post full code but basically there are 3 classes : Game, Player and AIPlayer.
Well if you want the driver code also, I can post that too

Game class :-

class Game{
  vector<vector<char>> board;
public:
  Game();
  char did_win();
  char get(int i , int j);
  void display();
  void playO(pair<int, int> move);
  void playX(pair<int, int> move);
};

the important function here is playO and playX

//playO function
void Game:: playO(pair<int,int>move){
  board(move.first)(move.second) = 'o';
}

//playX function
void Game:: playX(pair<int,int>move){
  board(move.first)(move.second) = 'x';
}

Similarly, there’s another 2 classes and there memberfunctions :-

class Player{
  char xo;

public:
  Player(char choose);
  pair<int, int> play(Game &game);
};

Player::Player(char choose){
  xo = choose;
}
 
pair<int, int>Player:: play(Game &game){
  int pos1,  pos2;
  cout<<"Enter two numbers to let us know where to play: "<<endl;
  cin>>pos1>>pos2;
  return make_pair(pos1, pos2);
}


class AIPlayer : public Player{
public:
  AIPlayer(char choose);
  pair<int, int> play(Game &game);
};

AIPlayer:: AIPlayer(char choose): Player(choose){

}

pair<int, int> AIPlayer:: play(Game &game){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j< 3; j++){
      if(game.get(i , j) == '-') {
       return make_pair(i,j);


      }
    }
  }
  return make_pair(0,0);
}

real analysis – Wrong inequality in simple proof Cauchy $implies$ Boundedness.

These notes from Oxford University contain an apparently very simple proof that Cauchy sequences (real or complex) imply boundedness.

I understand the Cauchy condition $|a_m – a_n| < epsilon$, and that the proof assigns $epsilon=1$ as an arbitrary value.

Question: I can’t understand how the following inequality is derived from the triangle inequality:

$$|a_m| leq 1 + |a_N|$$

My Attempt: I have tried using the reverse triangle inequality with no success:

$$|a_m| – |a_N| leq |a_n -a_N| < 1$$

And so,

$$|a_m| < 1 + |a_N|$$

Here the inequality is $<$ and not $leq$ as per the reproduced notes.


For convenience, the proof is reproduced below.

enter image description here

air travel – Wrong ID information on Wizzair

As outlined in the answer to this question, airlines don’t have the slightest concern for any fields that you enter other than “name”. Every other detail on the booking could be completely wrong and they’ll still let you on the plane. As you enter the plane, your passport or ID card will be scanned by the agent, updating your booking to contain the right data and overwriting any data previously recorded for your booking. This also ensures that any APIS data is correctly shared with immigration authorities.

Relax and enjoy your flight. There’s nothing else you need to do.

magento2.2.4 – Magento 2.4 – Error encountered after installing new theme error: Requested path ” is wrong

I installed a thirdparty theme and for some reason it broke my magento server now I am unable to see the frontend and backend. I cannot access the admin panel to switch it back to the default luma theme. Please help me, what is this error?

Your kind help is highly appreciated. please assist thanks.

Frontend:

Requested path ” is wrong.

#1 MagentoFrameworkAppStaticResource->launch() called at (vendor/magento/framework/App/Bootstrap.php:263)
#2 MagentoFrameworkAppBootstrap->run() called at (pub/static.php:13)

programming practices – Is this wrong or right for walk throw in project?

Q1: If I want to make a project for example (Library Management System) is fine to look at someone’s code and take the idea about the project then I make it by my own and if I stuck go back and look at the block that I stuck at; Is this way is good and help me to improve or this way is bad?

Q2: Can any one share some ways to make projects or the ways of walk throw when i want to make specific project that if i do it, i will improve ?

Q3: Would any one suggest to me some project(c++) for intermediate and expert?

Thanks so mush in advance

differential equations – (Possibly bugs? ) Wrong results provided by `DEigensystem`

I was trying DEigensystem with the following code:

DEigensystem({-u''(x) + x u'(x), DirichletCondition(u(x) == 0, True)},u(x), {x, 0, 1}, 2)

And after a period of time of calculation, it returns the following results:enter image description here

It surprised me that the first eigen value is a complex Root expression while the second one is a simple integer 10, however after a while I realized that the second solution was actually zero:enter image description here
So 10 should not be the eigen value of this operator. The plot of the following code shows that every even integer is the solution of u(1)==0 with boundary condition u(0)==0

Plot(Log@RealAbs(DSolveValue({-u''(x) + x u'(x) - (Lambda) u(x) == 0, u(0) == 0}, u(x), x) /. {C(_) :> 1, x :> 1} // Evaluate), {(Lambda), 0, 15})

enter image description here

However, when (Lambda) equals to even numbers, the general solution is actually zero, and the special solution is not zero at point x==1:

Limit(DSolveValue({-u''(x) + x u'(x) - (Lambda) u(x) == 0, u(0) == 0}, u(x), x) /. {C(_) :> 1}, (Lambda) -> 10) // Simplify

(*0*)

DSolveValue({-u''(x) + x u'(x) - (Lambda) u(x) == 0, u(0) == 0} /. (Lambda) -> 10, u(x), ) /. {C(_) :> 1} // Simplify

(*(-2 E^(x^2/2) x (2895 - 2640 x^2 + 588 x^4 - 44 x^6 + x^8) + 
 Sqrt(2 (Pi)) (-945 + 4725 x^2 - 3150 x^4 + 630 x^6 - 45 x^8 + x^10) Erfi(x/Sqrt(2)))/7257600*)

% /. x -> 1

(*(-1600 Sqrt(E) + 1216 Sqrt(2 (Pi)) Erfi(1/Sqrt(2)))/7257600*)

So my question is: How to get the right DEigensystem result of the operator above automatically? By the way, all of the codes give the same result in version 12.1, 12.2 and 12.3.

magento2.4 – Catalog Search result Wrong Result Magento 2

I am facing issue in the search result. I have installed Magento 2.4.0 and using Elasticsearch 7.0.
When i search for h397 it gives me 4 product count and if i search for h397-4 it gives me 1868 product count. Might Magento consider it as a separate value like h397 and 4. So how can i fix this issue?

Please check attached screenshot for more clarification.

enter image description here

Is there any solution?

debian – Rescue Tip: Wrong library file installation damaged Ubuntu 18.04 after upgrade

There was an old Ubuntu 14.04 linode.com instance which I attempted to upgrade to 18.04. Some Dependencies where somehow not upgraded anyway.

So I attempted to install corresponding deb file from Ubuntu server (as it was not in repo)

The following packages have unmet dependencies:
 dpkg : Breaks: libdpkg-perl (< 1.18.11) but 1.18.4ubuntu1 is to be installed
        Breaks: libdpkg-perl:i386 (< 1.18.11)
 libc-bin : Depends: libc6 (< 2.25) but 2.27-3ubuntu1.2 is to be installed
 locales : Depends: libc-bin (> 2.27)

I accidentally installed wrong version of libc6 which result to damage the instance.

root@myself:~# dpkg -i libc6_2.27-3ubuntu1_amd64.deb 
dpkg: warning: downgrading libc6:amd64 from 2.31-0ubuntu9.2 to 2.27-3ubuntu1
(Reading database ... 110607 files and directories currently installed.)
Preparing to unpack libc6_2.27-3ubuntu1_amd64.deb ...
/usr/bin/perl: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
dpkg: error processing archive libc6_2.27-3ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 127
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Errors were encountered while processing:
 libc6_2.27-3ubuntu1_amd64.deb

Now I cannot access ssh

Login via Lish Gateway(Linode SH), I get the following message and it doesn’t accept any login.

 * Stopping flush early job output to logs                               ( OK )
 * Starting SystemD login management service                             ( OK )
 * Starting system logging daemon                                        ( OK )
 * Starting Bridge socket events into upstart                            ( OK )
 * Starting Bridge file events into upstart                              ( OK )
 * Setting up X socket directories...                                    ( OK )
 * Stopping cold plug devices                                            ( OK )
 * Stopping log initial device creation                                  ( OK )
 * Stopping System V initialisation compatibility                        ( OK )
 * Starting configure network device security                            ( OK )
 * Starting System V runlevel compatibility                              ( OK )
 * Starting OpenSSH server                                               ( OK )
 * Starting regular background program processing daemon                 ( OK )
 * Starting save kernel messages                                         ( OK )
 * Stopping save kernel messages                                         ( OK )
 * Starting configure virtual network devices                            ( OK )
 * Starting MySQL Server                                                 (fail)
 * Restoring resolver state...                                           ( OK )
 * Stopping MySQL Server                                                 ( OK )                                                                         
 *                                                                             
 * The apache2 configtest failed.                                              
Output of config test was:                                                     
/usr/sbin/apache2: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such
Action 'configtest' failed.                                                    
The Apache error log may have more information.                                
 * Stopping System V runlevel compatibility                              ( OK )
                                                                               
Ubuntu 18.04.1 LTS nmd2 ttyS0                                             
                                                                               
nmd2 login:                                                                   
------------------------------------------------------------------------------

So attempting a rescue mode is the only option. It seems libcrypt dependency is causing the error.

How to solve this in rescue mode. Any advice please.

What is wrong about this proof? (NP P; One Way Function)

I read a proof in my script:
If P != NP -> There exists no OWF.

Their proof was a bit messy so I want to ask if this also counts as a correct proof:

Assume P = NP, and a OWF over {0,1}^n. Then there exists a NTM M, that can check every possible String in {0,1}^n in O(n)-time (binary tree). Therefore, F^-1 is in NP.
If P = NP, then F^-1 is in P and there would not exist an OWF.