NP membership from witness relations #
Membership in Cslib.Complexity.NP asks for a verifier whose certificates have length exactly
p (enc a).length. Problems are usually given by a witness relation instead: a belongs to the
problem when some witness b with R a b exists, the witnesses of a member can be chosen of
polynomial length, and R is decidable in polynomial time
Papadimitriou, Proposition 9.1. This file turns such relations into membership
in NP, handling the exact-length convention in one place.
A certificate is a witness prefix padded with false to the required length, and the verifier
ignores the padding (Cslib.Complexity.IsVerifier.of_padding). Four kinds of witnesses are
supported:
- witnesses
b : βwith an encodingencWthat has a decoderTuring.MultiTapeTM.Decoder(Cslib.Complexity.mem_NP_of_witness): the certificate isframe (encW b)followed by padding. The verifierCslib.Complexity.witnessVerifierdecodes the framed prefix of the certificate, re-encodes the decoded witness to reject malformed certificates, and checks the witness (Cslib.Complexity.witnessVerifier_eq_true_iff). The decoder is what makes the parsing polynomial-time: a check that is polynomial-time on encoded witnesses says nothing about words that encode no witness; - sets of candidates from a list computed from the instance
(
Cslib.Complexity.mem_NP_of_subsetWitness): bitiof the certificate selects thei-th candidate at its first occurrence (Cslib.Complexity.selectDistinct), missing bits arefalse, and bits beyond the candidates are ignored; - sub-multisets of a list of entries computed from the instance
(
Cslib.Complexity.mem_NP_of_subMultisetWitness): bitiof the certificate selects thei-th entry (Cslib.Complexity.maskSelect), so a value occurring several times may be selected several times. Subset sum, partition and knapsack use these; - bit strings read with default
false, directly throughIsVerifier.of_padding, as for the assignments ofSAT.
NP is also closed under polynomial-time reductions (Cslib.Complexity.PolyTimeReducible.mem_NP,
the unrelativized counterpart of Cslib.Complexity.PolyTimeReducible.mem_NPWithOracle).
Certificates for the original instance have a length polynomial in its own length, while the
verifier of the target expects a length determined by the reduced instance, so the verifier reads
only that prefix of the certificate (Cslib.Complexity.exists_truncated_verifier), and
List.exists_length_eq_take_iff matches the two certificate quantifiers.
For verifiers on concatenated strings, Cslib.Complexity.mem_NP_setOf_exists_append places the
pairs (a, u) admitting an accepted suffix of length q (enc a).length in NP. This is the
inner existential quantifier used in the Karp–Lipton argument.
Main definitions #
Cslib.Complexity.witnessVerifier: the verifier of a witness relation, parsing certificates with a decoder.Cslib.Complexity.subsetVerifier: the verifier of a subset problem, selecting candidates by a mask (Cslib.Complexity.selectDistinct).Cslib.Complexity.maskVerifier: the verifier of a sub-multiset problem, selecting entries by a mask (Cslib.Complexity.maskSelect).Cslib.Complexity.encWithEntries: an instance paired with selected entries, the input of the checks of both kinds of verifier.
Main results #
Cslib.Complexity.witnessVerifier_eq_true_iff: the witness verifier accepts exactly a framed encoded witness that passes the check, followed by any bits.Cslib.Complexity.isVerifier_witnessVerifier,Cslib.Complexity.mem_NP_of_witness: a relation with polynomially short witnesses decided in polynomial time defines a problem inNP.Cslib.Complexity.mem_NP_of_check: the same for a problem given by a sound check under which every member has a short accepted witness.Cslib.Complexity.isVerifier_subsetVerifier,Cslib.Complexity.mem_NP_of_subsetWitness: subset problems over polynomial-time candidate lists with polynomial-time checks are inNP.Cslib.Complexity.isVerifier_maskVerifier,Cslib.Complexity.mem_NP_of_subMultisetWitness: the same for sub-multisets of polynomial-time lists of entries.Cslib.Complexity.PolyTimeReducible.mem_NP:NPis closed under polynomial-time reductions.Cslib.Complexity.mem_NP_setOf_exists_append: a polynomially bounded suffix accepted by a polynomial-time verifier defines a problem inNPon pairs.
References #
Witnesses parsed by a decoder #
The verifier of the witness relation decided by check. It decodes the framed prefix of the
certificate with D, rejects the certificate unless it starts with the framed encoding of the
decoded witness, and checks that witness.
Instances For
Malformed certificates are rejected. witnessVerifier D check accepts exactly the
certificates that consist of the framed encoding of a witness accepted by check, followed by any
bits.
A certificate framing the encoding of a witness, followed by any bits, is checked as that witness.
Witness relations. If check decides R and every member has a witness whose encoding has
length at most p (enc a).length, then witnessVerifier D check verifies {a | ∃ b, R a b} with
certificates of length 2 * p + 1: a framed encoded witness, followed by padding.
The verifier of a witness relation is polynomial-time when its check is.
NP membership from a witness relation Papadimitriou, Proposition 9.1.
If check decides the relation R in polynomial time, the witness encoding has a decoder, and
every member has a witness whose encoding has length at most p (enc a).length, then
{a | ∃ b, R a b} is in NP.
NP membership from a sound and complete check. If check accepts a witness only for
members of A, and every member has a witness accepted by check whose encoding has length at
most p (enc a).length, then A is in NP. This is mem_NP_of_witness for the relation
check (a, b) = true, stated for the problem A itself.
An instance paired with a list of selected entries, the input of the check of a subset or mask verifier: the encoded instance, framed, followed by the entries, each framed.
Instances For
Subset witnesses #
Selecting the entries of a list from a mask is polynomial-time.
The verifier of a subset problem over the candidates vs a: select candidates by the
certificate mask (selectDistinct) and check the selected list.
Instances For
Subset witnesses. Let the candidates vs a be at most p (enc a).length many, and let
check decide P a on the duplicate-free lists of candidates. Then subsetVerifier vs check
verifies the problem of having a set S of candidates with P a S, with certificates of length
p: the mask of S, followed by padding.
The verifier of a subset problem is polynomial-time when the candidates and the check are.
NP membership of subset problems. If the candidates vs a and the check of the selected
candidates are polynomial-time, and check decides P a on duplicate-free lists of candidates,
then having a set S of candidates with P a S is in NP.
Mask witnesses #
Selecting the entries of a list by a mask (maskSelect) is polynomial-time.
Sub-multiset witnesses. Let the entries items a be at most p (enc a).length many, and
let check decide P a on the sublists of the entries. Then maskVerifier items check verifies
the problem of having a sub-multiset s of the entries with P a s, with certificates of length
p: a mask selecting s, padded with false. Unlike isVerifier_subsetVerifier, a repeated
entry may be selected repeatedly.
The verifier of a sub-multiset problem is polynomial-time when the entries and the check are.
NP membership of sub-multiset problems. If the entries items a and the check of the
selected entries are polynomial-time, and check decides P a on the sublists of the entries,
then having a sub-multiset s of the entries with P a s is in NP.
Closure under reductions #
NP is closed under polynomial-time reductions. The verifier of A runs the verifier of
B on the reduced instance and on the prefix of the certificate whose length the verifier of B
expects. For the oracle classes, see Cslib.Complexity.PolyTimeReducible.mem_NPWithOracle.
The inner quantifier #
The inner quantifier of a Π₂ verifier is in NP. For a polynomial-time V, the pairs
(a, u) for which V accepts (a, u ++ v) for some v of length q (enc a).length form a
problem in NP, for the encoding of pairs.