Procedural Generation Compression Engine Store algorithms, not data.
ALICE-Zip is a next-generation compression tool that stores "how to generate the data" instead of the data itself.
For patterns, waves, and mathematical data, it achieves compression ratios of 10x to 1000x. For everything else, it falls back to LZMA, ensuring it's never worse than standard tools.
Features
- Procedural Compression: Sine waves, polynomials, and mathematical patterns
- Adaptive Fallback: Automatically selects LZMA when procedural methods don't help
- Lossless: Bit-perfect reconstruction
- Cross-Platform: Python, Rust, C#/Unity, C++/UE5
Repository layout
| Path | What | Where it ships |
|---|---|---|
/ (alice-zip) |
Rust core crate — compression primitives (LZ77, dictionary, BPE, entropy, quantisation, zlib / LZMA residual containers) + every generator law (polynomial / Fourier / Perlin), no_std + alloc |
crates.io · docs.rs |
libalice/ (alice-zip-cli) |
CLI alice, C FFI (cdylib), PyO3 native module; thin re-export of the core generators and compression |
C# / UE5 bindings, pip libalice |
alice_zip/ |
Python package (ALICEZip analyzer + .alice container) |
pip alice-zip |
bindings/ |
C++ / C# (Unity) / UE5 wrappers over libalice/include/alice.h |
Installation
# Python
# Rust
Rust crate
use *;
// Compression primitives (no_std)
let tokens = lz77_encode;
assert_eq!;
assert_eq!;
// Generator laws: fit a series, keep the coefficients, regenerate
let series: = .map.collect;
let = fit_polynomial.unwrap;
assert_eq!;
let = analyze_signal;
let regenerated = generate_from_coefficients;
# Ok::
| Feature | Adds | Default |
|---|---|---|
std |
compression (zlib via flate2), std::error::Error for ZipError |
✓ |
fft |
generators::analyze_signal_fft (rustfft, same contract as the naive DFT) |
|
parallel |
rayon row parallelism for generate_perlin_2d / _advanced |
|
lzma |
compression::{lzma_compress, lzma_decompress} + the .alice quantised / lossless residual containers (lzma-rs) |
|
| (none) | no_std + alloc; float math via libm; CI builds the rlib for thumbv7em-none-eabihf |
Two persisted coefficient conventions coexist under explicit names (they are
different laws and are never silently interchangeable): fit_polynomial /
generate_polynomial (x = 0..n-1, ascending — alice-db segments) and
fit_polynomial_unit / generate_polynomial_unit (x ∈ [0, 1], descending —
the .alice container). Every law is checked against a closed-form answer in
tests/analytic_oracle.rs and fuzzed (7 targets,
including naive-DFT ↔ FFT parity). MSRV 1.87.
Quick Start
Command Line
# Compress
# Decompress
# Show file info
Python API
=
# Compress sine wave data
=
=
# Decompress
=
How It Works
Traditional compression finds patterns in bytes. ALICE finds patterns in mathematics.
Original Data = Generated(parameters) + Residual
Where:
- Generated() = Mathematical function (polynomial, sine wave, etc.)
- parameters = Tiny description (~100 bytes)
- Residual = Compressed difference (often near-zero)
Example
Input: Sine wave, 100,000 samples (400 KB)
↓
Analysis: Detected as "Sine wave, freq=50Hz, amp=1.0"
↓
Output: Parameters only (~280 bytes)
↓
Result: 400 KB → 280 bytes = 1400x compression
Laws with evidence (law module)
law::SignalLaw keeps a fitted polynomial together with the evidence it came
from, the measured residual, the x range the evidence covers, its provenance
and reference values it must reproduce. It is recomputed at new conditions but
never extrapolated, and new evidence is judged rather than appended:
use ;
let pts: = .map.collect;
let law = fit_polynomial?;
assert!; // a condition that was not measured
assert!; // outside the measured range
let policy = IngestPolicy ;
assert!;
# Ok::
| Verdict | When |
|---|---|
Supports |
the new points agree with the law within the band |
ParameterUpdate |
the same form fits old and new points with other parameters (the refitted law is returned) |
ResidualGrew |
the deviation exceeds the band but not break_factor times it |
Breaks |
the new points are not described by this form |
OutOfRange |
some points lie outside the range the law was fitted on; nothing is judged |
The rules and their order are documented on the module and pinned by
tests/analytic_law.rs.
Benchmarks
| Data Type | Original | Compressed | Ratio |
|---|---|---|---|
| Sine wave (100K samples) | 400 KB | ~280 bytes | 1400x |
| Polynomial (degree 3) | 400 KB | ~285 bytes | 1400x |
| Linear gradient | 400 KB | ~250 bytes | 1600x |
| Random data | 400 KB | ~370 KB | 1.08x (LZMA fallback) |
Ideal Use Cases
- Scientific Data: Simulation outputs, sensor readings, waveforms
- Game Assets: Procedural textures, terrain heightmaps
- IoT/Edge: Sensor logs on bandwidth-constrained devices
- Time Series: Telemetry, monitoring logs with patterns
When NOT to Use
| Data Type | Reason |
|---|---|
| JPEG/PNG/MP3 | Already compressed |
| Random/encrypted data | No pattern to exploit |
| Small files (<1KB) | Header overhead |
Building from Source
# Install Python package
# Run tests
# Rust core crate — every CI gate, locally (scripts/preflight.sh --quick ≈ 3 min)
# CLI / FFI crate
Related Projects
The same idea applied to other domains — this crate stores the recipe for a signal; these store the recipe for a shape, a physical state, or a frame.
| Project | Description | Links |
|---|---|---|
| ALICE-SDF | 3D geometry as laws instead of polygons — GLSL / WGSL / HLSL transpile, SVO, marching cubes, cross-platform bit-exact evaluation | crates.io · docs.rs · GitHub |
| ALICE-DetMath | The bit-exact transcendental layer (sin / exp / atan2 / …) that this crate's Fourier / Perlin generators and ALICE-SDF both evaluate, so the same law yields the same bits on every platform |
crates.io · docs.rs · GitHub |
| ALICE-DB | Model-based time-series database | crates.io · GitHub |
| ALICE-Edge | Embedded / IoT model generator (no_std) |
crates.io · GitHub |
| ALICE-Streaming-Protocol | Ultra-low bandwidth video streaming | crates.io · GitHub |
| ALICE-Eco-System | Complete Edge-to-Cloud pipeline demo | GitHub |
All projects share the core philosophy: encode the generation process, not the data itself.
License
- Rust core crate
alice-zip(/): MIT OR Apache-2.0, at your option - CLI / FFI crate (
libalice/), Python package (alice_zip/), bindings: MIT libalice-enterprise/: separate, unpublished proprietary crate (see its own LICENSE)
Author
Created by Moroya Sakamoto
"The best compression is not to store data, but to store the recipe for generating it."