# KeY

> Write JML specifications for sequential Java code; KeY's prover, mostly automatic with interactive steps when needed, proves the code meets them.

- Kind: toolchain
- Verifies: Java (Sequential Java. Generics, threads, switch expressions and several other Java 5+ features are not supported (KeY 3.0 Java coverage table).)
- Effort: Interactive — You write proofs step by step in a proof assistant.
- Stage: 1 (Usable)
- Trust: Checker partial, Semantics weak, Frontend partial, Binary gap weak, Escape hatches partial
- Licence: open-source, GPL-2.0-or-later
- Latest release: 3.0.0 (2026-07-23) https://github.com/KeYProject/key/releases/tag/KeY-3.0.0
- Links: [homepage](https://www.key-project.org/), [repo](https://github.com/KeYProject/key), [docs](https://keyproject.github.io/key-docs/), [paper](https://doi.org/10.1007/978-3-319-49812-6), [tutorial](https://keyproject.github.io/key-docs/user/getting-started/)

## Use it if
- You want to prove functional correctness of sequential Java classes, such as library algorithms and data structures.
- You want to see and steer the proof step by step when automation gets stuck.
- You need information-flow (non-interference) proofs for Java code.

## Look elsewhere if
- Your code uses generics, threads, switch expressions or many library classes; these are not supported.
- You forget to change the default integer setting; by default KeY ignores integer overflow, which KeY itself marks as unsound.
- You need the proof checked by a small, independent proof kernel.

## How it works (pipeline)

| Step | Component | Assurance | Note |
|---|---|---|---|
| frontend | KeY's Java parser (based on JavaParser since KeY 3.0) and JML parser | trusted | A separate front end from javac; KeY 3.0 replaced the older Recoder parser. |
| translation | JML to Java dynamic logic proof obligations | trusted |  |
| checker | KeY prover (sequent calculus with symbolic execution, defined by taclet rules) | trusted | The rule base is large and trusted. Some rules have saved soundness proofs that KeY's test suite replays (ProveRules). |
| checker | SMT solvers (Z3, cvc5, CVC4, Princess), optional (`z3`) | trusted | Optional; when used to close a goal, the solver's answer is trusted. |
| compiler | javac and the Java virtual machine | trusted |  |

## Trust

| Axis | Level | Summary | Note |
|---|---|---|---|
| Checker | Partial (amber) | KeY's own rule-based prover decides; its large rule base is trusted, not a small kernel. | Some rules have saved soundness proofs that the test suite replays, but most are trusted. Optional SMT solvers can close goals and are trusted when used. [source](https://keyproject.github.io/key-docs/devel/testing/prove-rules/) |
| Semantics | Weak (red) | Default integer rules ignore overflow, which KeY itself marks unsound; Java mode exists. | The default option arithmeticSemanticsIgnoringOF lets KeY prove properties that do not hold under Java's actual integer semantics. Switching intRules to javaSemantics or arithmeticSemanticsCheckingOF fixes this. Apart from this, the Java calculus is built into KeY and tested by its own test suite. [source](https://github.com/KeYProject/key/blob/main/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/optionsDeclarations.key) |
| Frontend | Partial (amber) | KeY's own Java parser, separate from javac. |  [source](https://github.com/KeYProject/key/pull/3120) |
| Binary gap | Weak (red) | javac and the JVM, including its JIT compiler, are not verified. |  |
| Escape hatches | Partial (amber) | Unsound options, model-field axioms and library stubs; KeY 3.0 has a soundness report. | KeY 3.0 added a "soundiness" report that lists unsound taclet options and assumptions used in a proof; it is opened from the proof statistics dialog rather than shown by default. [source](https://github.com/KeYProject/key/pull/3887) |

## What it can prove

| Property | Support |
|---|---|
| No undefined behavior | Supported — Java has no undefined behavior. A normal_behavior contract requires that the method does not end with an exception, so KeY proves that no runtime exceptions (such as null dereference or index errors) occur. ([source](https://keyproject.github.io/key-docs/user/getting-started/proving/)) |
| Functional correctness | Supported — Functional specifications in JML (method contracts, class invariants, loop invariants). ([source](https://keyproject.github.io/key-docs/user/getting-started/)) |
| Equivalence | Partial — No dedicated equivalence mode; you specify the relation between two versions by hand. |
| Information flow | Supported — KeY's information-flow module checks JML "determines" clauses, which state which results may depend on which inputs. ([source](https://github.com/KeYProject/key/pull/3640)) |
| Concurrency | Not supported — Multithreading is not supported; KeY reasons about sequential Java only. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Termination and liveness | Supported — A normal_behavior contract without a diverges clause requires the method to terminate, and KeY proves it. Loops use decreasing clauses and recursion uses measured_by. ([source](https://keyproject.github.io/key-docs/user/getting-started/proving/)) |

## Common features

| Feature | Support |
|---|---|
| Machine integers | Partial — Three settings exist. The default treats Java integers as unbounded mathematical integers, which KeY marks as unsound. "Java semantics" models overflow exactly, and "checking overflow" proves that no overflow happens. ([source](https://github.com/KeYProject/key/blob/main/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/optionsDeclarations.key)) |
| Floating point | Supported — Supported; needs an installed SMT solver with floating-point support. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Heap and pointers | Supported — Objects and references with an explicit heap model. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Arrays and buffers | Supported — Including multi-dimensional arrays, ArrayStoreException and out-of-bounds behavior. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Loops | Supported — Loop invariants; for-each loops are rewritten to indexed or iterator loops. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Recursion | Supported — Recursive methods with measured_by clauses for termination. ([source](https://keyproject.github.io/key-docs/user/language/jml-grammar/)) |
| Higher-order code | Partial — Lambdas and method references are partly supported (turned into classes); lambdas in field initializers and anonymous classes are not. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Threads and shared memory | Not supported — Multithreading is not supported. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| I/O and system calls | Not supported — KeY has no model of the JVM runtime or I/O; library methods, including I/O, need stub classes with hand-written contracts. ([source](https://keyproject.github.io/key-docs/user/faq/)) |
| Standard library | Partial — Library classes must be on KeY's classpath, usually as stubs with contracts; KeY reports an error otherwise. ([source](https://keyproject.github.io/key-docs/user/faq/)) |

## Java-specific features

| Feature | Support |
|---|---|
| Objects and inheritance | Supported — Classes, interfaces, inheritance and dynamic dispatch. Private and default interface methods load but cannot yet be proved about. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Exceptions | Supported — try/catch/finally, throw, multi-catch and try-with-resources. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Generics | Not supported — Generics are not supported in any form; a separate tool can remove them before loading. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |
| Threads and synchronized | Not supported — Multithreading is not supported. ([source](https://keyproject.github.io/key-docs/user/features/java-coverage/)) |

## Stage

**Stage 1: Usable.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Publicly available | yes | [evidence](https://github.com/KeYProject/key) |
| 0 | At least one published verification uses it | yes | [evidence](https://doi.org/10.1007/978-3-031-07727-2_4) Verification of the JDK's IdentityHashMap (2022); earlier, the TimSort bug analysis. |
| 1 | Released or updated in the last 12 months | yes | [evidence](https://github.com/KeYProject/key/releases/tag/KeY-3.0.0) Latest release: 3.0.0, 2026-07-23. |
| 1 | Installs and runs on current platforms | yes | [evidence](https://github.com/KeYProject/key/releases/tag/KeY-3.0.0) Runnable jar (the 3.0 release targets Java 21); SMT solvers are optional extras. |
| 1 | User documentation or tutorial | yes | [evidence](https://keyproject.github.io/key-docs/) |
| 1 | Used by a group other than its authors | yes | [evidence](https://www.key-project.org/2023/07/23/cwi-researchers-win-google-award-for-finding-a-bug-in-javas-linkedlist-using-key/) CWI researchers used KeY to analyze a bug in Java's LinkedList. |
| 2 | Verified code in production at two or more independent organizations | no | None recorded. |
| 2 | Checker axis is not red | yes |  |
| 2 | Semantics axis is not red | no |  |
| 2 | Public channel for soundness bugs | yes | [evidence](https://github.com/KeYProject/key/issues?q=label%3A%22%E2%9C%8B+Soundness%22) Public GitHub issues with a "Soundness" label. |

Missing for Stage 2: Verified code in production at two or more independent organizations; Semantics axis is not red.

## Projects
- [JDK IdentityHashMap verification](https://doi.org/10.1007/978-3-031-07727-2_4)
- [Bug in OpenJDK's TimSort found while verifying it (CAV 2015)](https://doi.org/10.1007/978-3-319-21690-4_16)
- [Bug in Java's LinkedList (Google award)](https://www.key-project.org/2023/07/23/cwi-researchers-win-google-award-for-finding-a-bug-in-javas-linkedlist-using-key/)

## Sources
- [KeY Java coverage (as of KeY 3.0)](https://keyproject.github.io/key-docs/user/features/java-coverage/)
- [KeY taclet option declarations (defaults and unsound options)](https://github.com/KeYProject/key/blob/main/key.core/src/main/resources/de/uka/ilkd/key/proof/rules/optionsDeclarations.key)
- [KeY proof options appendix (integer semantics)](https://keyproject.github.io/key-docs/user/getting-started/appendix/)
- [KeY 3.0.0 release notes](https://github.com/KeYProject/key/releases/tag/KeY-3.0.0)
- [Deductive Software Verification - The KeY Book (2016)](https://doi.org/10.1007/978-3-319-49812-6)

---
Last checked 2026-11-26. Data: [JSON](/toolchains/key.json) · Page: [HTML](/toolchains/key/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
