1
6.045Lecture 8:
Communication Complexity,Start up Turing Machines
1
https://www.innovairre.com/super-tuesday/
L has a streaming alg using β€ π(π) bits of space means:Give an algorithm A and prove that on all inputs x, A determines π β L correctly and uses β€ π( π ) bits of memoryGive an upper bound!
Every streaming alg for L needs β₯ π(π) bits of space means:For any π, give a streaming distinguisher S for L (a set of strings such that all pairs can be
distinguished in L) where |S| β₯ ππ π
Give a lower bound!
2
3
6.045Announcements:
- Pest 3 is due tomorrow- Midterm: March 19
4
Communication Complexity
A theoretical model of distributed computing
β’ Function f : {0,1}* Β£ {0,1}* ! {0,1}
β Two inputs, π₯ β {0,1}* and π¦ β {0,1}*
β We assume |π|=|π|=π. Think of π as HUGE
β’ Two computers: Alice and Bob
β Alice only knows π₯, Bob only knows π¦
β’ Goal: Compute f(π, π) by communicating as few bits as possible between Alice and Bob
We do not count computation cost. We only care about the number of bits communicated.
5
Alice and Bob Have a Conversation
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
A(x,0110) = STOPx y
f(x,y)=0f(x,y)=0
In every step: A bit or STOP is sent, which is a function of the partyβs input and all the bits communicated so far.
Communication cost = number of bits communicated= 4 (in the example)
We assume Alice and Bob alternate in communicating, and the last BIT sent is the value of π(x,y)
6
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
x y
f(x,y)=0f(x,y)=0
Def. A protocol computing f is a pair of functionsA, B : {0,1}* Γ {0,1}* β {0, 1, STOP} with the semantics:
On input (π, π), let π := 0, ππ := Ξ΅. While (ππ β STOP),
π + +If π is odd, Alice sends ππ = π¨ π, ππβ―ππβπ
else Bob sends ππ = π© π, ππβ―ππβπOutput ππβπ = f(π, π). Number of rounds = π β π
7
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
x y
f(x,y)=0f(x,y)=0
Def. The cost of a protocol (A,B) on π-bit strings is
π¦ππ±π,π β π,π π
[number of rounds taken by (A,B) on (π, π)]
The communication complexity of f on π-bit strings, cc(f),is min cost over all protocols computing f on π-bit strings= the minimum number of rounds used by any protocol
computing f(π, π), over all π-bit π, π
8
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
x y
f(x,y)=0f(x,y)=0
Example. Let f : {0,1}* Γ {0,1}* β {0,1} be arbitrary
There is always a βtrivialβ protocol for f:Alice sends the bits of her π in odd-numbered roundsBob sends whatever bit in even roundsAfter ππ β π rounds, Bob knows π and can send π(π, π)
Proposition: For every π, cc(π) β€ ππ
9
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
x y
f(x,y)=0f(x,y)=0
Example. PARITY(π, π) = Οπππ + Οπππ mod 2.
Whatβs a good protocol for computing PARITY?
Alice sends ππ = (Οπππ mod 2) Bob sends ππ = (ππ + Οπππ mod 2). Alice stops.
Proposition: cc(PARITY) = 2
10
x y
f(x,y)=0f(x,y)=0
Example. MAJORITY(π, π) = most frequent bit in ππModels voting in two βremoteβ locations; they want to determine a winner
Whatβs a good protocol for computing MAJORITY?
Alice sends π΅π = number of 1s in πBob computes π΅π = number of 1s in π,
sends 1 iff π΅π +π΅π is greater than (|x|+|y|)/2 = π
Proposition: cc(MAJORITY) β€ O(log π§)
11
x y
f(x,y)=0f(x,y)=0
Example. EQUALS(π, π) = 1 β π = πUseful for checking consistency of two far-apart databases!
Whatβs a good protocol for computing EQUALS?
????
12
x y
Examples:π³ = { x | x has an odd number of 1s}
β ππ³ π, π = PARITY(x,y) = Οπππ + Οπππ mod 2π³ = { x | x has at least as many 1s as 0s}
β ππ³ π, π = MAJORITY(x,y)π³ = { xx | x β {0,1}*}
β ππ³ π, π = EQUALS(x,y)
Connection to Streaming Algs and DFAs
Let π³ β {0,1}*Def. ππ³: {0,1}*Γ{0,1}*β {0,1}
for π, π with |π|=|π| as:ππ³ π, π = π β ππ β π³
13
Theorem: If π³ has a streaming alg using β€ π(π) space on inputs of length β€ ππ, then cc(ππ³) β€ πΆ(π π ).
Proof Idea: Alice runs streaming algorithm A on π, reaches a memory state π. She sends π to Bob in πΆ(π π ) rounds. Then Bob starts up A from state π, runs A on π. Gets an output bit, sends bit to Alice.
x y
Let π³ β {0,1}*Def. ππ³: {0,1}*Γ{0,1}*β {0,1}
for π, π with |π|=|π| as:ππ³ π, π = π β ππ β π³
Connection to Streaming Algs and DFAs
14
Theorem: If π³ has a streaming alg using β€ π(π) space on inputs of length β€ ππ, then cc(ππ³) β€ πΆ(π π ).
Corollary: For every regular π³, cc(ππ³) β€ O(1).
Example: cc(PARITY) = 2
Corollary: cc(MAJORITY) β€ O(log n),because thereβs a streaming algorithm for {x : x has more 1βs than 0βs} with O(log n) space
What about the Comm. Complexity of EQUALS?
Let π³ β {0,1}* Def. ππ³ π, π = π β ππ β π³
Connection to Streaming Algs and DFAs
15
Theorem: cc(EQUALS) = π―(π).In particular, every communication protocol for EQUALS must send β₯ π bits between Alice and Bob.
No communication protocol can do much better than βsend your whole inputβ!
Corollary: π³ = {xx | x in {0,1}*} is not regular.
Corollary: Every streaming algorithm for π³needs π π bits of memory, for some constant π > 0!
π(π)
Communication Complexity of EQUALS
16
Theorem: cc(EQUALS) = π―(π). In particular, everyprotocol for EQUALS needs β₯ π bits of communication!
Idea: Consider all possible ways A & B can communicate.
Definition: The communication pattern of a protocol on inputs (π, π) is the sequence of bits Alice & Bob send.
0
1
1
0
Pattern: 0110π π
Communication Complexity of EQUALS
17
A(xβ,Ξ΅) = 0
B(yβ,0) = 1
A(xβ,01) = 1
B(yβ,011) = 0
πβ πβ
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
π π
Key Lemma: If (π, π) and (πβ², πβ²) have the same pattern π·in a protocol, then (π, πβ²) and (πβ², π) also have pattern π·
18
A(xβ,Ξ΅) = 0
B(yβ,0) = 1
A(xβ,01) = 1
B(yβ,011) = 0
πβ πβ
A(x,Ξ΅) = 0
B(yβ,0) = 1
A(x,01) = 1
B(yβ,011) = 0
π π
Key Lemma: If (π, π) and (πβ², πβ²) have the same pattern π·in a protocol, then (π, πβ²) and (πβ², π) also have pattern π·
19
Key Lemma: If (π, π) and (πβ², πβ²) have the same pattern π·in a protocol, then (π, πβ²) and (πβ², π) also have pattern π·
A(x,Ξ΅) = 0
B(yβ,0) = 1
A(x,01) = 1
B(yβ,011) = 0
πβ πβ
A(x,Ξ΅) = 0
B(y,0) = 1
A(x,01) = 1
B(y,011) = 0
π π
20
Theorem: The comm. complexity of EQUALS is π―(π).In particular, every protocol for EQUALS needs β₯ π bits of communication.
Proof: By contradiction. Suppose cc(EQUALS) β€ π β π.Then there are β€ ππ β π possible communication patterns of that protocol, over all pairs of inputs (π, π) with n bits each.
Claim: There are π β π such that on (π, π) and on (π, π), the protocol uses the same pattern π·.
By the Key Lemma, (π, π) and π, π also use pattern π·
So Alice & Bob output the same bit on (π, π) and (π, π).But EQUALS(π, π) = 0 and EQUALS(π, π) = 1. Contradiction!
Communication Complexity of EQUALS
21
Randomized Protocols Help!
EQUALS needs β₯ π bits of communication, butβ¦
Theorem: There is a randomized protocol for computing EQUALS π, π using only O(log π)
bits of communication, which is correct with probability 99.9%!
23
Turing Machines
Turing Machine (1936)
FINITE
STATE
CONTROL
INFINITE REWRITABLE TAPE
I N P U T
q0q1
A β¦
24
In each step:- Reads a symbol- Writes a symbol- Changes state- Moves Left or Right
Turing Machine (1936)
INFINITE REWRITABLE TAPE
I N P U TA β¦
25
26
https://www.cs.utah.edu/~draperg/cartoons/2005/turing.html
Turing Machines versus DFAs
The TM can both write to and read from the tape,and can write symbols that arenβt part of input
The βtape headβ can move right and left
The input is written on an infinite tape
Accept and Reject take immediate effect
with βblankβ symbols after the input
27
A TM for L = { w#w | w {0,1}* } over πΊ={0,1,#}
1. If thereβs no # on the tape (or more than one #), reject.2. While there is a bit to the left of #,
Replace the first bit b with X, and check if the first bit bβto the right of the # is identical to b. (If not, reject.) Replace that bit bβ with an X too.
3. If thereβs a bit to the right of #, then reject else accept28
Definition: A Turing Machine is a 7-tuple T = (Q, Ξ£, Ξ, , q0, qaccept, qreject), where:
Q is a finite set of states
Ξ is the tape alphabet, where Ξ and Ξ£ Ξ
q0 Q is the start state
Ξ£ is the input alphabet, where Ξ£
: Q Ξ β Q Ξ {L, R}
qaccept Q is the accept state
qreject Q is the reject state, and qreject qaccept
29
= βblankβ
30
0 β 0, R
read write move
β , R
qaccept
qreject
0 β 0, R
β , R
Ξ£ = {0}
= βblankβ
31
0 β 0, R
read write move
β , R
qaccept
0 β 0, R
β , R
0 β 0, R
β , L
Ξ£ = {0}
= βblankβ
Turing Machine Configurations
q01101000110 2 (Q [ Ξ)*
corresponds to the configuration:
q0
1 0 0 0 0 01 1 1 1
32
Turing Machine Configurations
0q1101000110 2 (Q [ Ξ)*
corresponds to the configuration:
q1
1 0 0 0 0 00 1 1 1
33
Turing Machine Configurations
0000011110q7 2 (Q [ Ξ)*
corresponds to the configuration:
q7
0 0 0 1 1 00 0 1 1
34
Defining Acceptance and Rejection for TMs
Let C1 and C2 be configurations of a TM MDefinition. C1 yields C2 if M is in configuration C2
after running M in configuration C1 for one step
Example. Suppose (q1, b) = (q2, c, L)Then aq1bb yields q2acbSuppose (q1, a) = (q2, c, R)Then abq1a yields abcq2
Let w Ξ£* and M be a Turing machine.M accepts w if there are configs C0, C1, ..., Ck, s.t.
β’ C0 = q0w [the initial configuration]β’ Ci yields Ci+1 for i = 0, ..., k-1, and β’ Ck contains the accept state qaccept
35
accepting computation
history of M on x
A TM M recognizes a language L if M accepts exactly those strings in L
A TM M decides a language L if M accepts all strings in L and rejects all strings not in L
A language L is recognizable (a.k.a. recursively enumerable)
if some TM recognizes L
A language L is decidable (a.k.a. recursive)if some TM decides L
36
A Turing machine for deciding { 0 | n β₯ 0 }2n
1. Sweep from left to right, x-out every other 02. If in step 1, the tape had only one 0, accept3. If in step 1, the tape had an odd number of 0βs,
reject4. Move the head left to the first input symbol.5. Go to step 1.
Turing Machine PSEUDOCODE:
Why does this work?
37
even0βs
Step 1
odd 0βs
0 β , R
β , R
qacceptqreject
0 β x, R
x β x, R β , R
x β x, R
0 β 0, Lx β x, L
x β x, R
β , L β , R
0 β x, R0 β 0, R
β , Rx β x, R
q0 q1
q2
q3
q4
{ 0 | n β₯ 0 }2n
Step 2
Step 3
Step 4
38