copyright: Copyright (c) Runtime Verification, Inc. All Rights Reserved.
The K Framework is a language-agnostic formal specification and verification framework developed by Runtime Verification.
It lets you define programming language semantics in .k files and then automatically derives an interpreter, model checker, and deductive verifier from that definition.
The repository is a monorepo with two independent technology stacks:
- Java/Scala — the K compiler toolchain (
kompile,krun,kprove, etc.) - Python (
pyk/) — thekframeworkPython SDK for programmatically interacting with the K toolchain
k-frontend/ K language parser and frontend (Java/Scala)
k-distribution/ Main distribution bundle
bin/, lib/ Symlinks into target/release/k/
include/kframework/ Shared Makefile infrastructure (ktest.mak, ktest-group.mak)
tests/regression-new/ Java-backend regression suite (229 test subdirs)
haskell-backend/ Haskell-based symbolic backend
llvm-backend/ LLVM-based concrete execution backend
pyk/ Python SDK sub-project (self-contained)
src/pyk/ Package source (cli, kast, kore, proof, kcfg, kdist, …)
src/tests/ pytest test suite (unit/, integration/)
regression-new/ Python-backend regression suite (213 test subdirs)
pyproject.toml Build & tool config (hatchling, black, mypy, flake8, …)
Makefile All pyk make targets
k-tutorial/ Tutorial K definitions
mvn package -DskipTests
This compiles all Maven modules (k-frontend, k-distribution, haskell-backend, llvm-backend) and produces JARs under each module's target/ directory.
Java 17 and Scala 2.13 are required.
The pyk/ sub-project uses hatchling as its build backend and uv as its package manager.
No explicit build step is needed before running lint or tests — the make targets handle installation.
mvn spotless:apply
This auto-formats all Java/Scala sources (Google Java Format + Scalafmt).
Run it after every Java change; commits must pass mvn spotless:check.
make -C pyk check
This runs, in order: black --check, isort --check, autoflake --check, flake8, mypy, pydocstyle.
To auto-apply all formatters:
make -C pyk format
Key style settings (from pyk/pyproject.toml):
black: line-length 120, skip-string-normalizationisort: black profile, line-length 120mypy:disallow_untyped_defs = truepydocstyle: Google convention
There are four distinct test surfaces.
mvn verify
Runs all JUnit 4 tests across k-frontend and k-distribution via Maven Surefire.
Tests run with LC_NUMERIC=en_US.UTF-8.
make -C pyk test
Runs src/tests/unit/ and src/tests/integration/ with 4 parallel workers (pytest-xdist, worksteal).
Unit tests only (faster, no K toolchain required):
make -C pyk test-unit
make -C k-distribution/tests/regression-new
229 subdirectory test cases.
Each test compiles a .k definition with kompile and executes it with krun or kprove, comparing output against .out baseline files.
The shared test infrastructure lives in k-distribution/include/kframework/ktest.mak.
make -C pyk/regression-new
213 subdirectory test cases; 113 are currently skipped (listed in pyk/regression-new/skipped).
Same test infrastructure as the Java regression suite but exercises pyk-specific code paths.
If a change intentionally alters K program output, regenerate the .out files:
make -C k-distribution/tests/regression-new update-results
make -C pyk/regression-new update-results
Commit the updated baseline files in a dedicated commit after the logic change.