Skip to Content
Problem Solving

6-难问题求解

2019-08-28Original-language archivelegacy assets may be incomplete

Definition

Alphabet

  • Σ\Sigma: alphabet
    • Σ=P(Σ)\Sigma^*=\mathcal{P}(\Sigma)
    • Σ+=Σ{λ}\Sigma^+=\Sigma^*-\{\lambda\}
  • sΣs\in\Sigma: symbol
    • sws\in w
  • wΣ,ωΣw\subseteq\Sigma, \omega\in\Sigma^*: word over Σ\Sigma
    • wLw\in L
    • λ\lambda: empty word
    • w|w|: length of word
      • Σn={wΣw=n}\Sigma^n=\{w\in\Sigma^*|\vert w\vert=n\}
    • #a(w)_a(w): number of occurence of aa in ww
    • vwvw: concatenation of vv and ww
      • wn+1=wwn,w0=λw^{n+1}=ww^n,w^0=\lambda
    • prefix, suffix, subword
  • LΣL\subseteq\Sigma^*: language over Σ\Sigma
    • LC=ΣLL^C =\Sigma^*-L
    • L1L2={uv(Σ1Σ2)uL1,vL2}L_1L_2=\{uv\in(\Sigma_1\cup\Sigma_2)^*|u\in L_1,v\in L_2\}: concatenation
  • canonical ordering: let s1<...<sms_1<...<s_m be a linear ordering, u<vu<v
    • if u<v\vert u\vert<\vert v\vert
    • or u=v,u=xsiu,v=xsjv,i<j\vert u\vert=\vert v\vert,u=xs_iu',v=xs_jv',i<j

Algorithmic Problems

  • polynomially related: codings e1L1,e2L2,f:L1L2,f(e1)e_1\in L_1,e_2\in L_2,\exists f:L_1\rightarrow L_2,f(e_1) is polynomial
  • decision Problem: (L,U,Σ),LUΣ(L,U,\Sigma),L\subseteq U\subseteq \Sigma^*
    • AA solves/decides UU
      • A(x)=1,xLA(x)=1,x\in L
      • A(x)=0,xULA(x)=0,x\in U-L
    • AA accepts UU: A(x)=1,xLA(x)=1,x\in L
      • Halting Problem: Undecidable but acceptable
  • optimization Problem: U=(ΣI,ΣO,L,LI,M,cost,goal)U=(\Sigma_I,\Sigma_O,L,L_I,M,cost,goal)
    • briefly: U=(L,U=(L, constraints, costs, goal))
    • ΣI\Sigma_I: input alphabet
    • ΣO\Sigma_O: output alphabet
    • LΣIL\subset\Sigma_I^*: language of feasible Problem instances
    • LILL_I\subset L: language of the actual Problem instance
    • M:LP(ΣO)M:L\rightarrow \mathcal{P}(\Sigma_O^*), M(x)\mathcal{M}(x) is the set of feasible solutions for xx
    • cost:M(x)×LR:\mathcal{M}(x)\times L\rightarrow \mathbb{R}
    • goal {min,max}\in\{\min,\max\}
    • optimal solution OptU(x)=cost(y,x)=goalxLI{cost(z,x)zM(x)}Opt_U(x)=cost(y,x)=goal_{x\in L_I}\{cost(z,x)|z\in \mathcal{M}(x)\}
    • OutputU(x)M(x)Output_U(x)\subseteq \mathcal{M}(x): all optimal solutions for instance xUx\in U
  • Algorithm AA is consistent for UU: xLI,A(x)M(x)\forall x\in L_I,A(x)\in \mathcal{M}(x)
  • Algorithm BB solves UU
    • consistent
    • xLI,B(x)=OptU(x)\forall x\in L_I,B(x)=Opt_U(x)
  • U1U_1 is a subProblem of U2U_2 if LI,1LI,2L_{I,1}\subseteq L_{I,2} (Others are same)

Turing Machine

  • Turing Machine: M=(Q,Σ,Γ,δ,q0,qac,qrej)M=(Q,\Sigma,\Gamma,\delta,q_0,q_{ac},q_{rej})
    • QQ: state set
    • Σ\Sigma: Input alphabet
    • ΓΣ\Gamma\subseteq\Sigma: alphabet on tape
    • δ:Q×ΓQ×Γ×{L,R,}\delta:Q\times\Gamma\rightarrow Q\times\Gamma\times\{L,R,-\}
    • q0Qq_0\in Q: initial satate
  • nondeterministic TM: δ:Q×ΓP(Q×Γ×{L,R})\delta:Q\times\Gamma\rightarrow \mathcal{P}(Q\times\Gamma\times\{L,R\})
  • nondeterministic TM MM accept L=L(M)L=L(M)
    • xL,\forall x\in L,\exists computation of MM accepts xx
    • y∉L\forall y\not\in L, all computations of MM rejects yy
  • time complexity of nondeterministic TM MM
    • TM(ω)T_M(\omega): shortest accepting computation of MM on ω\omega
    • TM(n)=max{TM(x)xL(M)Σn}T_M(n)=\max\{T_M(x)|x\in L(M)\cap\Sigma^n\}
  • Church-Turing thesis: Problem UU can be solved by an algorithm iff \exists Turing machine solving UU
  • Theorem: for every increasing function f:NR+f:\mathbb{N}\rightarrow\mathbb{R}^+
    • \exists decision Problem such that every TM solving it has the time complexity in Ω(f(n))\Omega(f(n))
    • but \exists TM solving it in O(f(n)logf(n))O(f(n)\log f(n))
  • L(M)L(M): language decided by MM

Examples

Decision

  • PRIM: test if a number is a prime
  • EQ-POL: p1p2p_1\equiv p_2 in Zp\mathbb{Z}_p
  • EQ-1BP: equivalence of one-time-only branching programs
  • C-SAT: whether a formula with AND, NOT, OR gate is satisfiable
  • SAT (kSAT): whether a CNF can be satisfied
  • Clique: whether a graph contain KkK_k
  • VCP: whether graph contains a vertex cover of size kk
  • HC: whether graph contains a Hamiltonian cycle
  • SOL-IP: existence of a solution of linear integer programming
    • SOL-0/1-IP
    • SOL-IPp_p
  • PM: whether a bipartite graph has a perfect matching
  • SUBSET-SUM: exists a subset SSS'\subseteq S sum up to tt

Optimization

  • TSP: find a Hamiltonian cycle of the minial cost in a complete weighted graph
    • Δ\Delta-TSP: metric traveling salespaerson Problem (satisfying triangle inequality)
    • Euclidean TSP: geometrical, can be embedded in the two-dimensional Euclidean space
  • MSP: Makespan Scheduling Problem
  • MIN-VCP: find minimum vertex cover
    • WEIGHT-VCP
  • SCP: Set Cover Problem
  • MAX-CL: Maximum Clique Problem
  • MAX/MIN-CUT
  • KP: Knapsack Problem
    • SKP: Simple Knapsack Problem
    • BIN-P: Bin-Packing Problem
  • MAX-SAT: maximize the number of stisfied clauses
    • MAX-kSAT
    • MAX-EkSAT: exactly
  • LP: Linear Programming
    • IP: Integer Linear Programming
    • 0/1-Linear Programming
  • MAX-LinModk: Maximum Linear Equation Problem Mod k
    • MAX-EmLinModk: k is prime, m is positive integer
  • MAX-CSP: maxS,TE(S,T)\max_{S,T}|E(S,T)|

Complexity Theory

  • main objective of the complexity theory is:
    • find a formal specification of the class of practically solvable Problems
    • to develop methodes enabling the classification of algorithmic Problemcs accoording to their membershiop in this class
  • uniform cost
    • all numbers bounded
    • basic operation: O(1)O(1)
  • logarithmic cost
    • numbers kk takes O(lgk)O(\lg k) bits
    • addition, subtraction, assignment: O(n)O(n)
    • multiplication, division: O(nlogn)O(n\log n)
  • pseudopolynomial time complexity:
    • T(n)T(n) is polynomial in the numeric value of the input
    • T(n)T(n) is not polynomial in the number of bits required to repensent it of the input
  • bound
    • T/SA(x)T/S_A(x): time/space complexity on xΣIx\in\Sigma_I
    • T/SA(n)=max{T/SA(x)xΣIn}T/S_A(n)=\max\{T/S_A(x)|x\in\Sigma_I^n\}: worst case analysis
    • upper bound on the time complexity of UU: A\exists A solving UU with TA(n)O(g(n))T_A(n)\in O(g(n))
    • lower bound on the time complexity of UU: B\forall B solving UU has TB(n)Ω(f(n))T_B(n)\in\Omega(f(n))
  • There is a decision Problem such that A\forall A deciding LL, B\exists B deciding LL: TA(n)=log2TB(n)T_A(n)=\log_2T_B(n)
  • optimal algorithm: TimeC(n)O(g(n))\text{Time}_C(n)\in O(g(n)) and Ω(g(n))\Omega(g(n)) is a lower bound

Complexity Class

  • Complexity Zoo
  • P={L(M)M\text{P}=\{L(M)|M is a TM, c>0,TM(n)O(nc)}\exists c>0,T_M(n)\in O(n^c)\}
    • tractable (solvable): LPL\in P, LL is accepted/decided by a polynomial-time algorithm
    • intractable: L∉PL\not\in P
  • NP={L(M)M\text{NP}=\{L(M)|M is a polynomial-time nondeterministic TM}\}
    • verifier for LL: AA works on Σ×{0,1}\Sigma^*\times\{0,1\}^*, L=V(A)={ωΣc{0,1},AL=V(A)=\{\omega\in\Sigma^*|\exists c\in\{0,1\}^*,A accepts (ω,c)}(\omega,c)\}
    • NP={V(A)TA(ω,c)O(ωd)}\text{NP}=\{V(A)|T_A(\omega,c)\in O(|\omega|^d)\}
    • closed under ,,,\cap,\cup,\cdot,\star
  • polynomial-time reduction (Karp, many-one) L1pL2L_1\leq_p L_2: \exists poly. time ff that x:xL1    f(x)L2\forall x: x\in L_1\iff f(x)\in L_2
    • Cook/Turing reduction: an algorithm that solves Problem AA using a polynomial number of calls to a subroutine for Problem BB, and polynomial time outside of those subroutine calls
  • NP\text{NP}-hard LL: UNP,UpL\forall U\in \text{NP},U\leq_p L
  • NP\text{NP}-complete LL: LNPL\in \text{NP} and LL is NP\text{NP}-hard
  • co-NP\text{NP}: LNP\overline{L}\in \text{NP}, x∉Lx\not\in L can be poly. time verified with cc
  • strongly NP\text{NP}: NP\text{NP} when all of its numerical parameters are bounded by a polynomial in the length of the input
  • LNLPZPPNPPHPSPACE=NPSPACEEXPNEXPEXPSPACEELEMENTARYPRRREALL\text{L}\subseteq\text{NL}\subseteq\text{P}\subseteq\text{ZPP}\subseteq\text{NP}\subseteq\text{PH}\subseteq\text{PSPACE}=\text{NPSPACE}\subseteq\text{EXP}\subseteq\text{NEXP}\subseteq\text{EXPSPACE}\subseteq\text{ELEMENTARY}\subseteq\text{PR}\subseteq\text{R}\subseteq\text{RE}\subseteq\text{ALL}
    • PEXP\text{P}\neq\text{EXP}
    • NPNEXP\text{NP}\neq\text{NEXP}
  • PZPPRPBPPPP\text{P}\subseteq\text{ZPP}\subseteq\text{RP}\subseteq\text{BPP}\subseteq\text{PP}
  • PBQPPSPACE\text{P}\subseteq\text{BQP}\subseteq\text{PSPACE}
  • Conjecture: PNP\text{P}\neq \text{NP}: no hope for a polynomial-time algorithm
  • Conjecture: BPP=P\text{BPP}=\text{P}: randomization alone not help

Optimization Complexity

  • NPO\text{NPO}:
    • LIPL_I\in \text{P}
    • exists a polynomial pUp_U such that
      • xLI,yx,ypU(x)\forall x\in L_I,y\in\mathcal{x},|y|\leq p_U(|x|)
      • exists a polynomial-time algorithm that yΣO,xLI\forall y\in\Sigma_O^*,x\in L_I such that ypU(x)|y|\leq p_U(|x|), decides wheter yM(x)y\in M(x)
    • cost is computable in polynomial time
  • PO\text{PO}:
    • UNPOU\in \text{NPO}
    • xLI,\forall x\in L_I,\exists polynomial-time algorithm computes an optimal solution
  • threshold language of UU (minimum): LangU={(x,a)LI×ΣboolOptU(x)Number(a)}Lang_U=\{(x,a)\in L_I\times\Sigma^*_{bool}|Opt_U(x)\leq Number(a)\}
  • UU is NP\text{NP}-hard if LangULang_U is NP\text{NP}-hard
    • UPO,LangUPU\in \text{PO},Lang_U\in \text{P}

Reduction

  • Cook's Theorem: C-SAT is NP\text{NP}-complete
  • NPC\text{NPC}
    • C-SAT p\leq_p SAT
    • SAT p\leq_p 3SAT
    • 3SAT p\leq_p SOL-0/1-ILP: x1x2x3    x1+(1x2)+(1x2)1x_1\vee\overline{x}_2\vee\overline{x}_3\iff x_1+(1-x_2)+(1-x_2)\geq1
    • 3SAT p\leq_p SUBSET-SUM
    • 3SAT p\leq_p Clique: K3,3,,3K_{3,3,\cdots,3}
    • Clique p\leq_p VC: (G,k)(G,k)\in Clique    (G,Vk)\iff(\overline{G},|V|-k)\in VC
    • VC p\leq_p HAM-CYCLE
    • VC p\leq_p SCP
    • HAM-CYCLE p\leq_p HAM-PATH
    • HAM-CYCLE p\leq_p TSP
    • MAX-CUT
  • strongly NPC\text{NPC}: 3-Partition
  • PM NP\in\text{NP}\capco-NP\text{NP}
  • EXP\text{EXP}-complete: Go
  • NEXP\text{NEXP}-complete: equivalence of regular expressions with squaring, concatenating and union
  • EXPSPACE\text{EXPSPACE}-complete: equivalence of regular expressions with squaring, concatenating, union and Kleene

Approximation

Error

  • relative error ϵA(x)=cost(A(x))OutU(x)OptU(x)\epsilon_A(x)=\frac{|cost(A(x))-Out_U(x)|}{Opt_U(x)}
    • ϵA(n)=max{ϵA(x)xLI(ΣI)n}\epsilon_A(n)=\max\{\epsilon_A(x)|x\in L_I\cap(\Sigma_I)^n\}
  • approximation ratio RA(x)=max{cost(A(x))OptU(x),OptU(x)cost(A(x))}R_A(x)=\max\{\frac{cost(A(x))}{Opt_U(x)},\frac{Opt_U(x)}{cost(A(x))}\}
    • RA(n)=max{RA(x)xLI(ΣI)n}R_A(n)=\max\{R_A(x)|x\in L_I\cap(\Sigma_I)^n\}
    • (minimization) RA(x)=1+ϵA(x)R_A(x)=1+\epsilon_A(x)
NPO Name Description Examples
FPTAS\text{FPTAS} fully polynomial-time approximation scheme TimeA(x,ϵ1)\text{Time}_A(x,\epsilon^{-1}) bounded by a function that is polynomial in both x\lvert x\rvert and ϵ1\epsilon^{-1} knapsack
PTAS\text{PTAS} polynomial-time approximation scheme (x,ϵ)LI×R+\forall (x,\epsilon)\in L_I\times\mathbb{R}^+, AA computes a feasible solution A(x)A(x) with ϵA(x)<ϵ\epsilon_A(x)<\epsilon and TimeA(x,ϵ1)\text{Time}_A(x,\epsilon^{-1}) can be bounded by a function that is polynomial in x\vert x\vert MSP
APX\text{APX} δ\delta-approximation algorithm xLI,RA(x)δ\forall x\in L_I,R_A(x)\leq \delta MIN-VCP, MAX-SAT, δ\delta-TSP
log-APX\log\text{-APX} f(n)f(n)-approximation algorithm RA(n)f(n),f(n)R_A(n)\leq f(n),f(n) is bounded by a polylogarithmic function iailogi(n)\sum_{i}a_i\log^i(n) SCP
f(n)-APXf(n)\text{-APX} f(n)f(n)-approximation algorithm RA(n)f(n),f(n)R_A(n)\leq f(n),f(n) is not bounded by any polylogarithmic function TSP, MAX-CL

Distance

  • distance function from U\overline{U} according to LIL_I: hL:LR+h_L:L\rightarrow\mathbb{R}^+
    • xLI,hL(x)=0\forall x\in L_I, h_L(x)=0
    • hLh_L is polynomial-time computable
  • Ballr,h(LI)={wLh(w)r}Ball_{r,h}(L_I)=\{w\in L|h(w)\leq r\}
  • Ur=(ΣI,ΣO,L,Ballr,h(LI),M,cost,goal)U_r=(\Sigma_I,\Sigma_O,L,Ball_{r,h}(L_I),M,cost,goal)
  • property of infinite jumps: If Ballq,h(LI)Ballr,h(LI)Ball_{q,h'}(L_I)\subset Ball_{r,h'}(L_I) for some q<rq<r, then Ballr,h(LI)Ballq,h(LI)|Ball_{r,h'}(L_I)|-|Ball_{q,h'}(L_I)| is infinite

for δ\delta-approximation AA

Stability according to hh Description
pp-stable rp,δr,ϵR>1,A\forall r\leq p,\exists \delta_{r,\epsilon}\in\mathbb{R}^{>1},A is δr,ϵ\delta_{r,\epsilon}-approximation algorihtm for UrU_r
stable AA is pp-stable according to hh for all pR+p\in R^+
(r,fr(n))(r,f_r(n))-quasistable AA is an fr(n)f_r(n)-approxiamtion algorithm for UrU_r

for PTAS AA:

Stability according to hh Description
stable r>0,ϵ>0,Aϵ\forall r>0,\forall\epsilon>0,A_\epsilon is a δr,ϵ\delta_{r,\epsilon}-approximation algorithm for UrU_r
superstable δr,ϵf(ϵ)g(r)\delta_{r,\epsilon}\leq f(\epsilon)g(r), f,gf,g are some functions from R0\mathbb{R}^{\geq0} to R+\mathbb{R}^+ and limϵ0f(ϵ)=0\lim_{\epsilon\rightarrow0}f(\epsilon)=0
  • constraint distance function for uu is h:LI×ΣOR0h:L_I\times\Sigma^*_O\rightarrow\mathbb{R}^{\geq0}, SM(x),h(x,S)=0\forall S\in M(x),h(x,S)=0, S∉M(x),h(x,S)>0\forall S\not\in M(x),h(x,S)>0 and hh is polynomial-time computable.
    • ϵ\epsilon-ball of M(x)M(x) according to hh: Mϵh(x)={SΣOh(x,S)ϵ}M_\epsilon^h(x)=\{S\in\Sigma^*_O|h(x,S)\leq\epsilon\}
hh-dual Description
PTAS (x,ϵ)LI×R+,A(x,ϵ)Mϵh(x)\forall (x,\epsilon)\in L_I\times\mathbb{R}^+,A(x,\epsilon)\in M_\epsilon^h(x) and cost(A(x,ϵ))OptU(x)cost(A(x,\epsilon))\geq Opt_U(x) if goal=max and TimeA(x,ϵ1)\text{Time}_A(x,\epsilon^{-1}) is bounded by a function that is polynomial in x\lvert x\rvert
FPTAS TimeA(x,ϵ1)\text{Time}_A(x,\epsilon^{-1}) can be bounded by a function that is polynoimal in both x\lvert x\rvert and ϵ1\epsilon^{-1}

Randomization

  • RandomA(x)\text{Random}_A(x): the maximum number of random bits used
    • RandomA(n)\text{Random}_A(n): max{RandomA(x)x=n}\max\{\text{Random}_A(x)||x|=n\}
    • derandomization: RandomA(n)logn\text{Random}_A(n)\leq\log n
  • ProbA,x(C)\text{Prob}_{A,x}(C): Probability of the executaion CC on xx
    • Prob(A(x)=y)=C outputs yProbA,x(C)\text{Prob}(A(x)=y) = \sum_{C\text{ outputs }y}\text{Prob}_{A,x}(C)
  • Exp-TimeA(x)=CProbA,x(C)Time(C)\text{Exp-Time}_A(x)=\sum_C\text{Prob}_{A,x}(C)*Time(C)
    • Exp-TimeA(n)=max{Exp-TimeA(x)x=n}\text{Exp-Time}_A(n)=\max\{\text{Exp-Time}_A(x)||x|=n\}
  • TimeA(x)=max{Time(C)C runs on x}\text{Time}_A(x)=\max\{\text{Time}(C)|C\text{ runs on }x\}
    • TimeA(n)=max{TimeA(x)x=n}\text{Time}_A(n)=\max\{\text{Time}_A(x)||x|=n\}

Decision Problem

Classification Name Description Repeat k times
ZPP\text{ZPP} Las Vegas algorithm Prob(A(x)=F(x))12\text{Prob}(A(x)=F(x))\geq\frac{1}{2} Prob(A(x)=?)<12\text{Prob}(A(x)=?)<\frac{1}{2} LZPP1(1δ)kL\in \text{ZPP}_{1-(1-\delta)^k}
RP\text{RP} One-sided-error Monte Carlo algorithm xL,Prob(A(x)=F(x)=1)12\forall x\in L,\text{Prob}(A(x)=F(x)=1)\geq\frac{1}{2} x∉L,Prob(A(x)=F(x)=0)=1\forall x\not\in L,\text{Prob}(A(x)=F(x)=0)=1 LRP1(1δ)kL\in \text{RP}_{1-(1-\delta)^k}
BPP\text{BPP} Two-sided-error Monte Carlo algorithm Prob(A(x)=F(x))12+ϵ,0<ϵ12\text{Prob}(A(x)=F(x))\geq\frac{1}{2}+\epsilon,0<\epsilon\leq\frac{1}{2} k2ln2δln(14ϵ2),LBPP1δk\geq\frac{2\ln 2\delta}{\ln(1-4\epsilon^2)},L\in \text{BPP}_{1-\delta}
PP\text{PP} Unbounded-error Monte Carlo algorithm Prob(A(x)=F(x))>12\text{Prob}(A(x)=F(x))>\frac{1}{2}

Optimization Problem

Algorithm Description
RFPTAS\text{RFPTAS} p(x,δ1)p(\vert x\vert,\delta^{-1}) is polynomial in both x\vert x\vert and δ1\delta^{-1}
RPTAS\text{RPTAS} (randomized polynomial-time approximation scheme) Prob(A(x)M(x))=1\text{Prob}(A(x)\in M(x))=1 and Prob(ϵA(x,δ)δ)12\text{Prob}(\epsilon_A(x,\delta)\leq\delta)\geq\frac{1}{2} and TimeA(x,δ1)p(x,δ1)Time_A(x,\delta^{-1})\leq p(\vert x\vert,\delta^{-1}) and pp is a polynomial in x\vert x\vert
randomized f(n)f(n)-approximation algorithm Prob(A(x)M(x))=1\text{Prob}(A(x)\in M(x))=1 and Prob(RA(x)f(x))12\text{Prob}(R_A(x)\leq f(\vert x\vert))\geq\frac{1}{2}
randomized δ\delta-approximation Prob(A(x)M(x))=1\text{Prob}(A(x)\in M(x))=1 and Prob(RA(x)δ)12\text{Prob}(R_A(x)\leq\delta)\geq\frac{1}{2}
randomized δ\delta-expected approximation Prob(A(x)M(x))=1\text{Prob}(A(x)\in M(x))=1 and E(RA(x))δE(R_A(x))\leq\delta
  • w.h.p (with high probility): pc=O(11n)p_c=O(1-\frac{1}{n})
  • Median Trick
    • ϵ\forall\epsilon, return a Z^\hat Z in time poly(ϕ,1ϵ|\phi|,\frac{1}{\epsilon}), P((1ϵ)ZZ^(1+ϵ)Z)23P((1-\epsilon)Z\leq\hat Z\leq(1+\epsilon)Z)\geq\frac{2}{3}
    • Repeat O(log1δ)O(\log\frac{1}{\delta}) and choose median number (Chernoff Bound)
    • FPRAS: ϵ,δ\forall\epsilon,\delta, return a Z^\hat Z in time Poly(ϕ,1ϵ,log1δ|\phi|,\frac{1}{\epsilon},\log\frac{1}{\delta}), P((1ϵ)ZZ^(1+ϵ)Z)1δP((1-\epsilon)Z\leq\hat Z\leq(1+\epsilon)Z)\geq1-\delta

Paradigms of Design of Randomized Algorithm

  • Foiling an adversary
  • Abundance of witness: decision Problem
    • Fingerprinting: equivalence Problem
  • random sampling
    • relexation and random rounding