Lecture7_Randomized-Algorithms (1)
Lecture7_Randomized-Algorithms (1)
FACULTY OF ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
𝑋 = 𝑥1 𝑥2 … 𝑥𝑛 , 𝑥𝑖 ∈ {0,1}
𝑌 = 𝑦1 𝑦2 … 𝑦𝑛 , 𝑦𝑖 ∈ {0,1}
Question: 𝑋 =? 𝑌
𝐼𝑛𝑝𝑢𝑡: 𝑋 = 𝑥1 𝑥2 … 𝑥𝑛 , 𝑌 = 𝑦1 𝑦2 … 𝑦𝑛 , 𝑥𝑖 𝑦𝑖 ∈ {0,1}
𝐴 𝐵
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 𝑛2 ⌉ ≤ 4 ∗ ⌈log 𝑛⌉
For 𝑛 = 1016 ;
≤ 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 1016
𝑓𝑜𝑟 𝑛 = 1016 => ≈ 0.7 ∗ 10−14
1016
𝑂(𝑙 ∗ log 𝑛)
𝐿 ⊆ Σ ∗ , 𝑤 ∈ Σ ∗ : 𝑤 ∈? 𝐿
𝐺 = (𝑉, 𝐸)
|𝑉| = 𝑛, |𝐸| = 𝑚
3 1
𝑃𝑟𝑜𝑏𝑇 ["𝑦𝑒𝑠 𝑖𝑛 𝑜𝑛𝑒 𝑟𝑜𝑢𝑛𝑑" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ ∗
𝑚 𝑛−2
3
𝑃𝑟𝑜𝑏𝑇 ["𝑛𝑜 𝑖𝑛 𝑜𝑛𝑒 𝑟𝑜𝑢𝑛𝑑" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≤ 1 −
𝑚(𝑛 − 2)
𝑙
3
𝑃𝑟𝑜𝑏𝑇 ["𝑛𝑜 𝑖𝑛 𝑙 𝑟𝑜𝑢𝑛𝑑𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≤ (1 − )
𝑚(𝑛 − 2)
𝑙
3
𝑃𝑟𝑜𝑏𝑇 ["𝑦𝑒𝑠 𝑖𝑛 𝑙 𝑟𝑜𝑢𝑛𝑑𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ 1 − (1 − )
𝑚(𝑛 − 2)
1 𝑘 𝑘→∞ 1
(1 + ) → 𝑒 = 2.7182 …
𝑘
𝑥 𝑘 𝑘→∞
(1 + ) → 𝑒 𝑥
𝑘
Place a minus before x:
−𝑥 𝑘 𝑘→∞ −𝑥
(1 + ) → 𝑒
𝑘
We want to apply the Euler sequence for our probabilistic ∆𝐺𝑟𝑎𝑝ℎ algorithm:
𝑙→∞
𝑘 = 𝑙, 𝑥 = 𝑦𝑙 ➔ (1 − 𝑦)𝑙 → 𝑒 −𝑦𝑙
3 𝑚(𝑛−2)
𝑦 = 𝑚(𝑛−2) , 𝑙 = ➔𝑦∗𝑙 =1
3
𝑚(𝑛−2)
3 3 1 1 1
(1 − ) ≈ 𝑒 −1 ≈ ≈ <
𝑚(𝑛 − 2) 𝑒 2.7 2
RP
1. 𝑃𝑟𝑜𝑏𝑇 ["𝑦𝑒𝑠" | 𝐺 ∉ ∆𝐺𝑟𝑎𝑝ℎ] = 0
1
2. 𝑃𝑟𝑜𝑏𝑇 ["𝑦𝑒𝑠" | 𝐺 ∈ ∆𝐺𝑟𝑎𝑝ℎ] ≥ 2
3. 𝑝𝑜𝑙𝑦𝑛𝑜𝑚𝑖𝑒𝑙
2𝑛−1 = 1(𝑛)
𝑛 = 3, 4, 5 …
Definition: Let 𝑚 be a composite number with (𝑎, 𝑚) = 1 and 𝑎𝑚−1 = 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
̅|𝑘 ∉ℙ
(1) 𝑃𝑟𝑜𝑏[𝑘 ∈ ℙ ̅] = 0
̅] ≤ 1
̅|𝑘 ∈ℙ
(2) 𝑃𝑟𝑜𝑏[𝑘 ∉ ℙ 2
1
The probability of error is therefore at most 2. 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
1
is at most 2𝑙; so, it can be made as small as you want.
1
➔ Executing the algorithm 𝑙 times leads to an error probability of ≤ 2𝑙
ℤ𝑚 𝑖𝑠 𝑎 𝑓𝑖𝑒𝑙𝑑 iff 𝑚 ∈ ℙ
𝑥2 = 1
In other words: If there is a nontrivial square root modulo 𝑚, then m is a composite number.
𝑚∈ℕ
𝑠 = 𝑚𝑎𝑥{ 𝑟 ∈ ℕ | 2𝑟 𝑚 − 1}
𝑚−1
𝑑= 2𝑠
𝑏 ∈ ℤ𝑚 : 𝑏 − 𝑠𝑒𝑞𝑢𝑒𝑛𝑐𝑒
0 1 2 𝑠−1 𝑑 𝑠
〈𝑏 2 𝑑 , 𝑏 2 𝑑 , 𝑏 2 𝑑 , … , 𝑏 2 , 𝑏 2 𝑑 〉 𝑚𝑜𝑑 (𝑚)
If 𝑚 ∈ ℙ:
𝑠𝑑 𝑠 ∗𝑚−1
𝑏2 = 𝑏2 2𝑠 = 𝑏 𝑚−1 = 1(𝑚)
𝑝−1
Theorem: 𝐿𝑒𝑡 𝑏𝑒 𝑝 ∈ ℙ, 𝑠 = 𝑚𝑎𝑥{𝑟 | 2𝑟 𝑝 − 1}, 𝑑 = , 𝑏 ∈ ℕ 𝑤𝑖𝑡ℎ (𝑏, 𝑝) = 1
2𝑠
Then (1) 𝑏 𝑑 = 1 (𝑝) or
𝑟𝑑
(2) ∃𝑟 ∈ {0, 1, … , 𝑠 − 1}: 𝑏 2 = −1 (𝑝)
𝑚 ∈ ℕ, 𝑏 ∈ ℤ𝑚 , 𝑤𝑖𝑡ℎ 𝑏 − 𝑠𝑒𝑞𝑢𝑒𝑛𝑐𝑒
➔𝑚∉ℙ
Definition: 𝑚 ∈ 𝑈+ , 𝑚 ≥ 3, 𝑚 − 1 = 2𝑠 𝑑 𝑤𝑖𝑡ℎ 𝑑 ∈ 𝑈+ , 𝑏 ∈ ℤ𝑚
𝑟𝑑
If 𝑏 𝑑 = 1(𝑚) or 𝑏 2 = −1(𝑚) holds for an 𝑟 ∈ {0, 1, … , 𝑠 − 1}, then 𝑚 is called strong
pseudoprime to base 𝑏.
1
(3) 𝑃𝑟𝑜𝑏[𝑙 − 𝑡𝑖𝑚𝑒𝑠 𝑂𝑢𝑡𝑝𝑢𝑡: 𝑛 𝑖𝑠 𝑝𝑟𝑖𝑚𝑒? | 𝑛 ∉ ℙ] ≤
4𝑙
1
(4) 𝑃𝑟𝑜𝑏[𝑎𝑓𝑡𝑒𝑟 𝑙 𝑒𝑥𝑐𝑒𝑐𝑢𝑡𝑖𝑜𝑛𝑠 𝑂𝑢𝑡𝑝𝑢𝑡: 𝑛 𝑖𝑠 𝑛𝑜𝑡 𝑝𝑟𝑖𝑚𝑒 | 𝑛 ∉ ℙ] ≥ 1 −
4𝑙
(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.