Lecture7 Randomized Algorithms
Lecture7 Randomized Algorithms
FACULTY OF ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
𝑋 = 𝑥! 𝑥" … 𝑥# , 𝑥$ ∈ {0,1}
𝑌 = 𝑦! 𝑦" … 𝑦# , 𝑦$ ∈ {0,1}
Question: 𝑋 =? 𝑌
Comparison overhead:
The Equal algorithm is a randomized communication protocol for the data comparison example.
It drastically reduces the comparison effort. Comparison overhead was previously 𝑂(𝑛), now
the overhead is reduced to 5 𝑠𝑡𝑒𝑝𝑠 → 𝑂(1)
Communication overhead:
0 ≤ 𝑝, 𝑠 ≤ 𝑛²
𝑚 ∈ ℕ → ⌈log 𝑚⌉ 𝐵𝑖𝑡𝑠
𝑙(𝑠, 𝑝) ≤ 2 ∗ ⌈log 𝑛" ⌉ ≤ 4 ∗ ⌈log 𝑛⌉
For 𝑛 = 10!& ;
≤ 4 ∗ 16 ∗⌈log 10⌉
≤ 4 ∗ 16 ∗ 4
= 256 Bits
𝑃𝑟𝑜𝑏()*+, [𝐴 | 𝐵 ]
𝑋 = 𝑌 => 𝑡 = 𝑠
𝑋 ≠ 𝑌 <= 𝑡 ≠ 𝑠
Example:
𝑛=5
𝑋 = 10011 𝑣 (𝑋) = 19
𝑌 = 10001 𝑣(𝑌) = 17
𝑓𝑜𝑟 𝑝 = 11 => s = 8, t = 6
𝑋 = 10011 𝑣 (𝑋) = 19
𝑌 = 10001 𝑣(𝑌) = 17
𝑓𝑜𝑟 𝑝 = 2 => s = 1, t = 1
Establishing the relationship between bad witnesses and total witness candidates:
2 ln 10!&
𝑓𝑜𝑟 𝑛 = 10!& => ≈ 0.7 ∗ 10'!.
10!&
𝑂(𝑙 ∗ log 𝑛)
𝐿 ⊆ Σ ∗ , 𝑤 ∈ Σ ∗ : 𝑤 ∈? 𝐿
𝐺 = (𝑉, 𝐸)
|𝑉| = 𝑛, |𝐸| = 𝑚
3 1
𝑃𝑟𝑜𝑏4 ["𝑦𝑒𝑠 𝑖𝑛 𝑜𝑛𝑒 𝑟𝑜𝑢𝑛𝑑" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ ∗
𝑚 𝑛−2
3
𝑃𝑟𝑜𝑏4 ["𝑛𝑜 𝑖𝑛 𝑜𝑛𝑒 𝑟𝑜𝑢𝑛𝑑" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≤ 1 −
𝑚(𝑛 − 2)
,
3
𝑃𝑟𝑜𝑏4 ["𝑛𝑜 𝑖𝑛 𝑙 𝑟𝑜𝑢𝑛𝑑𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≤ Ž1 − •
𝑚(𝑛 − 2)
,
3
𝑃𝑟𝑜𝑏4 ["𝑦𝑒𝑠 𝑖𝑛 𝑙 𝑟𝑜𝑢𝑛𝑑𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ 1 − Ž1 − •
𝑚(𝑛 − 2)
1 5 5→7 !
Ž1 + • ‘⎯“ 𝑒 = 2.7182 …
𝑘
𝑥 5 5→7
”1 + • ‘⎯“ 𝑒 8
𝑘
Place a minus before x:
−𝑥 5 5→7 '8
”1 + • ‘⎯“ 𝑒
𝑘
We want to apply the Euler sequence for our probabilistic ∆𝐺𝑟𝑎𝑝ℎ algorithm:
,→7
𝑘 = 𝑙, 𝑥 = 𝑦𝑙 è (1 − 𝑦), ‘⎯“ 𝑒 '9,
: ;(#'")
𝑦 = ;(#'") , 𝑙 = :
è𝑦∗𝑙 =1
;(#'")
3 : 1 1 1
Ž1 − • ≈ 𝑒 '! ≈ ≈ <
𝑚(𝑛 − 2) 𝑒 2.7 2
RP
1. 𝑃𝑟𝑜𝑏4 ["𝑦𝑒𝑠" | 𝐺 ∉ ∆𝐺𝑟𝑎𝑝ℎ] = 0
!
2. 𝑃𝑟𝑜𝑏4 ["𝑦𝑒𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ "
3. 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑒𝑙
2#'! = 1(𝑛)
𝑛 = 3, 4, 5 …
Definition: Let 𝑚 be a composite number with (𝑎, 𝑚) = 1 and 𝑎;'! = 1(𝑚) or 𝑎; = 𝑎(𝑚),
then 𝑚 is called pseudoprime to base 𝑎
In other words: Pseudoprime numbers satisfy Fermat's little theorem even though they are not
prime
𝐹; = {𝑎 ∈ ℤ; | 𝑎𝑚−1 = 1(𝑚)}
If 𝑚 is not a prime number, then 𝐹; contains the bases that “fool” the Fermat test.
Let m ∈ ℕ, m ≥ 3, be a composite and not a Carmichael number, then the following applies:
ℤ;
|𝐹; | ≤
2
alg notPrime (𝒌 ∈ 𝑼( , 𝒌 ≥ 𝟑)
If 𝒂𝒌"𝟏 ≠ 𝟏(𝒌)
then Output: 𝒌 𝒊𝒔 𝒏𝒐𝒕 𝒑𝒓𝒊𝒎𝒆
otherwise Output: 𝒌 𝒑𝒓𝒊𝒎𝒆?
endalg
ℙ = COMPOSITES ∈ RPP
K |𝑘 ∉ℙ
(1) 𝑃𝑟𝑜𝑏[𝑘 ∈ ℙ K] = 0
#
K|𝑘 ∈ℙ
(2) 𝑃𝑟𝑜𝑏[𝑘 ∉ ℙ K] ≤
+
!
The probability of error is therefore at most ". If the algorithm is now carried out for l rounds
in which the base a is chosen anew at random and independently, then the probability of error
!
is at most "! ; so, it can be made as small as you want.
#
è Executing the algorithm 𝑙 times leads to an error probability of ≤ +!
ℤ; 𝑖𝑠 𝑎 𝑓𝑖𝑒𝑙𝑑 iff 𝑚 ∈ ℙ
𝑥" = 1
In other words: If there is a nontrivial square root modulo 𝑚, then m is a composite number.
𝑚∈ℕ
𝑠 = 𝑚𝑎𝑥{ 𝑟 ∈ ℕ | 2? | 𝑚 − 1}
;'!
𝑑= ""
𝑏 ∈ ℤ; : 𝑏 − 𝑠𝑒𝑞𝑢𝑒𝑛𝑐𝑒
# $ % "&$ @ "
〈𝑏 " @ , 𝑏 " @ , 𝑏 " @ , … , 𝑏 " , 𝑏 " @ 〉 𝑚𝑜𝑑 (𝑚)
If 𝑚 ∈ ℙ:
è We get more information about the structure of the b-sequence if m is a prime number:
Examples:
a) Let m=25 (i.e., composite), then s=3 and d=3. For the basis b=2 the sequence results
and for 𝑏 = 7
b) Let m=97 (i.e., prime), then s=5 and d=3. For the basis b=2 the sequence results
for 𝑏 = 35
and for 𝑏 = 62
è The examples show that the b-sequences for prime numbers have a specific structure.
>'!
Theorem: 𝐿𝑒𝑡 𝑏𝑒 𝑝 ∈ ℙ, 𝑠 = 𝑚𝑎𝑥{𝑟 | 2? | 𝑝 − 1}, 𝑑 = ""
, 𝑏 ∈ ℕ 𝑤𝑖𝑡ℎ (𝑏, 𝑝) = 1
𝑚 ∈ ℕ, 𝑏 ∈ ℤ; , 𝑤𝑖𝑡ℎ 𝑏 − 𝑠𝑒𝑞𝑢𝑒𝑛𝑐𝑒
è𝑚∉ℙ
Definition: 𝑚 ∈ 𝑈- , 𝑚 ≥ 3, 𝑚 − 1 = 2C 𝑑 𝑤𝑖𝑡ℎ 𝑑 ∈ 𝑈- , 𝑏 ∈ ℤ;
(@
If 𝑏 @ = 1(𝑚) or 𝑏 " = −1(𝑚) holds for an 𝑟 ∈ {0, 1, … , 𝑠 − 1}, then 𝑚 is called strong
pseudoprime to base 𝑏.
#
(3) 𝑃𝑟𝑜𝑏[𝑙 − 𝑡𝑖𝑚𝑒𝑠 𝑂𝑢𝑡𝑝𝑢𝑡: 𝑛 𝑖𝑠 𝑝𝑟𝑖𝑚𝑒? | 𝑛 ∉ ℙ] ≤ ,!
#
(4) 𝑃𝑟𝑜𝑏[𝑎𝑓𝑡𝑒𝑟 𝑙 𝑒𝑥𝑐𝑒𝑐𝑢𝑡𝑖𝑜𝑛𝑠 𝑂𝑢𝑡𝑝𝑢𝑡: 𝑛 𝑖𝑠 𝑛𝑜𝑡 𝑝𝑟𝑖𝑚𝑒 | 𝑛 ∉ ℙ] ≥ 1 − ,!
(5) 𝑂[𝑙 ∗ (log 𝑛)` arithmetical operations or 𝑂(𝑙 ∗ (log 𝑛)³) bit operations
Outline:
2 ln 𝑛
𝐷𝑎𝑡𝑎𝑠𝑒𝑡 ∈ 𝑅𝑃 Ž •
𝑛
1
∆𝐺𝑟𝑎𝑝ℎ ∈ 𝑅𝑃 Ž •
2
1
𝑀𝑖𝑙𝑙𝑒𝑟 𝑅𝑎𝑏𝑖𝑛 ∈ 𝑅𝑃 Ž •
4
ð The algorithms that class RP defines are also called Monte Carlo algorithms. Such
algorithms allow a one-sided error.