Skip to main content

Verify and diff 3D-printer G-code by the material it deposits — an open, checkable IR for the mesh-to-G-code half of the fabrication pipeline.

Project description

Kerf

An open, engine-independent IR for the mesh → G-code half of 3D printing — with a written-down denotational semantics and a lowering whose correctness is mechanically checked.

Think "LLVM for slicing," but the point is the verifier, not the container.

Slicers (Cura, PrusaSlicer, OrcaSlicer) are compilers: they lower geometry into machine code (G-code), but each buries that machinery in a private codebase, and no mainstream slicer can show its output corresponds to the input. Kerf is the open middle: an IR whose meaning is defined (denote = the material a program deposits), a lowering Kerf owns, and an oracle that checks the lowering preserves that meaning. Today it mostly consumes slicer G-code to verify it.

Install

# CLI (the `kerf` binary)
cargo install kerf-cli

# Python (CPython  3.12)
pip install pykerf

# Server + dashboard
docker run -p 8080:8080 ghcr.io/khushiyant/kerf

Quickstart

# Verify: do Kerf's operations preserve this print?
kerf verify part.gcode              # exit 0 sound · 1 unsound · 3 nothing to verify

# Diff: do two slicers / settings make the same part?
kerf diff old.gcode new.gcode       # exit 0 identical · 1 differ

# Inspect: what did the parser recover, guess, or drop?
kerf inspect part.gcode
import json, pykerf
r = json.loads(pykerf.verify_gcode(open("part.gcode").read()))
assert r["has_geometry"] and r["pass_preserves_denotation"] and r["translation_invariant"]

What it does

  • Two-level IRhi (geometric regions) and lo (move plan), joined by a lowering Kerf owns.
  • denote — reference semantics: a program's deposited material as conservative raster occupancy, reversal-invariant.
  • Soundness oracle — checks the lowering and each optimization pass preserve denote; a negative test confirms a material-dropping pass is rejected.
  • G-code frontend — parses real Cura / PrusaSlicer / OrcaSlicer / Bambu / Simplify3D / KISSlicer / ideaMaker / Slic3r output, including arc (G2/G3) flattening; never panics on untrusted input.
  • kerf verify / kerf diff — verification and material comparison over real parsed geometry, with CI-friendly exit codes.
  • Proofs — P1–P4 proved in Lean 4 (no sorry); load-bearing kernels model-checked with Kani.

Limitations

  • Resolution-bounded. denote compares material up to the raster resolution; choose --resolution ≤ your smallest feature. Sub-resolution differences are not distinguished.
  • Planar only. 2D-per-layer IR; non-planar / vase mode is out of scope.
  • Deposited geometry, not process state. Widths without a ;WIDTH: comment are estimated; feature roles are an untrusted re-inference. The lo→G-code emitter is lossy and sits outside the verified boundary.
  • Checked oracle, not an end-to-end proof. A semantics-level mechanized proof over exact geometry is future work.

Repository

crates/kerf-core   IR, lowering, denote, passes, G-code frontend, verify/diff
crates/kerf-cli    the `kerf` binary
crates/kerf-py     PyO3 bindings (published to PyPI as pykerf)
crates/kerf-{api,engine,store,queue,worker,ingest,render}   verification service + dashboard
proofs/            Lean 4 proofs of P1–P4
docs/              design record and semantics

The full design rationale, prior-art scoping, and semantics live in docs/ — start with docs/00-thesis.md and docs/08-semantics.md.

License

Dual-licensed under MIT or Apache-2.0, at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pykerf-0.2.0-cp312-abi3-win_amd64.whl (320.3 kB view details)

Uploaded CPython 3.12+Windows x86-64

pykerf-0.2.0-cp312-abi3-manylinux_2_34_x86_64.whl (474.9 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.34+ x86-64

pykerf-0.2.0-cp312-abi3-macosx_11_0_arm64.whl (408.3 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

Details for the file pykerf-0.2.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pykerf-0.2.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 320.3 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pykerf-0.2.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9c712a49fab29e445c0bfc6b0b70d36ce9c47845c2af333a2d3b87c003e31af8
MD5 ec714b8820fa35261080942c7d5fc962
BLAKE2b-256 0d0f9ff3256ea68e0948fc88890af97a445640f71dfbf0f4e76c1d8ec4ff2b6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykerf-0.2.0-cp312-abi3-win_amd64.whl:

Publisher: release.yml on Khushiyant/kerf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pykerf-0.2.0-cp312-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pykerf-0.2.0-cp312-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bd7b0816c24eea7d1967553931ee9ecff6e77d320706c257e98ccc1c47e888a5
MD5 4e95d137001f41fe8cf14cb4bcd2e66f
BLAKE2b-256 0902fd065825766a74ba114ce9628a7ded129da63f0f9ea7b02658993aaadf95

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykerf-0.2.0-cp312-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Khushiyant/kerf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pykerf-0.2.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pykerf-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ced7e6b97b9bbff8aef8bb003321c7a28c412130d13a54834753bf7c66b3823f
MD5 8072733a9ec29473d1d8f3764d382873
BLAKE2b-256 172973e84116b7394c915ab40577f70f185283e20325c27525f2a3f452e26b00

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykerf-0.2.0-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on Khushiyant/kerf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page