<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; 复杂性</title>
	<atom:link href="http://zhiqiang.org/blog/tag/%e5%a4%8d%e6%9d%82%e6%80%a7/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>数学、金融、计算机</description>
	<lastBuildDate>Sat, 19 May 2012 13:47:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>PCP - Probabilistic Checkable Proof</title>
		<link>http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html</link>
		<comments>http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html#comments</comments>
		<pubDate>Sun, 19 Oct 2008 09:11:22 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[计算机科学]]></category>
		<category><![CDATA[NP hard]]></category>
		<category><![CDATA[PCP]]></category>
		<category><![CDATA[复杂性]]></category>
		<category><![CDATA[高等理论计算机]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/?p=859</guid>
		<description><![CDATA[博客 » 计算机科学 » NP hard，PCP，复杂性，高等理论计算机 » PS: PCP可以说是理论计算机领域近20年来的最重要的结果之一，它给了NP问题一个新的刻画，并且提供了一种证明近似算法下界的方法。下面是yijia写的PCP介绍。 作者：yijia 我们可以从最基本的NP开始。一般NP的定义是基于nondeterministic Turing machine，但我们也可以用类似于Interactive Proof的系统来刻画： 一个语言是在NP内当...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science/computer-science">计算机科学</a> » <a href="http://zhiqiang.org/blog/tag/np-hard" rel="tag">NP hard</a>，<a href="http://zhiqiang.org/blog/tag/pcp" rel="tag">PCP</a>，<a href="http://zhiqiang.org/blog/tag/%e5%a4%8d%e6%9d%82%e6%80%a7" rel="tag">复杂性</a>，<a href="http://zhiqiang.org/blog/tag/%e9%ab%98%e7%ad%89%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba" rel="tag">高等理论计算机</a> » </p><p>PS: PCP可以说是理论计算机领域近20年来的最重要的结果之一，它给了<a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-p-vs-np-an-overview-of-the-problem.html" target="_self">NP问题</a>一个新的刻画，并且提供了一种证明近似算法下界的方法。下面是yijia写的PCP介绍。</p>
<p>作者：yijia</p>
<p>我们可以从最基本的NP开始。一般NP的定义是基于nondeterministic Turing machine，但我们也可以用类似于Interactive Proof的系统来刻画：</p>
<p>一个语言<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_f09564c9ca56850d4cd6b3319e541aee.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Q" /></span><script type='math/tex'>Q</script>是在NP内当且仅当存在一个多项式时间的算法<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>  (i.e., prover) 满足下面一系列条件：</p>
<ol>
<li><span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>有两个输入<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>和<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>，并且<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_0c5f507a618aac8497cf1b5407949659.gif' style='vertical-align: middle; border: none; ' class='tex' alt="|y|=poly(|x|)" /></span><script type='math/tex'>|y|=poly(|x|)</script>；</li>
<li>对于任意的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>， 我们有<br />
2.1. 如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_55cb0fad3efd248662c6b70819aad41e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \in Q" /></span><script type='math/tex'>x \in Q</script>，那么存在一个<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>使得<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_05550d1b7029ec8bc75af01b132dc666.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V(x,y)=1" /></span><script type='math/tex'>V(x,y)=1</script>，i.e., <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script> accepts <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_90cbc22edf225adf8a68974f51227f05.gif' style='vertical-align: middle; border: none; ' class='tex' alt="(x,y)" /></span><script type='math/tex'>(x,y)</script>;<br />
2.2 如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_ae9ccbbf4aa6a9d46d7e2cb3a8cd5ff3.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \not\in Q" /></span><script type='math/tex'>x \not\in Q</script>，那么对于任意y都有<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dc1a0717474ce723ed03113d36f2e56.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V(x,y)=0" /></span><script type='math/tex'>V(x,y)=0</script>，i.e.,<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script> rejects <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_90cbc22edf225adf8a68974f51227f05.gif' style='vertical-align: middle; border: none; ' class='tex' alt="(x,y)" /></span><script type='math/tex'>(x,y)</script>.</li>
</ol>
<p>在2.1中，<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>可以看成是<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_55cb0fad3efd248662c6b70819aad41e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \in Q" /></span><script type='math/tex'>x \in Q</script> 的一个证明。对于3Sat问题，我们可以设计这样的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>: <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>是一个3CNF公式，而y是一个对<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>中所有变元的赋值。Prover <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>就是用来验证y是否满足x。直观上<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>必须读完整个<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>才能确认<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_51f48eb6d63abe9d09170574d43f0353.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x\in Q" /></span><script type='math/tex'>x\in Q</script>。 那么有没有可能改进这一点，让<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>只读<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>的一部分，来增加效率? 比如现有的Graph Minor Theory的证明有几百页，如果只要其中几页就能确认其正确那么就会省去Reviewer的很多时间。如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>是个确定时间的算法，这就等价于要求<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_41af7600620f1f233be00c0fffb2b9d2.gif' style='vertical-align: middle; border: none; ' class='tex' alt="|y|=o(|x|)" /></span><script type='math/tex'>|y|=o(|x|)</script>。那么如果每个NP问题都有这样的Prover， 我们就可以证明NP包含Subexponential Time里。一般公认这不可能成立。</p>
<p>但如果我们允许<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>使用Randomness，问题就开始变得有趣了。这也就是Probabilistic Checkable Proof (PCP)。</p>
<p>要定义一个PCP系统, 我们先要给定两个函数<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_a24e18feb278f6b3663fc047697f13b3.gif' style='vertical-align: middle; border: none; ' class='tex' alt="r,q: N \rightarrow N" /></span><script type='math/tex'>r,q: N \rightarrow N</script>。我们说一个随机算法<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>是一个(r(n),q(n))-restricted verifier, 如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>在输入<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_90cbc22edf225adf8a68974f51227f05.gif' style='vertical-align: middle; border: none; ' class='tex' alt="(x,y)" /></span><script type='math/tex'>(x,y)</script>上使用<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d86236b599fa444d880396e23fdaebb1.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(r(|x|))" /></span><script type='math/tex'>O(r(|x|))</script>位随机数，访问<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d0cb8f11912580bcab56771bfb2898b4.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(q(|x|))" /></span><script type='math/tex'>O(q(|x|))</script>位。直观上，V 扔了<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d86236b599fa444d880396e23fdaebb1.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(r(|x|))" /></span><script type='math/tex'>O(r(|x|))</script>个骰子，然后根据结果去访问证明y 的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_d0cb8f11912580bcab56771bfb2898b4.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(q(|x|))" /></span><script type='math/tex'>O(q(|x|))</script>位。 当然V还要是一个多项式时间算法，<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_0c5f507a618aac8497cf1b5407949659.gif' style='vertical-align: middle; border: none; ' class='tex' alt="|y|=poly(|x|)" /></span><script type='math/tex'>|y|=poly(|x|)</script>， 同时满足所谓的non-adaptive条件（写起来太罗嗦了，所以就不写了)。</p>
<p>我们说这样的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>定义了一个语言<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_f09564c9ca56850d4cd6b3319e541aee.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Q" /></span><script type='math/tex'>Q</script>当且仅当对于任意的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>， 我们有<br />
(a) 如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_55cb0fad3efd248662c6b70819aad41e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \in Q" /></span><script type='math/tex'>x \in Q</script>，那么存在一个y 使得<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_50778c6222040e7e7f5affe04bb3315c.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Pr[V(x,y)=1]=1" /></span><script type='math/tex'>Pr[V(x,y)=1]=1</script>;<br />
(b) 如果<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_ae9ccbbf4aa6a9d46d7e2cb3a8cd5ff3.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \not\in Q" /></span><script type='math/tex'>x \not\in Q</script>，那么对于任意y都有<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_a807fd252e9a8502d4c666324de4d21b.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Pr[V(x,y)=1]<1/2" /></span><script type='math/tex'>Pr[V(x,y)=1]<1/2</script>.</p>
<p>要注意的是并不是所有的<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>都定义了一个语言，因为(b)不是总能满足的。</p>
<p>非常壮观的PCP定理就是</p>
<p><strong>Theorem 1. NP=PCP(<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_52e05a8b1b15239cc2aa291731c6f87e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\log n,1" /></span><script type='math/tex'>\log n,1</script>)</strong></p>
<p>也就是说，对于每个NP语言我们都可以构造一个<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_5206560a306a2e085a437fd258eb57ce.gif' style='vertical-align: middle; border: none; ' class='tex' alt="V" /></span><script type='math/tex'>V</script>，在每个<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_90cbc22edf225adf8a68974f51227f05.gif' style='vertical-align: middle; border: none; ' class='tex' alt="(x,y)" /></span><script type='math/tex'>(x,y)</script>上，仅使用<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_e255adac467bb5f89a8a36c18fdf4267.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(\log|x|)" /></span><script type='math/tex'>O(\log|x|)</script>位随机数，访问证明<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_415290769594460e2e485922904f345d.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="y" /></span><script type='math/tex'>y</script>中的常数多位，就能以很高的概率正确判断是否<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_55cb0fad3efd248662c6b70819aad41e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="x \in Q" /></span><script type='math/tex'>x \in Q</script>。</p>
<p>由于可以证明PCP(<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_52e05a8b1b15239cc2aa291731c6f87e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\log n,1" /></span><script type='math/tex'>\log n,1</script>)对于多项式时间规约(PTIME reductions)封闭，所以PCP定理也可以叙述为</p>
<p><strong>Theorem 2. 3Sat <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_986c22f151c46acac223b858e3fcf6fd.gif' style='vertical-align: middle; border: none; padding-bottom:1px;' class='tex' alt="\in" /></span><script type='math/tex'>\in</script> PCP(<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_52e05a8b1b15239cc2aa291731c6f87e.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\log n,1" /></span><script type='math/tex'>\log n,1</script>)</strong></p>
<p>除了本身非常有趣和counter intuitive，PCP的一个重要应用就是近似算法的下界:</p>
<p><strong>Corollary. 如果NP<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_f9bb70af966a4abbd08b776e6c5971ad.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\ne" /></span><script type='math/tex'>\ne</script>P, 那么Max-3Sat没有PTAS，同时Max-Clique不存在constant approximation。</strong></p>
<p>这个结论的证明就是通过PCP，构造所谓的Gap Instances：给定常数<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_e6885dfcb4c4a8ddb730c59135ffe731.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\delta \in (0,1)" /></span><script type='math/tex'>\delta \in (0,1)</script>，<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_3574f45dd11753e37c4def86a7f0c29b.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Gap_\delta" /></span><script type='math/tex'>Gap_\delta</script>-3Sat是如下的问题</p>
<p>input: 一个3CNF公式<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>使得要么存在一个满足<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script>的赋值，要么所有的赋值最多满足<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_77a3b715842b45e440a5bee15357ad29.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\delta" /></span><script type='math/tex'>\delta</script>-fraction的clauses。<br />
question：<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_9dd4e461268c8034f5c8564e155c67a6.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="x" /></span><script type='math/tex'>x</script> 是否可满足？</p>
<p><strong>Corollary 3. 存在一个<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_77a3b715842b45e440a5bee15357ad29.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\delta" /></span><script type='math/tex'>\delta</script>，使得存在一个3Sat到<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_3574f45dd11753e37c4def86a7f0c29b.gif' style='vertical-align: middle; border: none; ' class='tex' alt="Gap_\delta" /></span><script type='math/tex'>Gap_\delta</script>-3Sat的规约。</strong></p>
<p>实际上我们可以证明</p>
<p>Theorem PCP定理成立当且仅当上面的Corollary成立。</p>
<p>现在PCP定理有两个证明：一个就是由Arora，Sudan等人在90初完成的基于代数的方法，直接证明Theorem 2。证明的核心某种意义上就是Error Correcting Code。另一个就是Dinur前几年完成的基于Expander的组合方法，直接证明Cororllary 3。前者的证明很长，但实际上比较初等，而后者短一些且非常漂亮。</p>
<div><h4>相关文章</h4><ul><li class='currentpost'><a href="http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html">PCP - Probabilistic Checkable Proof</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html">素数筛法的复杂度</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/advanced-theoretical-computer-science-i-lectures.html">高等理论计算机I</a></li><li ><a href="http://zhiqiang.org/blog/science/why-the-world-needs-quantum-mechanics.html">为什么这个世界需要量子机制</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/np-hard.html">TCS：NP-hard</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/minesweeper-is-np-complete.html">扫雷是NP完全问题</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/most-windows-game-are-np-complete.html">Windows游戏中的NP完全问题</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/database-query-is-np-hard.html">数据库查询是NP-Hard问题</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2008. | <a href="http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html#comments">6 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>素数筛法的复杂度</title>
		<link>http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html</link>
		<comments>http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html#comments</comments>
		<pubDate>Sun, 30 Mar 2008 15:32:45 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[计算机科学]]></category>
		<category><![CDATA[复杂度]]></category>
		<category><![CDATA[复杂性]]></category>
		<category><![CDATA[算法]]></category>
		<category><![CDATA[素数]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/posts/complexity-of-prime-sieve.html</guid>
		<description><![CDATA[博客 » 计算机科学 » 复杂度，复杂性，算法，素数 » Xie Xie给我看了一个链接性能调优--永远超乎想象，里面提到了素数筛法的复杂度，作者用实验发现此筛法是线形的。 所谓素数筛法就是那个求小于n的所有素数最简单的算法： bool* prime(int n) { bool *p = new bool[n]; memset(p, 0, sizeof p); for (int i = 2; i &#60; n; i++) if (!p[i]) for (int j = 2*i; j &#60; n; j+=i) p[j] = true; return p; } 此算法复杂度实际...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science/computer-science">计算机科学</a> » <a href="http://zhiqiang.org/blog/tag/%e5%a4%8d%e6%9d%82%e5%ba%a6" rel="tag">复杂度</a>，<a href="http://zhiqiang.org/blog/tag/%e5%a4%8d%e6%9d%82%e6%80%a7" rel="tag">复杂性</a>，<a href="http://zhiqiang.org/blog/tag/%e7%ae%97%e6%b3%95" rel="tag">算法</a>，<a href="http://zhiqiang.org/blog/tag/%e7%b4%a0%e6%95%b0" rel="tag">素数</a> » </p><p>Xie Xie给我看了一个链接<a href="http://blog.csdn.net/rmartin/article/details/1132312" target="_blank">性能调优--永远超乎想象</a>，里面提到了素数筛法的复杂度，作者用实验发现此筛法是线形的。</p>
<p>所谓素数筛法就是那个求小于n的所有素数最简单的算法：</p>
<pre><span style="color: #0000ff;">bool</span>* prime(<span style="color: #0000ff;">int</span> n) {
  <span style="color: #0000ff;">bool</span> *p = <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">bool</span>[n];
  memset(p, 0, <span style="color: #0000ff;">sizeof</span> p);
  <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 2; i &lt; n; i++)
    <span style="color: #0000ff;">if</span> (!p[i])
      <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> j = 2*i; j &lt; n; j+=i)
        p[j] = <span style="color: #0000ff;">true</span>;
  <span style="color: #0000ff;">return</span> p;
}</pre>
<p>此算法复杂度实际为 <span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_f2da6587b781ab2b425b98951869fec0.gif' style='vertical-align: middle; border: none; ' class='tex' alt="O(\sum_{p<n}n/p) = O(n\log\log n)" /></span><script type='math/tex'>O(\sum_{p<n}n/p) = O(n\log\log n)</script>。在可以测试的范围内，的确是接近线形的，虽然实际上不是。下面是如何估计<span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_342199c907543038fcb45ba4e9a10a96.gif' style='vertical-align: middle; border: none; ' class='tex' alt="\sum\frac1p" /></span><script type='math/tex'>\sum\frac1p</script>:</p>
<p><p style='text-align:center;'><span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_7bff06ba2ae02e98fe00f203deeb4072.gif' style='vertical-align: middle; border: none;' class='tex' alt="\begin{eqnarray}\log\log\infty&=&\ln \left( \sum_{n=1}^\infty \frac{1}{n}\right) = \ln \left( \prod_{p} \frac{1}{1-p^{-1}}\right) = \sum_{p} \ln \left( \frac{1}{1-p^{-1}}\right) = \sum_{p} - \ln(1-p^{-1}) \\&=&\sum_{p} \left( \frac{1}{p} + \frac{1}{2p^2} + \frac{1}{3p^3} + \cdots \right) = \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( \frac{1}{2} + \frac{1}{3p} + \frac{1}{4p^2} + \cdots \right)\\&=& \sum_{p} \left( \frac{1}{p} + \frac{1}{2p^2} + \frac{1}{3p^3} + \cdots \right) = \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( \frac{1}{2} + \frac{1}{3p} + \frac{1}{4p^2} + \cdots \right)\\&<& \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( 1 + \frac{1}{p} + \frac{1}{p^2} + \cdots \right) = \left( \sum_{p} \frac{1}{p} \right) + \left( \sum_{p} \frac{1}{p(p-1)} \right)\\&=& \left( \sum_{p} \frac{1}{p} \right) + C\end{eqnarray}" /></span><script type='math/tex;  mode=display'>\begin{eqnarray}\log\log\infty&=&\ln \left( \sum_{n=1}^\infty \frac{1}{n}\right) = \ln \left( \prod_{p} \frac{1}{1-p^{-1}}\right) = \sum_{p} \ln \left( \frac{1}{1-p^{-1}}\right) = \sum_{p} - \ln(1-p^{-1}) \\&=&\sum_{p} \left( \frac{1}{p} + \frac{1}{2p^2} + \frac{1}{3p^3} + \cdots \right) = \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( \frac{1}{2} + \frac{1}{3p} + \frac{1}{4p^2} + \cdots \right)\\&=& \sum_{p} \left( \frac{1}{p} + \frac{1}{2p^2} + \frac{1}{3p^3} + \cdots \right) = \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( \frac{1}{2} + \frac{1}{3p} + \frac{1}{4p^2} + \cdots \right)\\&<& \left( \sum_{p}\frac{1}{p} \right) + \sum_{p} \frac{1}{p^2} \left( 1 + \frac{1}{p} + \frac{1}{p^2} + \cdots \right) = \left( \sum_{p} \frac{1}{p} \right) + \left( \sum_{p} \frac{1}{p(p-1)} \right)\\&=& \left( \sum_{p} \frac{1}{p} \right) + C\end{eqnarray}</script></p></p>
<p>更精确的，</p>
<p><p style='text-align:center;'><span class='MathJax_Preview'><img src='http://zhiqiang.org/blog/wp-content/plugins/latex/cache/tex_e00ebfe7605ef377d04c2d1b7f137a2e.gif' style='vertical-align: middle; border: none;' class='tex' alt="\sum_{p<n}\frac1p = \log\log n+\Theta(1)" /></span><script type='math/tex;  mode=display'>\sum_{p<n}\frac1p = \log\log n+\Theta(1)</script></p></p>
<p>注意此估计可直接得出素数有无穷多个 <img src='http://zhiqiang.org/blog/wp-includes/images/smilies/bigsmile.gif' alt=':D' class='wp-smiley' /> 。</p>
<p>但是纯O(n)的算法也不是没有，只不过需要增加辅助空间保存质数列表：</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #000084; font-weight: bold;">bool</span>* prime(<span style="color: #000084; font-weight: bold;">int</span> n) {
    <span style="color: #000084; font-weight: bold;">bool</span> *isp = <span style="color: #000084; font-weight: bold;">new</span> <span style="color: #000084; font-weight: bold;">bool</span>[n];
    <span style="color: #000084; font-weight: bold;">bool</span> *p = <span style="color: #000084; font-weight: bold;">new</span> p(<span style="color: #000084; font-weight: bold;">int</span>(2*n/log(n)+20));
    memset(isp, 0, <span style="color: #000084; font-weight: bold;">sizeof</span> isp);
    memset(p, 0, <span style="color: #000084; font-weight: bold;">sizeof</span> p);
    <span style="color: #000084; font-weight: bold;">int</span> np = 0;
    <span style="color: #000084; font-weight: bold;">for</span> (<span style="color: #000084; font-weight: bold;">int</span> i = 2; i &lt; n; i++) {
        <span style="color: #000084; font-weight: bold;">if</span> (~isp(i)) p(np++) = i;
        <span style="color: #000084; font-weight: bold;">for</span> (<span style="color: #000084; font-weight: bold;">int</span> j = 0; j &lt; pn &amp;&amp; p[j]*i &lt; n; j++) {
            isp[p[j]*i] = 1;
            <span style="color: #000084; font-weight: bold;">if</span>(i%p[j] == 0) <span style="color: #000084; font-weight: bold;">break</span>;
        }
    }
    <span style="color: #000084; font-weight: bold;">delete</span> p;
    <span style="color: #000084; font-weight: bold;">return</span> isp;
}</pre>
<p>这个算法的关键在于 if(i%pr[j] == 0) break;。它使得任何一个合数，只被它最小的质因数标记过一次。所以整个算法是线性的。但考虑到log(log(100000000))还不到3，故这个线性算法其实也只有理论上的价值罢了。</p>
<div><h4>相关文章</h4><ul><li class='currentpost'><a href="http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html">素数筛法的复杂度</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/introduce-probabilistic-checkable-proof.html">PCP - Probabilistic Checkable Proof</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-algorithms-and-calculation-model.html">理论计算机初步：算法和计算模型</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/an-algorithm-face-interviews-question-test.html">一个算法面试题 &#038; 面试题库</a></li><li ><a href="http://zhiqiang.org/blog/science/mathmatics-in-rubik-cube-and-algorithm.html">魔方里的数学</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/median-algorithm-of-ordered-matrix.html">有序矩阵的中位数算法</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/download-encyclopedia-of-algorithm.html">算法百科全书 - Encyclopedia of Algorithms</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/3-color-a-simple-graph.html">一个简单图的三染色算法问题</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/how-google-search-similar-images.html">图片搜索的原理</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/max-drawdown-algorithm.html">最大回撤和最大短期回撤的线性算法</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2008. | <a href="http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html#comments">9 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/computer-science/complexity-of-prime-sieve.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

