math / data /lean /OAI /Combinatorics /IndependentSets /PCP /AmplificationIteration.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
3.71 kB
import Mathlib
namespace OAI
namespace IndependentSetsGames.Foundations.PCP.AmplificationIteration
def run {X : Type*} (step : X β†’ X) : Nat β†’ X β†’ X
| 0, x => x
| n + 1, x => step (run step n x)
private theorem min_double_min (u cap : ℝ) (hc : 0 ≀ cap) :
min (2 * min u cap) cap = min (2 * u) cap := by
by_cases hu : u ≀ cap
Β· rw [min_eq_left hu]
Β· have hcu : cap ≀ u := le_of_not_ge hu
rw [min_eq_right hcu, min_eq_right (by linarith : cap ≀ 2 * cap),
min_eq_right (by linarith : cap ≀ 2 * u)]
theorem run_gap {X : Type*} (step : X β†’ X) (gap : X β†’ ℝ)
(cap : ℝ) (hc : 0 ≀ cap)
(amplifies : βˆ€ x, min (2 * gap x) cap ≀ gap (step x))
(n : Nat) (x : X) :
min (2 ^ n * gap x) cap ≀ gap (run step n x) := by
induction n with
| zero => simp [run]
| succ n ih =>
have hm : min (2 * min (2 ^ n * gap x) cap) cap ≀
min (2 * gap (run step n x)) cap :=
min_le_min (mul_le_mul_of_nonneg_left ih (by norm_num)) le_rfl
rw [min_double_min _ _ hc] at hm
have h := hm.trans (amplifies (run step n x))
simpa [run, pow_succ, mul_assoc, mul_left_comm, mul_comm] using h
theorem run_preserves {X : Type*} (step : X β†’ X) (P : X β†’ Prop)
(preserves : βˆ€ x, P x β†’ P (step x)) (n : Nat) (x : X) (hx : P x) :
P (run step n x) := by
induction n with
| zero => exact hx
| succ n ih => exact preserves _ ih
theorem run_size {X : Type*} (step : X β†’ X) (size : X β†’ Nat) (C : Nat)
(blowup : βˆ€ x, size (step x) ≀ C * size x) (n : Nat) (x : X) :
size (run step n x) ≀ C ^ n * size x := by
induction n with
| zero => simp [run]
| succ n ih =>
have h := (blowup (run step n x)).trans (Nat.mul_le_mul_left C ih)
simpa [run, pow_succ, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using h
def rounds (n : Nat) : Nat := Nat.log2 n + 1
theorem rounds_large (n : Nat) : n < 2 ^ rounds n := by
simpa [rounds, Nat.log2_eq_log_two] using
(Nat.lt_pow_succ_log_self (by decide : 1 < 2) n)
theorem rounds_power_le {n : Nat} (hn : 0 < n) : 2 ^ rounds n ≀ 2 * n := by
have h := Nat.pow_log_le_self 2 (Nat.ne_of_gt hn)
simpa [rounds, Nat.log2_eq_log_two, pow_succ, Nat.mul_comm] using
(Nat.mul_le_mul_right 2 h)
theorem blowup_rounds_le {C degree n : Nat} (hn : 0 < n) (hC : C ≀ 2 ^ degree) :
C ^ rounds n ≀ (2 * n) ^ degree := by
calc
C ^ rounds n ≀ (2 ^ degree) ^ rounds n := Nat.pow_le_pow_left hC _
_ = (2 ^ rounds n) ^ degree := by
rw [← pow_mul, ← pow_mul, Nat.mul_comm degree (rounds n)]
_ ≀ (2 * n) ^ degree := Nat.pow_le_pow_left (rounds_power_le hn) _
theorem run_size_polynomial {X : Type*} (step : X β†’ X) (size : X β†’ Nat)
{C degree n : Nat} (hn : 0 < n) (hC : C ≀ 2 ^ degree)
(blowup : βˆ€ x, size (step x) ≀ C * size x) (x : X) :
size (run step (rounds n) x) ≀ (2 * n) ^ degree * size x :=
(run_size step size C blowup (rounds n) x).trans
(Nat.mul_le_mul_right _ (blowup_rounds_le hn hC))
theorem run_reaches_cap {X : Type*} (step : X β†’ X) (gap : X β†’ ℝ)
(cap : ℝ) (hc : 0 ≀ cap) (hc1 : cap ≀ 1)
(amplifies : βˆ€ x, min (2 * gap x) cap ≀ gap (step x))
(n : Nat) (x : X) (hg : 0 ≀ gap x) (hstart : 1 ≀ (n : ℝ) * gap x) :
cap ≀ gap (run step (rounds n) x) := by
have hp : (n : ℝ) ≀ (2 : ℝ) ^ rounds n := by
exact_mod_cast (Nat.le_of_lt (rounds_large n))
have hcap : cap ≀ (2 : ℝ) ^ rounds n * gap x :=
hc1.trans (hstart.trans (mul_le_mul_of_nonneg_right hp hg))
have h := run_gap step gap cap hc amplifies (rounds n) x
rwa [min_eq_right hcap] at h
end IndependentSetsGames.Foundations.PCP.AmplificationIteration
end OAI