KeY
Also known as KeY Prover
Write JML specifications for sequential Java code; KeY's prover, mostly automatic with interactive steps when needed, proves the code meets them.
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
From your code to an accepted proof. Each step either has to be trusted or is checked by something else.
- Input Java code
- Front end 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 Trusted Optional; when used to close a goal, the solver's answer is trusted.
- Compiler javac and the Java virtual machine Trusted
Verified or checked: outside the trusted base Validated per run or by tests Trusted without proof
- Java: Sequential Java. Generics, threads, switch expressions and several other Java 5+ features are not supported (KeY 3.0 Java coverage table).
Trust
What a proof from this toolchain relies on: the trusted computing baseTrusted computing base (TCB). Everything that must be correct for a proof to mean what it says., one part at a time. How these are rated.
- Checker What has the final word on a proof?Partial
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.
- Semantics Is the tool's model of the language the real language?Weak
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.
- Frontend How does your source get into the model?Partial
KeY's own Java parser, separate from javac.
- Binary gap Does the proof cover what actually runs?Weak
javac and the JVM, including its JIT compiler, are not verified.
- Escape hatches Can a proof silently rest on unchecked assumptions?Partial
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.
What it can prove
Kinds of guarantees, not how easy they are to get.
| Feature | Support | Notes |
|---|---|---|
| No undefined behavior Memory safety and absence of runtime errors: no out-of-bounds access, use-after-free, overflow traps, panics or undefined behavior on any input allowed by the precondition. | SupportedSupported.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 | 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 |
| Functional correctness The code meets a written specification of its results, for example “returns the sorted list” or “implements this RFC”. | SupportedSupported.Functional specifications in JML (method contracts, class invariants, loop invariants). Source | Functional specifications in JML (method contracts, class invariants, loop invariants). source |
| Equivalence Two programs (an optimized and a reference version, or code before and after a change) are proved to behave the same, or one refines the other. | PartialPartial.No dedicated equivalence mode; you specify the relation between two versions by hand. | No dedicated equivalence mode; you specify the relation between two versions by hand. |
| Information flow Secrets do not influence public outputs, timing or memory access patterns (constant-time code, non-interference). | SupportedSupported.KeY's information-flow module checks JML "determines" clauses, which state which results may depend on which inputs. Source | KeY's information-flow module checks JML "determines" clauses, which state which results may depend on which inputs. source |
| Concurrency Correctness of code with threads or shared memory: absence of data races, deadlock freedom, linearizability of concurrent data structures. | Not supportedNot supported.Multithreading is not supported; KeY reasons about sequential Java only. Source | Multithreading is not supported; KeY reasons about sequential Java only. source |
| Termination and liveness Every run finishes, or the system keeps making progress (liveness). | SupportedSupported.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 | 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 |
Language coverage
Which parts of Java it handles. Hover or focus a mark for details.
Common features
| Feature | Support | Notes |
|---|---|---|
| Machine integers Fixed-width integer arithmetic, overflow and bit operations. | PartialPartial.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 | 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 |
| Floating point IEEE 754 floating-point arithmetic, including rounding and NaNs. | SupportedSupported.Supported; needs an installed SMT solver with floating-point support. Source | Supported; needs an installed SMT solver with floating-point support. source |
| Heap and pointers Dynamically allocated memory, pointers or references, and aliasing. | SupportedSupported.Objects and references with an explicit heap model. Source | Objects and references with an explicit heap model. source |
| Arrays and buffers Indexed memory such as arrays, slices, vectors and byte buffers. | SupportedSupported.Including multi-dimensional arrays, ArrayStoreException and out-of-bounds behavior. Source | Including multi-dimensional arrays, ArrayStoreException and out-of-bounds behavior. source |
| Loops Unbounded loops, which need invariants or bounds to verify. | SupportedSupported.Loop invariants; for-each loops are rewritten to indexed or iterator loops. Source | Loop invariants; for-each loops are rewritten to indexed or iterator loops. source |
| Recursion Functions that call themselves, directly or through others. | SupportedSupported.Recursive methods with measured_by clauses for termination. Source | Recursive methods with measured_by clauses for termination. source |
| Higher-order code Function pointers, closures and callbacks. | PartialPartial.Lambdas and method references are partly supported (turned into classes); lambdas in field initializers and anonymous classes are not. Source | Lambdas and method references are partly supported (turned into classes); lambdas in field initializers and anonymous classes are not. source |
| Threads and shared memory Concurrent threads with locks, atomics or message passing. | Not supportedNot supported.Multithreading is not supported. Source | Multithreading is not supported. source |
| I/O and system calls Files, network, system calls and foreign-function calls. | Not supportedNot 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 | KeY has no model of the JVM runtime or I/O; library methods, including I/O, need stub classes with hand-written contracts. source |
| Standard library Specifications or models for the language's standard library. | PartialPartial.Library classes must be on KeY's classpath, usually as stubs with contracts; KeY reports an error otherwise. Source | Library classes must be on KeY's classpath, usually as stubs with contracts; KeY reports an error otherwise. source |
Java-specific features
| Feature | Support | Notes |
|---|---|---|
| Objects and inheritance Classes, interfaces, inheritance and dynamic dispatch. | SupportedSupported.Classes, interfaces, inheritance and dynamic dispatch. Private and default interface methods load but cannot yet be proved about. Source | Classes, interfaces, inheritance and dynamic dispatch. Private and default interface methods load but cannot yet be proved about. source |
| Exceptions Checked and unchecked exceptions. | SupportedSupported.try/catch/finally, throw, multi-catch and try-with-resources. Source | try/catch/finally, throw, multi-catch and try-with-resources. source |
| Generics Generic classes and methods. | Not supportedNot supported.Generics are not supported in any form; a separate tool can remove them before loading. Source | Generics are not supported in any form; a separate tool can remove them before loading. source |
| Threads and synchronized Java threads, locks and the Java memory model. | Not supportedNot supported.Multithreading is not supported. Source | Multithreading is not supported. source |
Stage
Computed from the evidence below; see the criteria. 2criteria are missing for Stage 2.
- Met: Released or updated in the last 12 months Latest release: 3.0.0, 2026-07-23. evidence
- Met: Installs and runs on current platforms Runnable jar (the 3.0 release targets Java 21); SMT solvers are optional extras. evidence
- Met: User documentation or tutorial evidence
- Met: Used by a group other than its authors CWI researchers used KeY to analyze a bug in Java's LinkedList. evidence
- Not met: Verified code in production at two or more independent organizations None recorded.
- Met: Checker axis is not red
- Not met: Semantics axis is not red
- Met: Public channel for soundness bugs Public GitHub issues with a "Soundness" label. evidence
In use
Verified code in production, and notable verification projects.
Facts and sources
- Effort
- Interactive: You write proofs step by step in a proof assistant.
- Licence
- Open source, GPL-2.0-or-later
- Maintained by
- Karlsruhe Institute of Technology, Technical University of Darmstadt, Chalmers University of Technology
- Latest release
- 3.0.0 (23 Jul 2026) source
- Last checked
- 26 Nov 2026
Further sources
- KeY Java coverage (as of KeY 3.0) · accessed 26 Nov 2026
- KeY taclet option declarations (defaults and unsound options) · accessed 26 Nov 2026
- KeY proof options appendix (integer semantics) · accessed 26 Nov 2026
- KeY 3.0.0 release notes · accessed 26 Nov 2026
- Deductive Software Verification - The KeY Book (2016) · accessed 26 Nov 2026