bpe_pair_better
def
Comparison between two symbol pairs in a string, preferring the pair with strictly more nonoverlapping occurrences, and breaking ties by lexicographic order on pair IDs.
Statement
def bpe_pair_better (s : List ℕ) (p q : ℕ × ℕ) : Bool- Defined in
- OP-1536
- Verified
- 11 Nov 2026
- Axioms
- none listed
- Built on 1
- bpe_pair_countThe number of occurrences of the ordered symbol pair replaced by the left-to-right nonoverlapping full merge.
- Used by 1
- bpe_lex_best_pairSelects the adjacent pair with the largest number of nonoverlapping occurrences in the string, breaking ties by lexicographical order of…
Read back from the Lean
bpe_pair_better s p q is a boolean function that returns true if and only if either:
1. bpe_pair_count p.1 p.2 s > bpe_pair_count q.1 q.2 s, or
2. bpe_pair_count p.1 p.2 s = bpe_pair_count q.1 q.2 s and p.1 < q.1, or
3. bpe_pair_count p.1 p.2 s = bpe_pair_count q.1 q.2 s, p.1 = q.1, and p.2 < q.2.
Otherwise, it returns false.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- Boolean comparison favoring higher nonoverlapping count, breaking ties lexicographically. -/ def bpe_pair_better (s : List ℕ) (p q : ℕ × ℕ) : Bool := let cp := bpe_pair_count p.1 p.2 s let cq := bpe_pair_count q.1 q.2 s if cp > cq then true else if cp < cq then false else if p.1 < q.1 then true else if p.1 > q.1 then false else p.2 < q.2