# 证明与计算(1): Decision Problem, Formal Language L, P and NP

## 0x01 从判定问题到形式语言

https://en.wikipedia.org/wiki/Proof_of_knowledge

Let x be a language element of language L in NP

L = {x ∈ {0,1}* : Q(x) = 1}

• S->XSY|e
• X->aX|a
• Y->bY|e

• a list of its variables
• a list of its terminal symbols
• a list of its rules as (LHS, RHS) pairs
• its start variable

• '<G>=(S,X,Y)(a,b)((S,XSY),(S,e),(X,aX),(X,a),(Y,bY),(Y,e))S'

const decesionProblem = '<G>=(S,X,Y)(a,b)((S,XSY),(S,e),(X,aX),(X,a),(Y,bY),(Y,e))S'.split('')

const reducer =
(accumulator, currentValue) =>
accumulator + currentValue.charCodeAt(0).toString(2);

const binaryString = decesionProblem.reduce(reducer,'');
console.log(binaryString);

"11110010001111111101111011010001010011101100101100010110010110011010011010001100001101100110001010100110100010100010100111011001011000101001110110011010011011001010001010011101100110010110100110110010100010110001011001100001101100010100110110010100010110001011001100001101001101100101000101100110110011000101011001101001101100101000101100110110011001011010011010011010011"

P = {L \subseteq {0, 1}* : exist an algorithm A that decides L in p-time}

• Q是一个判定算法。
• Q是一个能在多项式时间内判定yes/no的判定算法。
• L是被Q判定结果为yes的所有输入x的集合。
• L是被Q判定结果为yes的所有输入x的集合所表示的形式语言。

## 0x02 P问题

P is the set of languages whose memberships are decidable by a Turing Machine that makes a polynomial number of steps.

PATH = {< G, u, v, k > : G = (V, E) is an undirected
graph, u,v ∈ V, k ≥ 0 is an integer, and exist a path
from u to v in G with ≤ k edges}

## 0x03 证明凭据(certificate)，证明(certifier)

L = {x ∈ {0, 1}* : exist y ∈ {0, 1}* s.t. A(x, y) = 1}

Given a graph G, is there set S of size ≥ k such that no two nodes in S are connected by an edge?

• Finding the set S is hard
• But if I give you a set S∗, checking whether S∗ is the answer is easy
• S∗ acts as a certificate that ⟨G,k⟩ is a yes instance of Independent Set

Certificate是否有效(efficient)([3])：
An algorithm B is an efficient certifier for problem X if:

• B is a polynomial time algorithm that takes two input strings I (instance of X) and C (a certificate)
• B outputs either yes or no.
• There is a polynomial p(n) such that for every string I: I ∈ X if and only if there exists string C of length ≤ p(|I|) such that B(I,C) = yes.

Certification的含义是“帮手”([3])：

B is an algorithm that can decide whether an instance I is a yes instance if it is given some “help” in the form of a polynomially long certificate.

Let’s say you had an efficient certifier B for the Independent Set problem.

Try every string C of length ≤ p(|I|) and ask is B(I,C) = yes?

## 0x04 NP问题

NP = {L \subseteq {0, 1}* : exist a certificate y, |y| = O(|x|^k), and an algorithm A s.t. A(x, y) = 1}

NP is the set of languages for which there exists an efficient certifier.

P is the set of languages for which there exists an efficient certifier that ignores the certificate.

A problem is in P if we can decided them in polynomial time. It is in NP if we can decide them in polynomial time, if we are given the right certificate.

• 存在长度是字符串x的多项式倍的字符串y
• 存在验证算法A
• 使得A(x,y)=1

• 能通过A(x,y)=1的所有x构成的语言是L
• 所有L的集合是NP语言集合

SUBSET-SUM: Given finite set S of integers, is there a subset whose sum is exactly t?

## 0x05 P vs NP vs NPC

• P \subseteq NP \subseteq NP-hard
• Co-NP = {L': L ∈ NP}
• NPC=NP中最难的集合，并且他们等价

Proof. Suppose X ∈ P. Then there is a polynomial-time algorithm A for X.
To show that X ∈ NP, we need to design an efficient certifier B(I,C).
JusttakeB(I,C)=A(I).

## 0x06 夹逼法(Reduction and NPC Reduction)

Reduce language L1 to L2 via function f:

1. Convert input x of L1 to instance f(x) of L2
2. Apply decision algorithm for L2 to f(x)

L1is p-time reducible to L2, or L1 p≤ L2, if exist a ptime
computable function f : {0, 1}* -> {0, 1}* s.t. for all x ∈ {0, 1}*, x ∈ L1
iff f(x) ∈ L2

If L1 p≤ L2 and L2 ∈ P, then L1 ∈ P

A language L ∈ {0, 1}* is NP-complete if:

1. L ∈ NP, and
2. L’ p≤ L for every L’ ∈ NP, i.e. L is NP-hard

1. If L is language s.t. L’ p≤L where L’ ∈ NPC, then L is NP-hard.
2. If L ∈ NP, then L ∈ NPC.

This gives us a recipe for proving any L ∈ NPC:

1. Prove L ∈ NP
2. Select L’ ∈ NPC
3. Describe algorithm to compute f mapping every input x of L’ to input f(x) of L
4. Prove f satisfies x ∈ L’ iff f(x) ∈ L, for all x ∈ {0, 1}*
5. Prove computing f takes p-time

“If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in "creative leaps," no fundamental gap between solving a problem and recognizing the solution once it's found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss...”
— Scott Aaronson, MIT

## 0x07 wait to be continue...

Let x be a language element of language L in NP

## 0x08 参考

posted @ 2018-07-18 20:04 ffl 阅读(...) 评论(...) 编辑 收藏