bpe_three_two_step_bound_of_numeric_bounds
For two greedy steps s to u to v, if the optimal three-merge utility is at most the two-merge optimum plus the initial maximum pair count, and the two-merge optimum is at most the initial maximum plus twice the maximum after the first greedy step, then the three-merge optimum is at most twice the total two-step greedy saving.
Statement
theorem bpe_three_two_step_bound_of_numeric_bounds
(s u v : List ℕ)
(h1 : bpe_greedy_step s u) (h2 : bpe_greedy_step u v)
(hgrowth : bpe_optimal_utility s 3 ≤ bpe_optimal_utility s 2 + bpe_max_pair_count s)
(htwo : bpe_optimal_utility s 2 ≤ bpe_max_pair_count s + 2 * bpe_max_pair_count u) :
bpe_optimal_utility s 3 ≤ 2 * (s.length - v.length)- Source
- Arithmetic reduction for the budget-three case of OP-1287.
- Verified
- 19 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 5
- bpe_greedy_step_utility_eq_maxA greedy full-merge step decreases the string length by exactly the maximum nonoverlapping adjacent-pair count, including the unchanged…
- bpe_greedy_step_length_leAny greedy full byte-pair merge step produces an output string of length at most the input string length.
- bpe_optimal_utilityThe supremum, over strings reachable in k partial-merge steps, of the reduction in length of the input string.
- bpe_max_pair_countThe largest nonoverlapping full-merge pair count among adjacent pairs of the current string, with maximum zero for a string shorter than…
- bpe_greedy_stepA greedy full-merge step selects any most frequent adjacent pair and a fresh symbol; a string without adjacent pairs remains unchanged.
- Used by 1
- bpe_retyping_three_of_numeric_boundsIf the three-merge optimum is at most three initial maximum pair counts, it is at most the two-merge optimum plus one initial maximum, and…
The proof, explained
The proof bounds the optimal three-merge utility by combining the two numeric hypotheses with the properties of greedy BPE steps. Each greedy step reduces the list length by exactly the maximum pair count, so the total two-step length reduction is the sum of the maximum pair counts of the initial and intermediate strings. Chaining the growth hypothesis with the two-merge bound produces an upper bound of twice this sum, which simplifies by linear integer arithmetic to twice the two-step greedy saving.
Each greedy step does not increase length, and its length reduction equals the maximum pair count: |u| ≤ |s|, |v| ≤ |u|, |s| - |u| = bpe_max_pair_count s, and |u| - |v| = bpe_max_pair_count u.
Applying bpe_greedy_step_length_le to the two greedy transitions (h1 and h2) ensures the lengths are non-increasing. Applying bpe_greedy_step_utility_eq_max shows that the length decrease at each step exactly equals the maximum count of any adjacent pair in the list at that step.
uses
bpe_greedy_step_length_le,bpe_greedy_step_utility_eq_maxhave hlen1 := bpe_greedy_step_length_le s u h1 have hlen2 := bpe_greedy_step_length_le u v h2 have hu1 := bpe_greedy_step_utility_eq_max s u h1 have hu2 := bpe_greedy_step_utility_eq_max u v h2
The optimal three-merge utility is at most twice the total two-step greedy saving: bpe_optimal_utility s 3 ≤ 2 * (|s| - |v|).
Substituting the two-merge bound htwo into the growth bound hgrowth yields bpe_optimal_utility s 3 ≤ 2 * bpe_max_pair_count s + 2 * bpe_max_pair_count u. Since lengths are non-increasing, the total reduction |s| - |v| telescopes into (|s| - |u|) + (|u| - |v|) = bpe_max_pair_count s + bpe_max_pair_count u. Twice this total reduction matches the upper bound on the three-merge optimum, and linear integer arithmetic (omega) finishes the proof.
omega
bpe_greedy_step_length_le- A greedy BPE step never increases the length of the string: if s steps to t greedily, then the length of t is at most the length of s.
bpe_greedy_step_utility_eq_max- The reduction in length achieved by a greedy BPE step equals the maximum frequency of an adjacent pair in the string.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem bpe_three_two_step_bound_of_numeric_bounds (s u v : List ℕ) (h1 : bpe_greedy_step s u) (h2 : bpe_greedy_step u v) (hgrowth : bpe_optimal_utility s 3 ≤ bpe_optimal_utility s 2 + bpe_max_pair_count s) (htwo : bpe_optimal_utility s 2 ≤ bpe_max_pair_count s + 2 * bpe_max_pair_count u) : bpe_optimal_utility s 3 ≤ 2 * (s.length - v.length) := by have hlen1 := bpe_greedy_step_length_le s u h1 have hlen2 := bpe_greedy_step_length_le u v h2 have hu1 := bpe_greedy_step_utility_eq_max s u h1 have hu2 := bpe_greedy_step_utility_eq_max u v h2 omega