AFTD Auto-Formalizing Theoretical Domains

bpe_arbitrary_full_merge_counterexample_lower_witness

theoremverified

The proposed arbitrary-full-merge stability counterexample has a full merge saving one and a three-step comparator saving eight. This does not assert an upper bound on the optimum after the merge.

Statement

theorem bpe_arbitrary_full_merge_counterexample_lower_witness : let s : List ℕ := [0,0,0,0,1,0,0,0,0,1]
    let t : List ℕ := [0,0,0,0,2,0,0,0,1]
    let v : List ℕ := [4,4]
    bpe_full_step s t ∧ s.length - t.length = 1 ∧
      bpe_steps bpe_partial_step 3 s v ∧ s.length - v.length = 8
Source
Explicit comparator for experiment 34428, related to OP-1287.
Verified
20 Nov 2026
Axioms
Quot.soundpropext
Built on 6
  • bpe_full_stepA full Byte-Pair Encoding merge step: either the string remains unchanged, or all nonoverlapping occurrences of some pair are replaced…
  • bpe_full_mergeThe string obtained by scanning left to right and replacing every available nonoverlapping occurrence of the selected pair with the given…
  • bpe_stepsExactly k applications of the specified binary relation connect the input and output strings.
  • bpe_partial_stepA partial merge replaces an arbitrary nonoverlapping subset of one pair by a fresh symbol, with an unchanged step allowed.
  • bpe_partial_mergeThe relation between input and output strings obtained by replacing an arbitrary subset of pairwise nonoverlapping occurrences of the…
  • bpe_worst_case_ratio_three_upper_boundThe worst-case ratio of greedy Byte-Pair Encoding to optimal partial-merge utility for three merges is at most 7/12.

The proof, explained

The theorem constructs an explicit counterexample string s = [0,0,0,0,1,0,0,0,0,1] of length 10 to show that an arbitrary full merge can be severely suboptimal. Merging the unique occurrence of (1, 0) into 2 yields t and saves only 1 symbol (length 9). In contrast, a 3-step sequence of full merges—first (0,0) ↦ 2, then (2,2) ↦ 3, then (3,1) ↦ 4—reduces s to v = [4,4], saving 8 symbols (length 2).

  1. Unfold the local definitions of s, t, and v.

    Simplifies the `let`-bound variables s, t, and v so that they are replaced in the goal with their concrete lists: s = [0,0,0,0,1,0,0,0,0,1], t = [0,0,0,0,2,0,0,0,1], and v = [4,4].

    line 9

      dsimp only
  2. Verify that s transitions to t via a full merge saving 1 symbol, and that reducing s to v saves 8 symbols.

    A full step `bpe_full_step s t` allows performing a full merge with a fresh symbol; selecting the merge alternative (`Or.inr`), the proof chooses pair (1, 0) and fresh symbol 2. The condition 2 ∉ s is verified by finite list inspection (`decide`), and the full merge of (1, 0) on s matches t definitionally (`rfl`). Direct arithmetic computation (`decide`) verifies both length differences: 10 - 9 = 1 and 10 - 2 = 8. This leaves only the 3-step transition from s to v to be established.

    line 10

    uses Or.inr

      refine ⟨Or.inr ⟨1,0,2, by decide, rfl⟩, by decide, ?_, by decide⟩
  3. Construct the 3-step transition from s to v using three successive full merges.

    To witness `bpe_steps bpe_partial_step 3 s v`, three consecutive steps are supplied. Since every full merge is also a valid partial merge (by `bpe3ub_partial_of_full`), each step is given as a full merge: 1. Merge (0, 0) ↦ 2, with 2 ∉ s checked by `decide`, transforming s into [2,2,1,2,2,1]. 2. Merge (2, 2) ↦ 3, with 3 checked fresh by `decide`, transforming the list into [3,1,3,1]. 3. Merge (3, 1) ↦ 4, with 4 checked fresh by `decide`, transforming the list into [4,4].

    lines 11–13

    uses Or.inr, bpe3ub_partial_of_full

      refine ⟨_, Or.inr ⟨0,0,2, by decide, bpe3ub_partial_of_full 0 0 2 _⟩,
        _, Or.inr ⟨2,2,3, by decide, bpe3ub_partial_of_full 2 2 3 _⟩,
        _, Or.inr ⟨3,1,4, by decide, bpe3ub_partial_of_full 3 1 4 _⟩, ?_⟩
  4. The list reached after the three merges is identically v.

    The 0-step base case of `bpe_steps` requires the final list to equal v = [4,4]. Evaluating the composition of the three full merges on s definitionally yields [4,4], so the equality is closed by reflexivity (`rfl`).

    line 14

      rfl
Or.inr
From a proof of B, establishes the disjunction A ∨ B.
bpe3ub_partial_of_full
Every full merge of a pair (a, b) into z is also a valid partial merge.

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

set_option maxRecDepth 8192set_option maxHeartbeats 4000000theorem bpe_arbitrary_full_merge_counterexample_lower_witness : let s : List ℕ := [0,0,0,0,1,0,0,0,0,1]    let t : List ℕ := [0,0,0,0,2,0,0,0,1]    let v : List ℕ := [4,4]    bpe_full_step s t ∧ s.length - t.length = 1 ∧      bpe_steps bpe_partial_step 3 s v ∧ s.length - v.length = 8 := by  dsimp only  refine ⟨Or.inr ⟨1,0,2, by decide, rfl⟩, by decide, ?_, by decide⟩  refine ⟨_, Or.inr ⟨0,0,2, by decide, bpe3ub_partial_of_full 0 0 2 _⟩,    _, Or.inr ⟨2,2,3, by decide, bpe3ub_partial_of_full 2 2 3 _⟩,    _, Or.inr ⟨3,1,4, by decide, bpe3ub_partial_of_full 3 1 4 _⟩, ?_⟩  rfl
See it in the graphDiscuss this resultChallenge it