File size: 3,952 Bytes
b9bf371 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | 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
/-- Alternating gap of a list already sorted in nonincreasing order. -/
def altGap : List β β β
| [] => 0
| [x] => x
| x :: y :: xs => x - y + altGap xs
/-- Sum of entries in odd positions (positions 1,3,5,...). -/
def oddSum : List β β β
| [] => 0
| [x] => x
| x :: _y :: xs => x + oddSum xs
/-- `sum + alternating gap = 2 Γ odd-position sum`. -/
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
/-- Odd-position sum in terms of total mass and alternating gap. -/
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
/-- The small residual allowed by Xiang's subset-sum construction. -/
def delta (n : β) : β :=
1 / ((2 : β)^(n+1) - 1)
/-- Claimed minimax value before simplification. -/
def claimedValue (n : β) : β :=
(1 + delta n) / 2
/-- Closed form of the answer. -/
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
/-- A finite sequence is written in nonincreasing order. -/
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
/-- Once matching lower and upper bounds are available, the value is fixed. -/
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
|