theory-of-computation-note-1

Formal Logical System·

Formal system·

  • image-20220418200944459
  • tautology 恒真的 statement
  • contradiction 恒假的 statement

Normal forms·

Disjunctive normal form (or of and)·

  • Every statement form (not a contradiction) is logically equivalent to a restricted statement form of the form (i=1m(j=1nQij))\left(\vee_{i=1}^{m}\left(\wedge_{j=1}^{n} Q_{i j}\right)\right) where each QijQ_{ij} is either a variable or the negation of a variable.

Conjunctive normal form (and of or)·

  • Every statement form (not a tautology) is logically equivalent to a restricted statement form of the form (i=1m(j=1nQij))\left(\wedge _{i=1}^{m}\left(\vee_{j=1}^{n} Q_{i j}\right)\right) where each QijQ_{ij} is either a variable or the negation of a variable.

Adequate set·

  • \sim 加上 {,,}\{\wedge,\vee, \rightarrow\} 中的任何一个
  • 一元的只有 NOR, NAND 必须引入 not

Formal statement calculus(L)·

  • an alphabet of symbols: ,,(,),P1,P2,P3,\sim, \rightarrow, (, ), P_1, P_2, P_3, \cdots

  • A set of finite string of these symbols, called well-formed formula:

    • PiP_i is a wf 一个变量是一个式子
    • If AA and BB are wfs, then (A)(\sim A) and (AB)(A \rightarrow B) are wfs.
  • Axioms:

    • image-20220418205040857
  • rules of deduction

    MP: From AA and ABA \rightarrow B, we can derive BB

    HS: {(AB),(BC)}(AC)\{(A\rightarrow B), (B \rightarrow C)\} \vdash (A \rightarrow C)

Deduction Theorem·

  • Δ{A}BΔAB\Delta \cup \{A\} \vdash B \Leftrightarrow \Delta \vdash A \rightarrow B
  • Proof: 归纳推导过程的长度枚举最后一步推导的方式substitution or MP

Unfinished! some examples·

  • image-20220418224906806

Extension·

  • An extension Lof L is consistent if and only if there is a wf. which is not a theorem of L.

    • Otherwise

      image-20220418224550276

  • complete: we can decide every statement true or false

Turing Machines·

Standard Turing Machine·

  • input ww is written on the first w|w| cells, other cells are empty
  • when want to move to the left of the leftmost cell, stay put
  • At each time
    • read the symbol
    • write a symbol
    • move left or right
  • image-20220404110144013
  • A language is recursively enumerable (recognizable) if some TM recognizes it.
    • the TM can enumerate all the strings
  • A language is recursive (decidable) if some TM decides it.
    • recursive language \subset recursively enumerable language

Multiple Tapes·

2-Tape Turing Machine·

  • The input is on Tape 1.
  • Tape 2 is initially blank.
  • Read a symbol from each tape, each head moves. 两个一起动
Simulation on one TM·
  • each aΓa \in \Gamma has a mirror state aa ^ *

    if one state has * it means 当前 head 位于这个位置

  • Beginning

    • input#\perp^*
    • replace the first symbol aa with aa ^ *
      • 表示 一开始 第一个纸带 输入是input 位置在第一位
      • 第二个纸带 输入是空 位置在第一位
      • 中间用 # 隔开
    • 每一次在一个上面做完了 就找到另一个 * state 然后再做
    • special case: 如果第一个纸带做到了 # 上先整体右移

Nondeterministic Turing Machine·

  • 下一个状态是一个可行集合
  • 只要有可行的方式到达 accept 那就是 accept
  • simulate 的方式
    • 3-tape TM
      • tape 1: input
      • tape 2: simulate
      • tape 3: 按从短到长的顺序 存储 guess (bfs)
    • 每次把 1 里面的 input load 到 2 上去当前 3 的 guess 在 2 上跑一遍
  • a NTM is a decider if all branches halt on all inputs

TM with outputs·

  • TM with a write only tape
  • enumerator
    • a machine that can enumerate strings one by one, maybe with repetitions
    • 为什么 Turing recognizable 的 language 称作 recursively enumerable
      • 因为可以用一个enumerator E 去 generate
      • image-20220412171050992
      • 为啥得枚举 步数
        • 一个 TM 输入的串的长度是否确定了在TM 上运行时间的上界
      • 如何recognize
        • 每次枚举出来一个 就跟输入 w 比较
        • accept的总能判断出来 但 reject 的可能会不停机

Universal Turing Machine (UTM)·

  • the set of TM is countable
    • 可以编号用 <M> 代表第 M 这个 TMTM 的编号
  • UTM
    • input: M, w
    • output: 与 M 上跑 w 的结果一样

Halting Problem·

ATMA_{TM}·

  • ATM={<M,w>M is a TM and M accepts w}A_{T M}=\{<M, w>\mid M \text { is a TM and } M \text { accepts } w\}
  • want to prove ATMA_{TM} is not decidable
  • Proof:
    • If ATMA_{TM} is decidable
      • H\exist H that decides ATMA_{TM}
      • consider H(M,<M>)H(M, <M>)
        • accept if MM accepts <M><M>
        • reject if MM rejects or loops on <M><M>
        • always halt
      • D(<M>)D(<M>) 如下定义 也是一个 TM
        • image-20220412173857875
        • always halt
      • 考虑 D(<D>)D(<D>)
        • DD accept <D><D> -> H(D,<D>)H(D, <D>) reject -> DD reject or loop on <D><D>
        • DD reject <D><D> -> H(D,<D>)H(D, <D>) accept -> DD accept <D><D>
        • 总是矛盾
    • Thus, ATMA_{TM} is not decidable
  • 显然 ATMA_{TM} is recognizable 因为我们可以直接模拟
  • 所以 ATMA_{TM} is not co-recognizable

HALTTMHALT_{TM}·

  • HALTTM={<M,w>TM M halts on input w>\mathrm{HALT}_{\mathrm{TM}}=\{<M, w>\mid \text{TM } M \text { halts on input } w>

  • not decidable

  • recognizable

  • not co-recognizable

Turing reducibility·

Oracle Turing Machine (OTM)·

  • 相当于你有一个 oracle language A 就是有一个 tool A
  • 你可以询问 A 让他自己告诉你 询问的串 在不在 AA

Definition·

  • Language A is Turing reducible to B, if an oracle TM MBM^B

    decides A, write ATBA\leq _T B

  • 就是说 有了 BB AA 就是 turing decidable

  • Ex: ATMTHALTTMA_{TM} \leq_T HALT_{TM}

Examples·

  1. ETM={MM是一个图灵机<spanclass="bdbox"><hcharclass="bdbdbeg"><hinner></hinner></hchar></span>L(M)=}E_{TM} = \{\langle M \rangle \mid M 是一个图灵机<span class="bd-box"><h-char class="bd bd-beg"><h-inner>,</h-inner></h-char></span>且 L(M) = \emptyset\}

    Undecidable

    image-20220412182018250

  2. REGULARTM={MM是一个图灵机<spanclass="bdbox"><hcharclass="bdbdbeg"><hinner></hinner></hchar></span>L(M)是一个正则语言}REGULAR_{TM} = \{\langle M \rangle \mid M 是一个图灵机<span class="bd-box"><h-char class="bd bd-beg"><h-inner>,</h-inner></h-char></span>且 L(M) 是一个正则语言\}

    Undecidable

    image-20220412193319580

  3. EQTM={M1,M2M1E Q_{\mathrm{TM}}=\left\{\left\langle M_{1}, M_{2}\right\rangle \mid M_{1}\right.M2M_{2} 都是图灵机, 且 L(M1)=L(M2)}\left.L\left(M_{1}\right)=L\left(M_{2}\right)\right\}

    Undecidable

    If EQTMEQ_{TM} is decidable,

    M1M_1 是一个拒绝所有输入的图灵机

    对于 MM输入 M,M1\langle M, M_1\rangle EQTMEQ_{TM} 即判定 L(M)L(M) 是否为空

    解决了 ETME_{TM}

Properties of CFG·

image-20220412193401901

Reduction via Computation History·

Definition of computation history·

  • Let MM be a TM and ww be an input string.

    An accepting computation history for MM on ww is a sequence of configurations, C1,C2,,ClC_1, C_2, \cdots, C_l , where C1C_1 is the start configuration of MM on ww, ClC_l is an accepting configuration of MM, and each CiC_i legally follows from Ci1C_{i−1} according to the rules of MM.

    A rejecting computation history for MM on ww is defined similarly, except that ClC_l is a rejecting configuration.

    一个 configuration CiC_i 是指 形如 uaqibvu a q_i b v 的组合 包含了带子的内容 头的位置和状态信息

  • 计算历史 是有限序列

    如果不停机 那么不存在计算历史

Example: Linear bounded automaton (LBA)·

  • LBA 是一种图灵机 不允许 head 离开 input 在带子上的区域

  • 相当于 纸带的存储大小被 input bound 住

  • ALBA={M,wM是一个接受wLBA}A_{LBA} = \{\langle M, w\rangle \mid M是一个接受w的LBA\}

  • Lemma: Let MM be an LBALBA with qq states and gg symbols in the tape alphabet. There are exactly qngnqng^n distinct configurations of MM for a tape of length nn.

    configuration数有限 显然

  • ALBAA_{LBA} is decidable

    • 因为 configuration 的上限 is qngnqng^n 我们可以在 w 上 模拟这么多步 或者直到它停机
    • 如果接受就接受 如果拒绝或者还没跑完就拒绝
  • ELBAE_{LBA} is not decidable

    • 想要从 ELBAE_{LBA} 规约到 ATMA_{TM}
    • 对于 MMww 我们构造一个检查器 检查器的输入是 M,wM, w 以及一段 accepting computation history
    • 检查器就是检查 computation history 是否合法 显然不需要额外的空间 因此是 LBA
    • 我们只要判断是否属于 ELBAE_{LBA} 也就是判断了 是否存在 accepting computation history

Example: ALLCFGALL_{CFG}·

  • ALLCFGALL_{CFG} is not decidable

    • 想要从 ALLCFGALL_{CFG} 规约到 ATMA_{TM}

    • 构造一个非确定的 PDA 对于 M 和 w

      • 如果 M 接受 w 则 PDA 不能接受所有的串
        • 不接受 M 中 w 的 accepting history
      • 如果 M 不接受 w 则 PDA 能够接受所有的串
    • 所以只要构造这样的PDA 不接受 w 的 accepting history 其他均接受

    • 接受以下所有

      1. 不以 C1C_1 开始
      2. 不以一个 accepting configuration 结束
      3. 某个 CiC_i 不能派生 Ci+1C_{i+1}
    • PDA 也有三个分支分别对应三种情况

        1. 不以 C1C_1 开始就接受

        2. 不以 accepting 结束 就接受

        3. 一个个判断

          在判断 CiC_iCi+1C_{i+1}首先走到 CiC_i 然后将其压入栈

          然后与 Ci+1C_{i+1} 一点点比较除了读写头之外应该相同

          读写头部分用 MM 去判断是否合理

        一个小问题 是 压入栈之后顺序会颠倒前一个倒着后一个正着 不能一个个比较

        解决方案把奇数位置的串正着写 偶数位置的倒着写

        image-20220412234303769

Post correspondence problem (PCP)·

  • 七种block
    • 开始的block [# | #q0w1w2wnq_0w_1w_2\cdots w_n#]
    • 如果 δ(q,a)=(r,b,R)\delta(q, a) = (r, b, R) 加入 [qaqa | brbr]
    • 如果 δ(q,a)=(r,b,L)\delta(q,a) = (r, b, L) 加入 [cqacqa | rcbrcb] (c)(\forall c)
    • 加入 [aa][a | a] (a)(\forall a)
    • [# | #], [# | ϵ\epsilon#]
    • [aqacceptaq_{accept} | qacceptq_{accept}], [qacceptaq_{accept}a | qacceptq_{accept}] 用来蚕食最后的剩余的骨牌们
    • [qacceptq_{accept}## | #] 最后位置上的匹配
  • 如何强制让第一种排在第一位最后一种排在最后一位
    • image-20220414154826455
    • 这样 只有第一个是开头都是星星
    • 只有最后一个结尾都是方块

Mapping reducibility·

Definition·

  • A function is computable / recursive if some TM MM, on every input ww, halts with f(w)f(w).
  • Language AA is mapping reducible to language BB if there is a recursive function ff s.t. wAf(w)Bw\in A \Leftrightarrow f(w) \in B.

Properties·

  • If AmBA \leq _m B and BB is decidable, then AA is decidable.
  • If AmBA \leq _m B and BB is recognizable, then AA is recognizable.
  • If AmBA \leq _m B and BB is co-recognizable, then AA is co-recognizable.

Example·

  • Prove EQTMEQ_{TM} is not decidable, recognizable, co-recognizable.
  • not decidable:
    • proved by Turing reduction
    • 规约到 ATMA_{TM} 是否与一个 空的TM 相同
  • not recognizable:
    • image-20220414163247206
    • ATMA_{TM} is not co-recognizable, so EQTMEQ_{TM} is not recognizable.
  • not co-recognizable:
    • 类似

Difference with Turing reducibility·

  • 更强

  • 需要是同向的

  • 性质一样 因为能够用一个 ff 去 map

  • Turing-reduction only for proving undecidability, and mapping-reduction can be used for prove unrecognizability.

Recursion Theorem·

  • Let t:NNt: N \rightarrow N be a recursive function. There is a TM FF for which t(F)t(\langle F\rangle) is the code of a Turing machine equivalent to FF.

Proof·

  • define such a TM DD:
D(<M>):
 output the code of the TM:
 G(y):
  d = M(<M>)
  simulate the machine with code d on y
  • DD is recursive because 只是输出一个编号不用运行 GG

  • define a TM VV:

V(<M>):
 output t(D(<M>))
  • Let F=D(V)\langle F \rangle = D(\langle V \rangle)

  • Then when running F(y)F(y):

    • d = V(<V>) = t(D(<V>)) = t(<F>)
    • simulate the machine with code d on y
  • So F(y) = simulating the TM with code t(<F>) on y

Diagonalized Proof·

  • image-20220415172903423
  • Unfinished

Generalization: Kleene’s recursion theorem·

  • Let tt be a recursive function t:N×NNt: N \times N \rightarrow N. There is a Turing machine R:NNR: N \rightarrow N, where R(x)=t(R,x)R(x)=t(\langle R\rangle, x)

Proof·

  • Define a recursive function s:NNs: N \rightarrow N by s-m-n thm:
s(x):
 output the code of TM on input y computing t(x,y)
  • By recursion theorem on ss, we have a TM FF s.t. the TM with code s(F)s(\langle F\rangle) is equivalent to FF.

  • The TM with code s(F)s(\langle F \rangle) is the TM that computes t(x,y)t(x,y) on input yy.

Unfinished·

Kolmogorov complexity·

Definition·

  • Let xx be a binary string.
  • The minimum description d(x)d(x) of xx is the shortest string <M,w><M,w> where TM MM on input ww halts with xx on the tape.
  • The Kolmogorov complexity K(x)=d(x)K(x)=|d(x)|
  • xx 的信息量

Properties·

  • x\forall x, K(x)x+cK(x) \leq |x| + c, for some constant cc.
  • x\forall x, K(xx)x+cK(xx) \leq |x| + c, for some constant cc.
  • x\forall x, K(xn)x+clognK(x ^ n) \leq |x| + c \log n, for some constant cc.
    • 存储 nn这个bound是 logn+c\log n + c
    • 任何的图灵机 都是固定长度的 除了输入的部分

c-compressible·

  • A string xx is c-compressible if K(x)xcK(x) \leq |x| - c.

  • If xx is not 1-compressible, then xx is incompressible.

  • Thm: Incompressible strings of every length exist.

    • Proof: 为什么只用 二进制串的 description
  • Thm: n,c\forall n, c, Prx{0,1}n[K(x)xc]112c\operatorname{Pr}_{x \in\{0,1\}^{n}}[K(x) \geq|x|-c] \geq 1-\frac{1}{2^{c}}

    • Proof: 一样考虑二进制的 description 的个数

Compressibility·

  • COMPRESS={(x,c)K(x)c}COMPRESS = \{(x, c) \mid K(x) \leq c\}

  • Thm: COMPRESS is undecidable.

    Proof:

    • Construct a Machine M:

      M(n):
       For all y in 字典序
        if (y, n) \notin COMPRESS
         print y
         halt
    • Then we get yy, the first string of K(y)>nK(y) > n

    • 但是 M(n)M(n) prints y, K(y)M,n=c+lognK(y) \leq |\langle M, n\rangle | = c + \log n

    • nn 充分大时矛盾

Chaitin’s incompleteness theorem·

  • image-20220415165729111

  • Proof:

    • Suppose we can prove K(x)>LK(x) > L for some xx.

    • 选择 proof 的长度最小的 PP which proves K(y)>LK(y) > L.

    • 考虑这样一个图灵机

      R(L):
       枚举所有的argument Q
        check whether Q is valid
        check whether Q proves K(y) > L
        If yes, outputs y

      这样一个玩意儿的长度是 R,L=c+logL|\langle R, L\rangle| = c + \log LK(y)>LK(y) > L 矛盾

      不需要输入 y 嘛虽然不影响证明

“Were-you-last” Game·

  • m players, unlimited bits
  • each player can read/write t\leq t bits

Solution·

Trivial solution·

  • Counter
If Counter = 0, Counter = m
Else Counter -= 1
  • t=O(logm)t = O(\log m)

real solution·

  • use several blocks to represent the counter
    • type of last block 0 / 1
    • number of blocks
    • size of each block
  • t4loglogm+O(1)t \leq 4 \log \log m + O(1)
  • How to set the initial counter to m?
    • work on C=CmC' = C \oplus m
  • Lower bound of tt: 0.4loglogm0.4 \log \log m
  • Cannot be solved when t=o(loglogm)t = o(\log\log m)
    • 无论玩家什么策略定义 SiS_i 表示 ii 这个玩家可能修改的 bits 的集合均有 Si2t1|S_i| \leq 2 ^ t - 1由于决策树最多 tt至多可以看 t 个 bit每层最多两个选择当前看的 bit 是 0/1
    • 如果玩家的策略均相同
      • i,Si=S\forall i, S_i = S
      • S<logm|S| < \log m不足以表示 0m10\sim m-1
    • 如果玩家策略不同
      • Sunflower Lemma
        • A sunflower: 一堆集合有共同的交集其他部分两两不交
        • Let S1,,SmS_1, \cdots, S_m be a collection of sets each of size l\leq l. If m>(p1)l+1l!m > (p - 1) ^ {l+1} l!, then 存在一个包含p个集合的 sunflower
      • l=2t1l = 2 ^ t - 1, m>(p1)l+1l!m > (p-1) ^ {l+1} l!
      • 存在一个 pp 的 sunflower记为 S1,,SpS_1, \cdots, S_p
      • 首先搞定其他所有的人然后这 p 个人放到最后操作只有 center of sunflower 会有影响center 的 size l\leq l
      • center 的状态 2l\leq 2 ^ l如果 p>2lp > 2 ^ l我们有 至少两个人 面对相同的 center 状态设为 iijj
      • 假设 ii 出现在 jj 之前ij1i\sim j - 1 删掉那么对于 jj 之后的人没有影响原先的最后一个人仍旧会判断自己为最后一个人错误
      • (2l)l+1l!2l2+l+llogl<m(2 ^ l) ^ {l+1} l! \leq 2 ^ {l ^ 2 + l + l\log l} < m 合理

Bounds of Complexity·

  • OO 上界 Ω\Omega 下界
  • 基于比较的排序的复杂度
    • 决策树

Dynamic Partial Sum·

Description·

  • 单点修改
  • 求前缀和

Bound of complexity·

  • 线段树 复杂度 查询修改均为 O(logn)O(\log n)

  • image-20220419012141083

Interleave info(IL)·

  • IL(t0,t1,t2)IL(t_0, t_1, t_2) 表示 (t0,t1)(t_0,t_1)(t1,t2)(t_1,t_2) 传递信息的次数只考虑 t1t0=t2t1t1 - t_0 = t_2 - t_1

  • IL(t0,t1,t2)IL(t_0, t_1, t_2) is the number of transitions between a value π(i)\pi(i) with i<t1i<t_1, and a consecutive value π(j)\pi(j) with j>t1j>t_1

  • E[IL(t0,t1,t2)]E[IL(t_0, t_1, t_2)]

    • Pr[j\operatorname{Pr}\left[\mathrm{j}\right. is in [t0,t1]]=k/(2k)=1/2\left.\left[\mathrm{t}_{0}, \mathrm{t}_{1}\right]\right]=\mathrm{k} /(2 \mathrm{k})=1 / 2
    • Pr[j+1\operatorname{Pr}\left[j+1\right. is in [t1,t2]\left[t_{1}, t_{2}\right] \mid j is in [t0,t1]]=k/(2k1)\left.\left[t_{0}, t_{1}\right]\right]=k /(2 k-1)
    • E[IL(t0,t1,t2)]=(2k1)k2(2k1)=k2\mathrm{E}\left[\mathrm{IL}\left(\mathrm{t}_{0}, \mathrm{t}_{1}, \mathrm{t}_{2}\right)\right]=(2 k-1) \cdot \frac{k}{2(2 k-1)}=\frac{k}{2}
  • Unfinished bound·

Information transfer (IT)·

  • IT(t0,t1,t2)IT(t_0, t_1, t_2) 表示 在 (t0,t1)(t_0, t_1) 写 在 (t1,t2)(t_1, t_2) 读 且 在 (t1,t2)(t_1, t_2) 不再写 的 memory locations 的集合
  • image-20220419014418611