Offline · exact source
Exact Lean source

YoungRSKReverse

formalization/Cloning/YoungRSKReverse.lean

Source hash: cd45e7aec986853723f4af3755a489f107f838418b7786a847606a335aa8da24

Full source copied without mathematical changes from the snapshot whose input hash matches the passing audit. Select a line number for a stable source pointer.

The declarations belong to the compiled inventory covered by the project’s shared axiom audit. That audit records an aggregate union, without attributing axioms to individual declarations.

Declarations in this module
1import Cloning.YoungRSKInsertion
2 
3/-!
4# Reverse row insertion preserves adjacent column inequalities
5 
6An occupied letter in a lower row guarantees an available smaller letter
7in the row above. The selected reverse operations preserve the literal
8strict-column prefix inequalities, both at a terminal deletion and along
9the reverse bumping path.
10-/
11 
12noncomputable section
13open scoped BigOperators Classical
14namespace Cloning.YoungGeneral
15 
16theorem rowReverseBump_exists_of_prefix {d : ℕ} (U V : RowContent d) (b : Fin d)
17    (hUV : ∀ k, rowPrefix V k ≤ rowStrictPrefix U k) (hb : 0 < V b) :
18    ∃ a, rowReverseBump U b = some a := by
19  have hb' : V b ≤ rowPrefix V b := by
20    exact Finset.single_le_sum (fun _ _ => Nat.zero_le _)
21      (show b ∈ Finset.univ.filter (fun j => j ≤ b) by simp)
22  have hp : 0 < rowStrictPrefix U b := hb.trans_le (hb'.trans (hUV b))
23  obtain ⟨a, ha, hUa⟩ := Finset.sum_pos_iff.mp hp
24  have hs : (rowReverseCandidates U b).Nonempty := by
25    refine ⟨a, ?_⟩
26    simpa only [rowReverseCandidates, Finset.mem_filter, Finset.mem_univ, true_and]
27      using And.intro ((Finset.mem_filter.mp ha).2) hUa
28  exact ⟨_, by rw [rowReverseBump, dif_pos hs]⟩
29 
30theorem rowReversed_prefix {d : ℕ} (A : RowContent d) (y x k : Fin d)
31    (h : rowReverseBump A y = some x) :
32    rowPrefix (rowReversed A y) k + (if x ≤ k ∧ k < y then 1 else 0) =
33      rowPrefix A k := by
34  obtain ⟨hxy, hx, _⟩ := (rowReverseBump_eq_some_iff A y x).mp h
35  simp only [rowReversed, h]
36  have he := rowReplace_sum A y x (ne_of_lt hxy).symm hx
37    (Finset.univ.filter (fun j => j ≤ k))
38  simp only [Finset.mem_filter, Finset.mem_univ, true_and] at he
39  change rowPrefix (rowReplace A y x) k + (if x ≤ k then 1 else 0) =
40    rowPrefix A k + (if y ≤ k then 1 else 0) at he
41  split_ifs at he ⊢ <;> omega
42 
43theorem rowReversed_strictPrefix {d : ℕ} (A : RowContent d) (y x k : Fin d)
44    (h : rowReverseBump A y = some x) :
45    rowStrictPrefix (rowReversed A y) k + (if x < k ∧ k ≤ y then 1 else 0) =
46      rowStrictPrefix A k := by
47  obtain ⟨hxy, hx, _⟩ := (rowReverseBump_eq_some_iff A y x).mp h
48  simp only [rowReversed, h]
49  have he := rowReplace_sum A y x (ne_of_lt hxy).symm hx
50    (Finset.univ.filter (fun j => j < k))
51  simp only [Finset.mem_filter, Finset.mem_univ, true_and] at he
52  change rowStrictPrefix (rowReplace A y x) k + (if x < k then 1 else 0) =
53    rowStrictPrefix A k + (if y < k then 1 else 0) at he
54  split_ifs at he ⊢ <;> omega
55 
56theorem rowRemove_content {d : ℕ} (A : RowContent d) (x j : Fin d) (hx : 0 < A x) :
57    rowRemove A x j + (if j = x then 1 else 0) = A j := by
58  by_cases hj : j = x
59  · subst j
60    simp only [rowRemove, Function.update_self, if_true]
61    omega
62  · simp [rowRemove, hj]
63 
64theorem rowRemove_prefix {d : ℕ} (A : RowContent d) (x k : Fin d) (hx : 0 < A x) :
65    rowPrefix (rowRemove A x) k + (if x ≤ k then 1 else 0) = rowPrefix A k := by
66  have he := Finset.sum_congr
67    (s₁ := Finset.univ.filter (fun j => j ≤ k)) rfl
68    (fun j _ => rowRemove_content A x j hx)
69  simpa only [rowPrefix, Finset.sum_add_distrib, Finset.sum_ite_eq',
70    Finset.mem_filter, Finset.mem_univ, true_and] using he
71 
72theorem rowPrefix_slack {d : ℕ} (A : RowContent d) (k b : Fin d)
73    (hkb : k < b) (hb : 0 < A b) : rowPrefix A k + 1 ≤ rowPrefix A b := by
74  have hs : insert b (Finset.univ.filter (fun j => j ≤ k)) ⊆
75      Finset.univ.filter (fun j => j ≤ b) := by
76    intro j hj
77    simp only [Finset.mem_insert, Finset.mem_filter, Finset.mem_univ, true_and] at hj ⊢
78    rcases hj with rfl | hj
79    · exact le_rfl
80    · exact hj.trans hkb.le
81  have he := Finset.sum_le_sum_of_subset (f := A) hs
82  rw [Finset.sum_insert (by simp [not_le_of_gt hkb])] at he
83  change A b + rowPrefix A k ≤ rowPrefix A b at he
84  omega
85 
86theorem rowStrictPrefix_eq_of_no_entries {d : ℕ} (A : RowContent d) (k b : Fin d)
87    (hkb : k ≤ b) (hzero : ∀ j, k ≤ j → j < b → A j = 0) :
88    rowStrictPrefix A b = rowStrictPrefix A k := by
89  symm
90  apply Finset.sum_subset
91  · intro j hj
92    simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hj ⊢
93    exact hj.trans_le hkb
94  · intro j hj hjnot
95    simp only [Finset.mem_filter, Finset.mem_univ, true_and, not_lt] at hj hjnot
96    exact hzero j hjnot hj
97 
98theorem rowStrictPrefix_eq_at_reverse {d : ℕ} (U : RowContent d) (b a k : Fin d)
99    (h : rowReverseBump U b = some a) (hak : a < k) (hkb : k ≤ b) :
100    rowStrictPrefix U b = rowStrictPrefix U k := by
101  apply rowStrictPrefix_eq_of_no_entries U k b hkb
102  intro j hkj hjb
103  have hmax := ((rowReverseBump_eq_some_iff U b a).mp h).2.2
104  by_contra hj
105  exact (not_le_of_gt (hak.trans_le hkj)) (hmax j hjb (Nat.pos_of_ne_zero hj))
106 
107/-- A reverse step in the upper row preserves interlacing with any lower
108row whose prefixes decrease and whose prefix at the returned letter drops. -/
109theorem rowReversed_interlaces_of_prefix {d : ℕ}
110    (U V W : RowContent d) (b a : Fin d)
111    (hUV : ∀ k, rowPrefix V k ≤ rowStrictPrefix U k)
112    (hb : 0 < V b) (hrev : rowReverseBump U b = some a)
113    (hWV : ∀ k, rowPrefix W k ≤ rowPrefix V k)
114    (hdrop : rowPrefix W b + 1 ≤ rowPrefix V b) :
115    ∀ k, rowPrefix W k ≤ rowStrictPrefix (rowReversed U b) k := by
116  intro k
117  have he := rowReversed_strictPrefix U b a k hrev
118  by_cases hk : a < k ∧ k ≤ b
119  · rw [if_pos hk] at he
120    have hflat := rowStrictPrefix_eq_at_reverse U b a k hrev hk.1 hk.2
121    have hslack : rowPrefix W k + 1 ≤ rowPrefix V b := by
122      rcases lt_or_eq_of_le hk.2 with hkb | rfl
123      · exact (Nat.add_le_add_right (hWV k) 1).trans (rowPrefix_slack V k b hkb hb)
124      · exact hdrop
125    have hupper := hUV b
126    omega
127  · rw [if_neg hk, add_zero] at he
128    rw [he]
129    exact (hWV k).trans (hUV k)
130 
131theorem rowReversed_interlaces_remove {d : ℕ} (U V : RowContent d) (b a : Fin d)
132    (hUV : ∀ k, rowPrefix V k ≤ rowStrictPrefix U k)
133    (hb : 0 < V b) (hrev : rowReverseBump U b = some a) :
134    ∀ k, rowPrefix (rowRemove V b) k ≤ rowStrictPrefix (rowReversed U b) k := by
135  apply rowReversed_interlaces_of_prefix U V (rowRemove V b) b a hUV hb hrev
136  · intro k
137    have he := rowRemove_prefix V b k hb
138    omega
139  · have he := rowRemove_prefix V b b hb
140    simpa only [le_refl, if_true] using he.le
141 
142theorem rowReversed_interlaces_reverse {d : ℕ} (U V : RowContent d) (c b a : Fin d)
143    (hUV : ∀ k, rowPrefix V k ≤ rowStrictPrefix U k)
144    (hV : rowReverseBump V c = some b) (hU : rowReverseBump U b = some a) :
145    ∀ k, rowPrefix (rowReversed V c) k ≤ rowStrictPrefix (rowReversed U b) k := by
146  obtain ⟨hbc, hb, _⟩ := (rowReverseBump_eq_some_iff V c b).mp hV
147  apply rowReversed_interlaces_of_prefix U V (rowReversed V c) b a hUV hb hU
148  · intro k
149    have he := rowReversed_prefix V c b k hV
150    omega
151  · have he := rowReversed_prefix V c b b hV
152    simpa only [le_refl, hbc, and_self, if_true] using he.le
153 
154end Cloning.YoungGeneral