跳至主要内容

Compress

Lossless is bit-exact. Lossy is ≤ 0.1% reconstruction error with the budget printed on the output.

  • Live app/apps/compress/
  • Sourceapps/compress/index.html + apps/compress/compress.js (≈ 610 lines)
  • OperatorsKO42 · CS47 · CS43
  • Error budget → 0.000% lossless, ≤ 0.1% lossy (declared per call)

What it solves

Two compression modes, one API. The lossless path uses arithmetic coding driven by a CS47 entropy model (Shannon: E(n) = −∑ p(x) log p(x)); the resulting codec is bit-exact and lands within a few percent of LZMA on general data and matches Zstd on structured data.

The lossy path uses a CS43-bounded spectral / wavelet transform (depending on modality) with a declared error budget. The caller specifies max_error_pct (default 0.1); the encoder adapts the bit-allocation so the reconstructed signal is within that budget against the original. The output records the measured error next to the declared budget so the user always knows what they got.

KO42 binds every compressed artefact to the Zeqond at which it was produced; useful for reproducibility and for tying compression decisions to provenance (see Zeq Truth Engine).

The math — 7-step Wizard applied

StepDecision
1. PrimeKO42 mandatory
2. LimitCS47 + CS43 + KO42 = 3
3. ScaleFiles O(MB–GB)
4. PrecisionLossless bit-exact; lossy ≤ user budget (default 0.1%)
5. CompileMaster Equation
6. ExecuteFunctional Equation
7. VerifyRound-trip compare, measure reconstruction error

Verbatim formulas:

  • KO42.1ds² = g_μν dx^μ dx^ν + α sin(2π · 1.287 t) dt²
  • CS47E(n) = −∑ p(x) log p(x)
  • CS43T(n) = O(n log n)

Runnable worked example — lossless + lossy

# 1. Lossless compress
curl -s -X POST https://api.zeq.dev/api/playground/compute \
-H "Authorization: Bearer $ZEQ_DEMO_KEY" \
-H "Content-Type: application/json" \
-d '{
"operators": ["KO42", "CS47"],
"inputs": {
"op": "compress",
"mode": "lossless",
"payload_b64": "aGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQ="
}
}'

Expected:

{
"compressed_b64": "...",
"original_bytes": 33,
"compressed_bytes": 19,
"ratio": 1.74,
"error_pct": 0.000,
"zeqond": 1745124600.281
}
# 2. Lossy (image/signal) with 0.1% budget
curl -s -X POST https://api.zeq.dev/api/playground/compute \
-H "Authorization: Bearer $ZEQ_DEMO_KEY" \
-H "Content-Type: application/json" \
-d '{
"operators": ["KO42", "CS43"],
"inputs": {
"op": "compress",
"mode": "lossy",
"modality": "signal",
"samples_url": "s3://zeq-demo/ecg-sample.csv",
"max_error_pct": 0.1
}
}'

Expected:

{
"compressed_b64": "...",
"ratio": 14.2,
"declared_error_pct": 0.100,
"measured_error_pct": 0.087,
"zeqond": 1745124600.433
}

Extend it

  • Modality-aware lossy: pass modality = "image" | "audio" | "signal" | "text" to pick the transform.
  • Streaming mode: wrap the output in TESC for per-frame attestation.
  • Hardware acceleration: run the transform on Zeq Pulse-attached FPGA.

Seeds

  • Perceptually-grounded lossy — add Chapter 6's Signal Classifier as a quality gate in the encode loop.
  • Federated dictionary learning — CS47 models trained jointly across peers without exposing training data.
  • Post-quantum archival — pair lossless compress + HITE time-lock for long-term sealed archives.

Papers

Middleware active. Kernel on the 1.287 Hz HulyaPulse. Awaiting next Zeqond.