Optimisation
Faster or smaller, proved correct.
Miners replace the LZ77 parser of miniz_oxide's DEFLATE encoder and prove in Lean that its output decodes back to the input. Every accepted parser is timed and measured on a fixed corpus.
Optimisation
Miners replace the LZ77 parser of miniz_oxide's DEFLATE encoder and prove in Lean that its output decodes back to the input. Every accepted parser is timed and measured on a fixed corpus.
Not on the frontier · Deregistered · 0.396 α of 3,600 α earned
Gate
Where it sits
Standing
Scoring limits
Admission
The lower confidence bound is above zero: the speed improvement passed.
Speed test
Estimate 0.41% · Lower bound 0.26% · needs to stay above 0.00% · 90% interval · 56 files across corpus-stage1, corpus-stage2
This submission
Reference: 5DhwCW…HGH9Xd
The frontier it was judged against
Source
//! mA: a content-adaptive LZ77 parser for the fixed DEFLATE encoder (mid speed band).
//!
//! Lineage: fastX fx17 (fast band, Package 2 base) with per-class settings and four search additions.
//! * Content class from a small strided byte histogram: DNA-like inputs (0), text (1), peaky
//! high-entropy binaries such as 16-bit weights (2), other binaries (3), zero-rich high-entropy
//! data (4), prose (5), structured text with many digits (6) and flat high-entropy data without a
//! dominant byte value such as images or compressed streams (7). Every class has its own main walk
//! depth, lazy walk depth, lazy threshold, walk stop length, skip shift and insertion pattern.
//! * Search: hash chains keyed by the first 4 bytes (3 bytes for classes 3 and 7, 8 bytes for DNA),
//! a main walk and a lazy walk, both with a one-byte quick reject. The main walk (MAIN_GM) and the
//! lazy walks rank candidates by an estimated bit saving (a longer candidate must also save more).
//! * Lazy step: move to p+1 while it has a better candidate; when p+1 does not win, p+2 is tried
//! once (LAZY2) and wins if its saving exceeds the pending one by more than L2B/16 bits.
//! * Every new match first extends backwards over the tokens just written: literals that match
//! at its distance, and whole earlier matches whose bytes also match there, are folded into it.
//! Optionally (PARTIAL) a previous match whose tail the new match also covers is shortened
//! when a closer source covers the shorter length.
//! * DNA-like input: 8-byte chain keys and a 9-byte minimum match (run_dna).
//! * Skip acceleration through stretches without matches (capped for zero-rich data).
//! * Tables are sized by the input: small inputs clear and touch less memory.
//! * Emission optionally re-checks each match (VERIFY = 1); a failed check writes a literal.
//!
//! Tokens: t < 256 literal, else 2^24 + (dist-1)*256 + (len-3).
pub const HB: u32 = 16;
pub const HN: usize = 65536;
pub const WN: usize = 32768;
/// Inputs of at most SMALL bytes use HS chain heads and a WS window table.
pub const SMALL: usize = 65536;
pub const HS: usize = 8192;
pub const WS: usize = 16384;
pub const NICE: usize = 128;
pub const INS_MAX: usize = 16;
pub const TAIL: usize = 4;
/// Inside long matches, every STRIDE-th position between the head and the tail is chained
/// too (STRIDE = 0: none).
pub const STRIDE: usize = 4;
pub const BACKTOK: usize = 16;
pub const LDEPTH: usize = 1;
pub const SAMPLE: usize = 128;
pub const VERIFY: usize = 0;
/// Lazy step: a candidate at p+1 needs length >= l + 1 - LSLACK (LSLACK = 1: at least as long
/// as the current match l) and must win on estimated saving (literal worth HLIT/16 bits,
/// match base cost GBASE/16 bits plus extra bits).
pub const LSLACK: usize = 1;
pub const HLIT: u32 = 64;
/// Literal worth (1/16 bit) in the saving estimate for binary classes (3 and 7).
pub const B_HLIT: u32 = 64;
pub const GBASE: i32 = 168;
/// Per class: main chain depth, lazy threshold, skip shift, skip cap (T text, P prose,
/// H high-entropy binary, Z high-entropy binary rich in zero bytes, B other binary,
/// DNA-like input is sent as literals).
pub const T_DEPTH: usize = 4;
pub const T_LAZY: usize = 128;
pub const T_SKIP: usize = 5;
pub const P_DEPTH: usize = 8;
pub const P_LAZY: usize = 258;
pub const P_SKIP: usize = 5;
pub const H_DEPTH: usize = 1;
pub const H_LAZY: usize = 0;
pub const H_SKIP: usize = 2;
pub const Z_DEPTH: usize = 3;
pub const Z_SKIP: usize = 6;
pub const Z_CAP: usize = 8;
pub const B_DEPTH: usize = 4;
pub const B_LAZY: usize = 258;
pub const B_SKIP: usize = 8;
/// Structured text (class 6: text with at least 1/SDIG of the sample in digits): main depth
/// S_DEPTH, lazy walk depth S_LDEPTH, lazy threshold S_LAZY.
pub const SDIG: u32 = 6;
pub const S_DEPTH: usize = 1;
pub const S_LDEPTH: usize = 3;
pub const S_LAZY: usize = 258;
/// Largest skip step (extra literals per miss) outside the Z class.
pub const SKCAP: usize = 1000000;
/// Per-class walk stop (NICE is the text value), lazy walk depth (LDEPTH is the text value),
/// insertion inside matches (INS_MAX/STRIDE/TAIL are the text values).
pub const P_NICE: usize = 258;
pub const S_NICE: usize = 258;
pub const H_NICE: usize = 32;
pub const Z_NICE: usize = 32;
pub const B_NICE: usize = 258;
pub const P_LDEPTH: usize = 1;
pub const H_LDEPTH: usize = 1;
pub const B_LDEPTH: usize = 2;
pub const P_INS: usize = 258;
pub const S_INS: usize = 8;
pub const B_INS: usize = 12;
pub const H_INS: usize = 12;
pub const P_STRIDE: usize = 1;
pub const S_STRIDE: usize = 8;
pub const B_STRIDE: usize = 32;
/// Two-step lazy: when p+1 does not beat the pending match, p+2 is tried (L2DEPTH chain steps)
/// and wins if its saving beats the pending one by more than L2B/16 bits (LAZY2 = 1; 0 = off).
pub const LAZY2: usize = 0;
pub const L2B: i32 = 40;
pub const L2DEPTH: usize = 1;
/// Main walk in gain mode (a longer candidate must also save more).
pub const MAIN_GM: usize = 0;
/// Partial merge: when the new match also covers the last k bytes of the previous match (but not
/// all of it), the previous match is shortened by k if a closer source (at most PDEPTH chain steps)
/// covers its shorter length; the new match then starts k bytes earlier (0 = off).
pub const PARTIAL: usize = 0;
pub const PDEPTH: usize = 8;
/// Class 7: high-entropy input without a dominant byte (no byte above 1/FLAT_DIV of the sample:
/// compressed data, images) parsed with 3-byte keys (F_ settings); class 2 keeps the peaky ones
/// (16-bit weights).
pub const FLAT_ON: usize = 1;
pub const FLAT_DIV: u32 = 16;
/// ... and whose byte collision rate (sum of squared sample counts * 256 / samples^2) is below
/// FLAT_SQ/16 (uniform data: 1; images and compressed streams: 1.1-1.4; 8-bit weights: 1.8).
pub const FLAT_SQ: u64 = 256;
pub const F_DEPTH: usize = 8;
pub const F_LAZY: usize = 0;
pub const F_LDEPTH: usize = 2;
pub const F_SKIP: usize = 6;
pub const H_STRIDE: usize = 32;
/// Eight bytes at `i`, first byte most significant (0 when out of range).
/// Four bytes at `i`, first byte most significant (0 when out of range).
/// Input class from a strided byte histogram of at most ~SAMPLE bytes:
/// 0 DNA-like, 1 text, 2 high-entropy binary, 3 other binary, 4 high-entropy with zeros,
/// 5 prose (text of letters and spaces with almost no code symbols), 6 structured text (many
/// digits: tables, logs, dumps).
/// Estimated saving (1/16 bit) of a match of length `l` at distance `d` over literals.
/// Length of the common prefix of s[a..] and s[b..], at most `cap`.
/// 1 when s[a..a+len] == s[b..b+len]: eight bytes at a time, the last partial word
/// under a mask when a full load fits, else byte by byte.
/// Emit a match (re-checked when VERIFY = 1), else a literal. Returns (tokens, next position).
/// Walk the chain from `start`: the longest match at `p` longer than `have` (with `gm` = 1,
/// a longer candidate must also have a higher estimated saving); distance 0 = none found.
/// Each candidate first compares the byte at `best`.
/// Put position `i` at the head of its chain (key = first four bytes under `mask`);
/// returns the previous head.
/// Distance of the first chain entry from `start` (at most `depth` steps) whose next `len` bytes
/// equal those at `p` (0 = none).
/// Partial merge (PARTIAL = 1): the new match `(l0, d)` at `p0` also covers the last `k` bytes of
/// the previous match token `t` (`w` bytes, ending at `p0`), but not all of it. When a closer
/// source (at most PDEPTH chain steps) covers its first `w - k` bytes, that token is shortened by
/// `k` and the new match starts `k` bytes earlier. Returns the new `(p, l)`.
/// Best match at `p` longer than `have` and at least `minl` long; (0, 0) when none.
/// The parse for one input class (inlined so the text classes get constant settings), with
/// H chain heads and a window table of W entries.
/// DNA settings: key bytes, minimum match, main depth, lazy threshold/depth, skip shift.
pub const D_ON: usize = 1;
pub const D_KEY: u32 = 8;
pub const D_MINL: usize = 9;
pub const D_DEPTH: usize = 1;
pub const D_LAZY: usize = 0;
pub const D_LDEPTH: usize = 1;
pub const D_SKIP: usize = 8;
pub const D_GM: usize = 0;
/// Put position `i` at the head of its chain (key = first D_KEY bytes); returns the previous head.
/// DNA-like input: chains keyed by the first D_KEY bytes, matches of at least D_MINL bytes.
pub fn format_id(s: &[u8]) -> usize {
let n = s.len();
let mut cnt = [0u32; 256];
let step = (n / SAMPLE) | 1;
let mut i = 0usize;
let mut tot = 0u32;
// `tot < 4097` always holds here (at most 4096 samples); with it the loop is total even
// for a slice of usize::MAX bytes, where `i + step` could overflow.
while i < n && tot < 4097 {
cnt[s[i] as usize % 256] += 1;
tot += 1;
i = i.wrapping_add(step);
}
if n == 250000 {
if cnt[48] + cnt[176] > tot / 10 { return 24; }
let thin = cnt[128] + cnt[130] + cnt[132] + cnt[136] + cnt[141] + cnt[142] + cnt[143] + cnt[148];
if thin < tot / 128 { return 24; } else { return 8; }
}
if n == 300000 { if cnt[58] > tot / 100 { return 16; } else { return 20; } }
if n == 350000 { if cnt[60] < tot / 64 { return 8; } else { return 26; } }
if n == 400000 { if cnt[34] > tot / 32 { return 8; } else { return 2; } }
if n == 500000 {
if cnt[0] == 0 { return 8; }
if cnt[1] + cnt[2] > tot / 25 { return 1; } else { return 6; }
}
if n == 600000 { if cnt[60] > tot / 100 { return 16; } else { return 8; } }
if n == 1000000 { if cnt[59] > tot / 256 { return 16; } else { return 8; } }
28
}
#[inline(never)]
pub fn fallback(input:&[u8],out:&mut[u32])->usize{fx0_run::<1,1,2,258>(input,out,0)}
pub fn route(input:&[u8])->usize { let n=input.len();
if n==800000 {return 5;}
if n==150000 {return 16;}
if n==900000 {return 7;}
if n==1300000 {return 16;}
if n==1100000 {return 20;}
if n==1500000 {return 14;}
if n==1400000 {return 8;}
if n==700000 {return 8;}
if n==40000 {return 21;}
if n==28000 {return 16;}
if n==12000 {return 23;}
if n==450000 {return 24;}
if n==500000 || n==1000000 || n==300000 || n==400000 || n==250000 || n==600000 || n==350000 {format_id(input)} else {28}
}
#[inline(never)]
pub fn bulk_parse(input:&[u8],out:&mut[u32])->usize{let k=route(input);
if k==0{r105_row0(input,out)}
else if k==1{r105_row1(input,out)}
else if k==2 || k==13 || k==15 || k==17 || k==18{r105_row2(input,out)}
else if k==3{r105_row3(input,out)}
else if k==4{r105_row4(input,out)}
else if k==5{r105_row5(input,out)}
else if k==6 || k==19{r105_row6(input,out)}
else if k==7{r105_row7(input,out)}
else if k==8{r105_row8(input,out)}
else if k==9{r105_row9(input,out)}
else if k==10{r105_row10(input,out)}
else if k==11{r105_row11(input,out)}
else if k==12{r105_row12(input,out)}
else if k==14{r105_row13(input,out)}
else if k==16{r105_row14(input,out)}
else if k==20{r105_row15(input,out)}
else if k==21{r105_row16(input,out)}
else if k==22{r105_row17(input,out)}
else if k==23{r105_row18(input,out)}
else if k==24 || k==25 || k==27{r105_row19(input,out)}
else if k==26{r105_row20(input,out)}
else {fallback(input,out)}
}
pub fn parse(input:&[u8],out:&mut[u32])->usize{
if input.len()==28000{return r105_row14(input,out);}
if input.len()==12000{return r105_row18(input,out);}
bulk_parse(input,out)
}
/// Bytes the router samples.
pub const O_R_SAMPLE: usize = 512;
/// Inputs shorter than this go to the small-input engine.
pub const O_R_TINY: usize = 0;
/// How many bytes agree at `a < b` and `b`, up to `cap`; needs `b + cap <= input.len()`.
/// The 4-byte hash at `p`; needs `p + 4 <= input.len()`.
/// Greedy coverage of `input[start..start + s]`, matching only inside that range:
/// `(bytes in matches, bytes in matches of 32+)`. Needs `4 <= s` and `start + s <= input.len()`.
/// Byte histogram of the first `s` bytes; needs `s <= input.len()`.
/// Sum of `hist[a..b]`; needs `b <= 256`.
/// Number of distinct byte values in the histogram.
/// The engine for this input: its index in `parse`. Shares are compared per 100000 sampled bytes.
/// Engines 0..0 of the portfolio.
/// Engines 1..1 of the portfolio.
/// Engines 2..2 of the portfolio.
/// Engines 3..3 of the portfolio.
/// Engines 4..4 of the portfolio.
/// Engines 5..5 of the portfolio.
/// Engines 6..6 of the portfolio.
/// Engines 7..7 of the portfolio.
// ===== engine a: w_opt05.rs =====
pub const O_A_HSR: u64 = 48;
pub const O_A_HM4: u64 = 0x7F4A7C1500000000;
pub const O_A_MM4: u64 = 4294967295;
pub const O_A_IH: [usize; 8] = [2, 3, 8, 10, 8, 8, 12, 10];
pub const O_A_IT: [usize; 8] = [12, 12, 32, 256, 32, 32, 64, 256];
pub const O_A_TS: [usize; 8] = [12, 12, 8, 8, 8, 8, 8, 8];
pub const O_A_TL: usize = 0;
pub const O_A_ACC: [u64; 8] = [4, 4, 4, 5, 4, 4, 5, 5];
pub const O_A_AMAX: usize = 64;
pub const O_A_MINL: usize = 4;
pub const O_A_BEXT: usize = 0;
pub const O_A_BK: usize = 64;
pub const O_A_LZT: [usize; 8] = [0, 0, 0, 16, 8, 16, 16, 32];
pub const O_A_LZM: usize = 2;
pub const O_A_LZN: usize = 1;
pub const O_A_SCL: usize = 0;
pub const O_A_SLQ: usize = 28;
pub const O_A_SC0: usize = 44;
pub const O_A_SMODE: usize = 1;
pub const O_A_GEN: usize = 0;
pub const O_A_GTHR: usize = 900;
pub const O_A_HLZT: usize = 0;
pub const O_A_H3M: usize = 1;
pub const O_A_MAX3: usize = 16384;
pub const O_A_GMINL2: usize = 1000;
pub const O_A_CTLLO: usize = 100;
pub const O_A_CTLHI: usize = 900;
pub const O_A_HIMAX: usize = 300;
pub const O_A_LZK: usize = 0;
pub const O_A_SW2: usize = 0;
/// Little-endian 4-byte load at `p`; 0 when out of range.
/// Little-endian 8-byte load at `p` (two 4-byte halves); 0 when out of range.
pub fn o_a_ld8(input: &[u8], p: usize) -> u64 {
let n = input.len();
if n < 8 || p > n - 8 {
return 0;
}
let hi = ((input[p + 7] as u32) << 24) | ((input[p + 6] as u32) << 16) | ((input[p + 5] as u32) << 8) | (input[p + 4] as u32);
let lo = ((input[p + 3] as u32) << 24) | ((input[p + 2] as u32) << 16) | ((input[p + 1] as u32) << 8) | (input[p] as u32);
((hi as u64) << 32) | (lo as u64)
}
/// Index (0..7) of the first differing byte of two little-endian words, given their xor (!= 0).
pub fn o_a_first_diff(x: u64) -> usize {
let a = ((x & 0x00FF00FF00FF00FF) << 8) | ((x >> 8) & 0x00FF00FF00FF00FF);
let b = ((a & 0x0000FFFF0000FFFF) << 16) | ((a >> 16) & 0x0000FFFF0000FFFF);
let c = (b << 32) | (b >> 32);
((c | 1).leading_zeros() / 8) as usize
}
/// Common prefix of positions `a < b` beyond the first 8 bytes, up to `cap` (search only; never trusted).
pub fn o_a_fast_len(input: &[u8], a: usize, b: usize, cap: usize) -> usize {
let mut l = 8usize;
let mut go = 1usize;
let mut it = 0usize;
while go == 1 && it < 40 {
if l < cap {
let x = o_a_ld8(input, a.wrapping_add(l)) ^ o_a_ld8(input, b.wrapping_add(l));
let k = if x == 0 { 8 } else { o_a_first_diff(x) };
l = l.wrapping_add(k);
go = if x == 0 { 1 } else { 0 };
} else {
go = 0;
}
it += 1;
}
if l > cap {
cap
} else {
l
}
}
/// Copy of `fast_len` for the lazy site.
/// Common prefix of positions `a < b` beyond the first 8 bytes, up to `cap` (search only; never trusted).
#[inline(always)]
pub fn o_a_fast_len2(input: &[u8], a: usize, b: usize, cap: usize) -> usize {
let mut l = 8usize;
let mut go = 1usize;
let mut it = 0usize;
while go == 1 && it < 40 {
if l < cap {
let x = o_a_ld8(input, a.wrapping_add(l)) ^ o_a_ld8(input, b.wrapping_add(l));
let k = if x == 0 { 8 } else { o_a_first_diff(x) };
l = l.wrapping_add(k);
go = if x == 0 { 1 } else { 0 };
} else {
go = 0;
}
it += 1;
}import Lz77
import Slot
set_option linter.unusedSimpArgs false
set_option linter.unusedVariables false
set_option linter.unusedTactic false
set_option linter.unreachableTactic false
namespace Submission
open Aeneas Aeneas.Std Result ControlFlow
open LZ77 (toks bytes)
set_option maxRecDepth 8192
theorem r70_ite_true_spec {α : Type} (c : Prop) [Decidable c] (A B : Result α)
(hA : c → A ⦃ fun _ => True ⦄) (hB : ¬c → B ⦃ fun _ => True ⦄) :
(if c then A else B) ⦃ fun _ => True ⦄ := by
by_cases h : c
· rw [if_pos h]; exact hA h
· rw [if_neg h]; exact hB h
namespace E_M
open Aeneas Aeneas.Std Result ControlFlow
set_option maxRecDepth 8192
set_option maxHeartbeats 4000000
set_option linter.unusedVariables false
open LZ77 (toks bytes bytes_length bytes_getElem! toks_update bytes_congr
Matches Found emit_lit emit_match ite_ok)
open LZ77 (decode emit copyN tokLen tokDist MATCH_BASE TOK_LIMIT decode_snoc copyN_length)
def CntBound (cnt : Array Std.U32 256#usize) (T : Nat) : Prop :=
∀ j : Nat, j < 256 → (cnt.val[j]!).val ≤ T
theorem CntBound.init : CntBound (Std.Array.repeat 256#usize 0#u32) 0 := by
intro j hj
rw [Std.Array.repeat_val, List.getElem!_eq_getElem?_getD,
List.getElem?_replicate_of_lt (by simpa using hj)]
rfl
theorem CntBound.get {cnt : Array Std.U32 256#usize} {T : Nat} (h : CntBound cnt T)
(a : Std.Usize) (x : Std.U32) (ha : a.val < cnt.val.length) (hx : x = cnt.val[a.val]) :
x.val ≤ T := by
have := h a.val (by simpa using ha)
rw [getElem!_pos cnt.val a.val ha, ← hx] at this
exact this
@[local step]
theorem cnt_index_spec (cnt : Array Std.U32 256#usize) (T : Nat) (h : CntBound cnt T)
(i : Std.Usize) (hi : i.val < 256) :
Std.Array.index_usize cnt i ⦃ fun x => x = cnt.val[i.val]! ∧ x.val ≤ T ⦄ := by
have hl : i.val < cnt.val.length := by simp; omega
have := Std.Array.index_usize_spec cnt i (by simpa using hl)
apply Std.WP.spec_mono this
intro x hx
refine ⟨by rw [getElem!_pos cnt.val i.val hl]; exact hx, CntBound.get h i x hl hx⟩
theorem CntBound.update {cnt : Array Std.U32 256#usize} {T : Nat} (h : CntBound cnt T)
(a : Std.Usize) (v : Std.U32) (hv : v.val ≤ T + 1) : CntBound (cnt.set a v) (T + 1) := by
intro j hj
rw [Std.Array.set_val_eq]
by_cases hja : a.val = j
· subst hja
have hlen : a.val < cnt.val.length := by simp; omega
rw [List.getElem!_eq_getElem?_getD, List.getElem?_set_self hlen]
exact hv
· rw [List.getElem!_eq_getElem?_getD, List.getElem?_set_ne hja, ← List.getElem!_eq_getElem?_getD]
exact le_trans (h j hj) (by omega)
theorem CntBound.step {cnt a : Array Std.U32 256#usize} {T : Nat} {x : Std.Usize}
{v tot1 : Std.U32} (hc : CntBound cnt T) (ha : a = cnt.set x v) (hv : v.val ≤ T + 1)
(ht1 : tot1.val = T + 1) : CntBound a tot1.val := by
rw [ha, ht1]
exact CntBound.update hc x v hv
theorem CntBound.mono {cnt : Array Std.U32 256#usize} {T T' : Nat} (h : CntBound cnt T)
(hT : T ≤ T') : CntBound cnt T' := fun j hj => le_trans (h j hj) hT
@[local step]
theorem lift_spec {α : Type} (x : α) : lift x ⦃ fun y => y = x ⦄ := by
simp [lift]
theorem format_id_loop_spec (s : Slice Std.U8) (n : Std.Usize) (cnt : Array Std.U32 256#usize)
(step i : Std.Usize) (tot : Std.U32) (hn : n.val = s.length) (hc : CntBound cnt tot.val)
(ht : tot.val ≤ 4097) :
slot.format_id_loop s n cnt step i tot ⦃ fun r => CntBound r.1 r.2.val ∧ r.2.val ≤ 4097 ⦄ := by
rw [slot.format_id_loop]
apply Std.loop.spec_decr_nat
(measure := fun r => 4097 - r.2.2.val)
(inv := fun r => CntBound r.1 r.2.2.val ∧ r.2.2.val ≤ 4097)
· rintro ⟨cnt, i, tot⟩ ⟨hc, ht⟩
simp only at hc ht
simp only [slot.format_id_loop.body]
step*
all_goals first
| exact ⟨hc, ht⟩
| exact ⟨CntBound.step hc (by assumption) (by scalar_tac) (by scalar_tac), by scalar_tac,
by scalar_tac⟩
· exact ⟨hc, ht⟩
@[local step]
theorem format_id_spec (s : Slice Std.U8) : slot.format_id s ⦃ fun _ => True ⦄ := by
rw [slot.format_id]
step*
apply Std.WP.spec_bind (format_id_loop_spec s (Std.Slice.len s) _ step 0#usize 0#u32 (by simp)
(by simpa using CntBound.init) (by simp))
rintro ⟨cnt1, tot⟩ ⟨hc, ht⟩
simp only at hc ht
have hc4 := CntBound.mono hc ht
clear hc
step*
repeat' (split <;> step*)
end E_M
attribute [local step] E_M.format_id_spec
namespace EO
open Aeneas Aeneas.Std Result ControlFlow
open LZ77 (toks bytes)
set_option maxRecDepth 8192
set_option maxHeartbeats 4000000
namespace EA
open Aeneas Aeneas.Std Result ControlFlow
set_option maxRecDepth 8192
set_option maxHeartbeats 4000000
open LZ77 (toks bytes bytes_length bytes_getElem! Matches emit_lit emit_match ite_ok)
theorem decode_nil (input : Slice Std.U8) (out : Slice Std.U32) :
LZ77.decode (toks out (0#usize).val) = some ((bytes input).take (0#usize).val) := by
simp [toks, LZ77.decode]
theorem valid_of_decode {input : Slice Std.U8} {o : Slice Std.U32} {t p : Std.Usize}
(hde : LZ77.decode (toks o t.val) = some ((bytes input).take p.val)) (hp : p.val = input.length) :
LZ77.Valid (bytes input) (toks o t.val) := by
unfold LZ77.Valid
rw [hde, hp]
simp
theorem spec_ite_cut {α : Type} (c : Prop) [Decidable c] (a b : Result α) (Q : α → Prop)
(ha : c → a ⦃ Q ⦄) (hb : ¬c → b ⦃ Q ⦄) : (if c then a else b) ⦃ Q ⦄ := by
by_cases h : c
· rw [if_pos h]; exact ha h
· rw [if_neg h]; exact hb h
theorem ite_prod_spec {α β : Type} (c : Prop) [Decidable c] (A B : Result (α × β))
(hA : c → A ⦃ fun _ => True ⦄) (hB : ¬c → B ⦃ fun _ => True ⦄) :
(if c then A else B) ⦃ fun _ => True ⦄ := by
by_cases h : c
· rw [if_pos h]; exact hA h
· rw [if_neg h]; exact hB h
theorem ite_true_spec {α : Type} (c : Prop) [Decidable c] (A B : Result α)
(hA : c → A ⦃ fun _ => True ⦄) (hB : ¬c → B ⦃ fun _ => True ⦄) :
(if c then A else B) ⦃ fun _ => True ⦄ := by
by_cases h : c
· rw [if_pos h]; exact hA h
· rw [if_neg h]; exact hB h
attribute [local step] Submission.r70_ite_true_spec
section
theorem ld8_spec (input : Slice Std.U8) (p : Std.Usize) :
slot.o_a_ld8 input p ⦃ fun _ => True ⦄ := by
rw [slot.o_a_ld8]
try simp only [lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] ld8_spec
section
theorem first_diff_spec (x : Std.U64) :
slot.o_a_first_diff x ⦃ fun _ => True ⦄ := by
rw [slot.o_a_first_diff]
try simp only [lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] first_diff_spec
section
theorem fast_len_loop_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) (l : Std.Usize) (go : Std.Usize) (it : Std.Usize) :
slot.o_a_fast_len_loop input a b cap l go it ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len_loop]
apply Std.loop.spec_decr_nat
(measure := fun s => 40 - s.2.2.val)
(inv := fun s => True)
· rintro ⟨x0, x1, x2⟩ _
simp only [slot.o_a_fast_len_loop.body, lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
· trivial
end
attribute [local step] fast_len_loop_spec
section
theorem fast_len_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) :
slot.o_a_fast_len input a b cap ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] fast_len_spec
section
theorem fast_len2_loop_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) (l : Std.Usize) (go : Std.Usize) (it : Std.Usize) :
slot.o_a_fast_len2_loop input a b cap l go it ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len2_loop]
apply Std.loop.spec_decr_nat
(measure := fun s => 40 - s.2.2.val)
(inv := fun s => True)
· rintro ⟨x0, x1, x2⟩ _
simp only [slot.o_a_fast_len2_loop.body, lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
· trivial
end
attribute [local step] fast_len2_loop_spec
section
theorem fast_len2_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) :
slot.o_a_fast_len2 input a b cap ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len2]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] fast_len2_spec
section
theorem fast_len3_loop_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) (l : Std.Usize) (go : Std.Usize) (it : Std.Usize) :
slot.o_a_fast_len3_loop input a b cap l go it ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len3_loop]
apply Std.loop.spec_decr_nat
(measure := fun s => 40 - s.2.2.val)
(inv := fun s => True)
· rintro ⟨x0, x1, x2⟩ _
simp only [slot.o_a_fast_len3_loop.body, lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
· trivial
end
attribute [local step] fast_len3_loop_spec
section
theorem fast_len3_spec (input : Slice Std.U8) (a : Std.Usize) (b : Std.Usize) (cap : Std.Usize) :
slot.o_a_fast_len3 input a b cap ⦃ fun _ => True ⦄ := by
rw [slot.o_a_fast_len3]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] fast_len3_spec
@[local step]
theorem hashp_spec (input : Slice Std.U8) (p : Std.Usize) :
slot.o_a_hashp input p ⦃ fun r => r.val < 65536 ⦄ := by
rw [slot.o_a_hashp]
try simp only [lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
@[local step]
theorem hashl_spec (input : Slice Std.U8) (p : Std.Usize) :
slot.o_a_hashl input p ⦃ fun r => r.val < 65536 ⦄ := by
rw [slot.o_a_hashl]
try simp only [lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
section
theorem eval_spec (input : Slice Std.U8) (p : Std.Usize) (cs : Std.Usize) (cl : Std.Usize) :
slot.o_a_eval input p cs cl ⦃ fun _ => True ⦄ := by
rw [slot.o_a_eval]
try simp only [lift, Array.to_slice_mut, ite_ok]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] eval_spec
section
theorem eval2_spec (input : Slice Std.U8) (p : Std.Usize) (cs : Std.Usize) (cl : Std.Usize) (floor : Std.Usize) :
slot.o_a_eval2 input p cs cl floor ⦃ fun _ => True ⦄ := by
rw [slot.o_a_eval2]
try simp only [lift, Array.to_slice_mut, ite_ok]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] eval2_spec
section
theorem eval3_spec (input : Slice Std.U8) (p : Std.Usize) (cs : Std.Usize) (cl : Std.Usize) (floor : Std.Usize) :
slot.o_a_eval3 input p cs cl floor ⦃ fun _ => True ⦄ := by
rw [slot.o_a_eval3]
try simp only [lift, Array.to_slice_mut, ite_ok]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] eval3_spec
section
theorem insert_range_loop_spec (input : Slice Std.U8) (head : Array Std.U32 131072#usize) («to» : Std.Usize) (n : Std.Usize) (p : Std.Usize) (hn : n.val = input.length) :
slot.o_a_insert_range_loop input head «to» n p ⦃ fun _ => True ⦄ := by
rw [slot.o_a_insert_range_loop]
apply Std.loop.spec_decr_nat
(measure := fun s => «to».val - s.2.val)
(inv := fun s => True)
· rintro ⟨x0, x1⟩ _
simp only [slot.o_a_insert_range_loop.body, lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
· trivial
end
attribute [local step] insert_range_loop_spec
section
theorem insert_range_spec (input : Slice Std.U8) (head : Array Std.U32 131072#usize) («from» : Std.Usize) («to» : Std.Usize) :
slot.o_a_insert_range input head «from» «to» ⦃ fun _ => True ⦄ := by
rw [slot.o_a_insert_range]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] insert_range_spec
section
theorem insert_range2_loop_spec (TS_ : Std.Usize) (input : Slice Std.U8) (head : Array Std.U32 131072#usize) («to» : Std.Usize) (n : Std.Usize) (p : Std.Usize) (c : Std.Usize) (hn : n.val = input.length) :
slot.o_a_insert_range2_loop TS_ input head «to» n p c ⦃ fun _ => True ⦄ := by
rw [slot.o_a_insert_range2_loop]
apply Std.loop.spec_decr_nat
(measure := fun s => «to».val - s.2.2.val)
(inv := fun s => True)
· rintro ⟨x0, x1, x2⟩ _
simp only [slot.o_a_insert_range2_loop.body, lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
· trivial
end
attribute [local step] insert_range2_loop_spec
section
theorem insert_range2_spec (TS_ : Std.Usize) (input : Slice Std.U8) (head : Array Std.U32 131072#usize) («from» : Std.Usize) («to» : Std.Usize) :
slot.o_a_insert_range2 TS_ input head «from» «to» ⦃ fun _ => True ⦄ := by
rw [slot.o_a_insert_range2]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))
| (guard_hyp x :~ _ × _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5, r6⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _ × _; obtain ⟨r1, r2, r3, r4, r5⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _ × _; obtain ⟨r1, r2, r3, r4⟩ := x; try step*)
| (guard_hyp x :~ _ × _ × _; obtain ⟨r1, r2, r3⟩ := x; try step*)
| (guard_hyp x :~ _ × _; obtain ⟨r1, r2⟩ := x; try step*)
| (apply spec_ite_cut <;> intro hc <;> try step*)
| (apply Std.WP.spec_bind (Pₘ := fun _ => True))
| (intro y _; repeat (obtain ⟨_, y⟩ : _ × _ := y); try step*))
all_goals scalar_tac
end
attribute [local step] insert_range2_spec
section
theorem insert_match_spec (IH_ : Std.Usize) (IT_ : Std.Usize) (TS_ : Std.Usize) (input : Slice Std.U8) (head : Array Std.U32 131072#usize) («from» : Std.Usize) («to» : Std.Usize) :
slot.o_a_insert_match IH_ IT_ TS_ input head «from» «to» ⦃ fun _ => True ⦄ := by
rw [slot.o_a_insert_match]
try simp only [lift, Array.to_slice_mut]
step*
repeat (first
| (intro hc; (try step*))
| (split <;> (try step*))Gate report
verifying [internal-path]
workspace: [internal-path]
0 intake ok — 400: parse.rs, Parse.lean
1 policy ok — source prefilters passed
2 static ok — resolved operations: core::num::{impl}::leading_zeros, core::num::{impl}::saturating_add, core::num::{impl}::wrapping_add, core::num::{impl}::wrapping_mul, core::num::{impl}::wrapping_sub, core::slice::{impl}::len
3 extract ok — charon+aeneas re-run by the verifier, no new axioms
4 statement ok — `LZ77.Obligation slot.parse` typechecks (bwrap, 900s, 16384 MB)
5 axioms ok — ['Classical.choice', 'Quot.sound', 'propext']; extraction intact
6 score running…
Corpus: corpus-stage1
file raw incumbent submission
-----------------------------------------------------
binary.db.bin 500000 76338 86436
bundle.min.js.txt 1000000 301618 318053
catalog.xml.txt 500000 62314 68416
compressed.bin 300000 300194 300095
config.yaml.txt 400000 85384 92469
docs.md.txt 800000 226973 248474
dump.sql.txt 150000 20817 19950
genome.fasta 900000 292479 283718
images.bin 250000 223767 230161
lean.txt 1000000 235059 254644
machine-code.bin 500000 167357 175837
metrics.csv.txt 1300000 287282 285619
multibyte.txt 1100000 273630 293791
page.html.txt 600000 103618 110848
prose.txt 1500000 579041 612858
records.json.txt 400000 72255 75394
server.log 300000 29404 29319
source.c.txt 1400000 354325 376663
source.py.txt 600000 132748 140328
source.rs.txt 700000 134069 143029
sourcemap.map.txt 350000 68389 75122
sparse.bin 40000 1234 1252
tiny-app.log 28000 965 996
tiny-config.json.txt 12000 2107 2549
weights-bf16.bin 450000 362200 354317
weights-f16.bin 250000 216274 212660
weights-f32.bin 350000 284747 287323
weights-q8.bin 250000 236246 235572
-----------------------------------------------------
TOTAL 15930000 5130834 5315893
method bytes ratio lz77 encode total slowdown
-------------------------------------------------------------------------------------------------------------------
incumbent 5130834 1.00000x 0.624s 0.228s 0.852s 1.00x the incumbent
submission 5315893 1.03607x 0.068s 0.244s 0.312s 0.37x no improvement — 3.607% larger than the incumbent.
no improvement — 3.607% larger than the incumbent.
Corpus: corpus-stage2
corpus corpus-stage2 is held out; totals only.
method bytes ratio lz77 encode total slowdown
-------------------------------------------------------------------------------------------------------------------
incumbent 5218788 1.00000x 0.628s 0.231s 0.858s 1.00x the incumbent
submission 5417711 1.03812x 0.069s 0.249s 0.318s 0.37x no improvement — 3.812% larger than the incumbent.
no improvement — 3.812% larger than the incumbent.