| import Mathlib |
|
|
| /-! |
| # Problem 3: Two-stage stick cutting game |
|
|
| Lean 4 + Mathlib formalisation scaffold. |
|
|
| The elementary algebra relating the alternating gap to Liu's odd-position |
| share, and the closed-form simplification of the answer, are fully proved. |
| The two deep finite-combinatorial lemmas (subset-sum pairing upper bound and |
| binary-tree/multigraph lower bound) are stated with `sorry`. |
| -/ |
|
|
| set_option autoImplicit false |
|
|
| namespace Problem3 |
|
|
| / |
| def altGap : List β β β |
| | [] => 0 |
| | [x] => x |
| | x :: y :: xs => x - y + altGap xs |
|
|
| / |
| def oddSum : List β β β |
| | [] => 0 |
| | [x] => x |
| | x :: _y :: xs => x + oddSum xs |
|
|
| / |
| theorem sum_add_altGap_eq_two_oddSum : |
| β xs : List β, xs.sum + altGap xs = 2 * oddSum xs |
| | [] => by simp [altGap, oddSum] |
| | [x] => by simp [altGap, oddSum] |
| | x :: y :: xs => by |
| simp [altGap, oddSum, sum_add_altGap_eq_two_oddSum xs] |
| ring |
|
|
| / |
| theorem oddSum_eq_half_sum_add_gap (xs : List β) : |
| oddSum xs = (xs.sum + altGap xs) / 2 := by |
| have h := sum_add_altGap_eq_two_oddSum xs |
| linarith |
|
|
| / |
| def delta (n : β) : β := |
| 1 / ((2 : β)^(n+1) - 1) |
|
|
| / |
| def claimedValue (n : β) : β := |
| (1 + delta n) / 2 |
|
|
| / |
| theorem claimedValue_closed_form (n : β) : |
| claimedValue n = (2 : β)^n / ((2 : β)^(n+1) - 1) := by |
| unfold claimedValue delta |
| rw [pow_succ] |
| have hden : (2 : β)^n * 2 - 1 β 0 := by positivity |
| field_simp [hden] |
| ring |
|
|
| / |
| If all but residual mass `R` can be grouped into equal pairs, the second |
| player can secure one member of every pair, so the first player receives at |
| most `(total + R)/2`. |
| -/ |
| theorem paired_mass_upper_bound |
| (total residual firstShare : β) |
| (hbound : firstShare β€ (total - residual) / 2 + residual) : |
| firstShare β€ (total + residual) / 2 := by |
| linarith |
|
|
| / |
| Subset-sum core of Xiang's upper bound. Among the `2^(n+1)` subset sums, |
| two distinct sums differ by at most `delta n`; deleting their common indices |
| gives disjoint subsets with nonempty symmetric difference. |
| -/ |
| theorem disjoint_subset_close_sums |
| (n : β) |
| (a : Fin (n+1) β β) |
| (hnonneg : β i, 0 β€ a i) |
| (hsum : β i, a i = 1) : |
| β P Q : Finset (Fin (n+1)), |
| Disjoint P Q β§ |
| (P βͺ Q).Nonempty β§ |
| |(β i β P, a i) - (β i β Q, a i)| β€ delta n := by |
| sorry |
|
|
| / |
| def IsDescending {m : β} (x : Fin m β β) : Prop := |
| β i j, i.1 β€ j.1 β x j β€ x i |
|
|
| / |
| Lower-bound combinatorial core. |
|
|
| The final pieces are indexed in nonincreasing order by `x`. `origin j` records |
| which initial binary piece produced the final piece `j`. The mass condition |
| says that the pieces of origin `i` sum to `2^i`. If at most `n` extra cuts |
| were made, then `m β€ 2n+1`, and the alternating gap is at least `1`. |
| -/ |
| theorem binary_partition_altGap_lower_bound |
| (n m : β) |
| (x : Fin m β β) |
| (origin : Fin m β Fin (n+1)) |
| (hxnonneg : β j, 0 β€ x j) |
| (hxsorted : IsDescending x) |
| (hm : m β€ 2*n + 1) |
| (hmass : β i : Fin (n+1), |
| (β j : Fin m, if origin j = i then x j else 0) = |
| (2 : β)^i.1) : |
| 1 β€ altGap (List.ofFn x) := by |
| sorry |
|
|
| / |
| theorem value_from_matching_bounds |
| (n : β) (v : β) |
| (hlower : claimedValue n β€ v) |
| (hupper : v β€ claimedValue n) : |
| v = (2 : β)^n / ((2 : β)^(n+1) - 1) := by |
| have hv : v = claimedValue n := le_antisymm hupper hlower |
| rw [hv, claimedValue_closed_form] |
|
|
| end Problem3 |
|
|