Proving the language of non-primes is in NP

Computer Science Asked by builderthebob00 on February 6, 2021

I am learning about NP problems and found this problem in my textbook that I was not sure how to answer, and was looking for some help on how to start the question.

Show the following language is in NP:

Not-Prime = {n ∈ N: n is not a prime number}

So far, I have created an efficient decider for the language with a certificate, but I’m not sure how to prove that the language is actually in NP. Thank you for any advice!

One Answer

If you created a deterministic polynomial-time algorithm $A$ that can check a "yes"-certificate for Not-Prime (of polynomial length in the size of instance), then you already proved that your problem is in $mathsf{NP}$.

Say that a polynomial upper bound on the length of the certificate is $p(s)$, where $s$ is the size of the instance. A non-deterministic polynomial-time algorithm for Not-Prime can do the following:

  • Guess the length $ell$ of the certificate in ${0, dots, p(s)}$.
  • For $i=1, dots, ell$: guess the $i$-th bit $c_i$ of the certificate.
  • Run $A$ on the certificate $c_1 c_2 dots c_ell$. If $A$ accepts, accept. Otherwise reject.

A certificate for an instance $n$ of Not-Prime is just a non-trivial prime factor of $n$ (which requires at most $lceil log n rceil$ bits to be represented, so you can pick $p(s)=s$).

Answered by Steven on February 6, 2021

Add your own answers!

Related Questions

How to generate graphs with a Hamiltonian path?

3  Asked on February 21, 2021 by always-newbie


Wifi throughput calculation

1  Asked on February 20, 2021 by copsa


Thirty-one game. Prediction of the winner

1  Asked on February 17, 2021 by donvitomarco


speed of preorder traversal

1  Asked on February 8, 2021 by keith-paton


Mergesort and some claims on comparison

1  Asked on February 7, 2021 by user3661613


Proving the language of non-primes is in NP

1  Asked on February 6, 2021 by builderthebob00


Longest path on a full tree

1  Asked on January 27, 2021 by bm1125


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP