PROOF.bend checks
raw source on the hub · import bend-bpe-tokenizer@0.1.0.0/PROOF.bend as PROOF
bend-bpe-tokenizer: the proofs of LAWS.bend. The literal laws compute. split_partition, bpe_conserves and added_partition go by induction on the fuel: each step cuts the text with take and drop (or joins two neighbours), and take_append_drop / append_assoc put it back.
9 imports
import Base import bend-mathlib@0.8.1.0/list.bend as ML import ./utf8.bend as U import ./split.bend as S import ./bpe.bend as B import ./hmap.bend as H import ./specials.bend as A import ./tok.bend as TK import ./LAWS.bend as Laws
Definitions
def split_cat source · line 16 · raw
@fuel:Nat -> @+fam:U32 -> @xs:List<&2, 0x0c46c789483b48a99efa2c996652d510/split.CC> -> {List.concat(&2, 0x0c46c789483b48a99efa2c996652d510/split.CC, 0x0c46c789483b48a99efa2c996652d510/split.split_go(fuel, fam, xs)) == xs : List<&2, 0x0c46c789483b48a99efa2c996652d510/split.CC>}---- split_partition ---- a step: the piece x <> take(t, n) and the rest's pieces, drop(t, n), concatenate to x <> t
def merge_head_cat source · line 33 · raw
@a:List<&2, U32> -> @t:List<&2, List<&2, U32>> -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.merge_head(a, t)) == List.append(&2, U32, a, List.concat(&2, U32, t)) : List<&2, U32>}---- bpe_conserves ----
def merge_cat source · line 41 · raw
@ps:List<&2, List<&2, U32>> -> @i:Nat -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.merge_at(ps, i)) == List.concat(&2, U32, ps) : List<&2, U32>}joining the pair at i keeps the concatenation
def bpe_if_cat source · line 52 · raw
@z:Bool -> @+at:Nat -> @+f:Nat -> @+ranks:0x0c46c789483b48a99efa2c996652d510/hmap.HM -> @+ps:List<&2, List<&2, U32>> -> @ih:(@x:List<&2, List<&2, U32>> -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_go(f, ranks, x)) == List.concat(&2, U32, x) : List<&2, U32>}) -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_if(z, at, ps, x => 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_go(f, ranks, x))) == List.concat(&2, U32, ps) : List<&2, U32>}
def bpe_next_cat source · line 62 · raw
@b:0x0c46c789483b48a99efa2c996652d510/bpe.BR -> @+f:Nat -> @+ranks:0x0c46c789483b48a99efa2c996652d510/hmap.HM -> @+ps:List<&2, List<&2, U32>> -> @ih:(@x:List<&2, List<&2, U32>> -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_go(f, ranks, x)) == List.concat(&2, U32, x) : List<&2, U32>}) -> {List.concat(&2, U32, 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_next(b, ps, x => 0x0c46c789483b48a99efa2c996652d510/bpe.bpe_go(f, ranks, x))) == List.concat(&2, U32, ps) : List<&2, U32>}
def flush_text source · line 78 · raw
@buf:List<&2, U32> -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.flush(buf)) == List.reverse(&2, U32, buf) : List<&2, U32>}---- added_partition ---- the plain text so far comes out as it went in
def text_of_append source · line 85 · raw
@xs:List<&2, 0x0c46c789483b48a99efa2c996652d510/specials.Seg> -> @ys:List<&2, 0x0c46c789483b48a99efa2c996652d510/specials.Seg> -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(List.append(&2, 0x0c46c789483b48a99efa2c996652d510/specials.Seg, xs, ys)) == List.append(&2, U32, 0x0c46c789483b48a99efa2c996652d510/specials.text_of(xs), 0x0c46c789483b48a99efa2c996652d510/specials.text_of(ys)) : List<&2, U32>}
def cut2_cat source · line 95 · raw
@none:Bool -> @+n:Nat -> @id:U32 -> @+buf:List<&2, U32> -> @+x:U32 -> @+t:List<&2, U32> -> @+f:Nat -> @+fs:List<&2, U32> -> @+added:List<&2, 0x0c46c789483b48a99efa2c996652d510/specials.AT> -> @ih:(@b:List<&2, U32> -> @r:List<&2, U32> -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.split_go(f, fs, added, b, r)) == List.append(&2, U32, List.reverse(&2, U32, b), r) : List<&2, U32>}) -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.cut2(none, n, id, buf, x, t, b => r => 0x0c46c789483b48a99efa2c996652d510/specials.split_go(f, fs, added, b, r))) == List.append(&2, U32, List.reverse(&2, U32, buf), x <> t) : List<&2, U32>}
def cut_cat source · line 118 · raw
@b:0x0c46c789483b48a99efa2c996652d510/specials.BA -> @+buf:List<&2, U32> -> @+x:U32 -> @+t:List<&2, U32> -> @+f:Nat -> @+fs:List<&2, U32> -> @+added:List<&2, 0x0c46c789483b48a99efa2c996652d510/specials.AT> -> @ih:(@b:List<&2, U32> -> @r:List<&2, U32> -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.split_go(f, fs, added, b, r)) == List.append(&2, U32, List.reverse(&2, U32, b), r) : List<&2, U32>}) -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.cut(b, buf, x, t, b => r => 0x0c46c789483b48a99efa2c996652d510/specials.split_go(f, fs, added, b, r))) == List.append(&2, U32, List.reverse(&2, U32, buf), x <> t) : List<&2, U32>}
def added_cat source · line 125 · raw
@fuel:Nat -> @+fs:List<&2, U32> -> @+added:List<&2, 0x0c46c789483b48a99efa2c996652d510/specials.AT> -> @+buf:List<&2, U32> -> @xs:List<&2, U32> -> {0x0c46c789483b48a99efa2c996652d510/specials.text_of(0x0c46c789483b48a99efa2c996652d510/specials.split_go(fuel, fs, added, buf, xs)) == List.append(&2, U32, List.reverse(&2, U32, buf), xs) : List<&2, U32>}